Skip to content

Commit 134edbd

Browse files
author
Jan Provaznik
committed
Address specs failing in rails 4
We want to run CI with rails 4 for a short-term (until we are sure that we will ship with rails 5). The problem is that rails 4 can not handle rails 5 schema.rb properly - specifically `t.index` directive can not handle multiple indexes on the same column. Because combination of rails 4 + rails 5 schema will be used only in CI for a short-term, we can just ignore these incompatibility failures. This patch adds `rails5` helper for specs.
1 parent 7dcf397 commit 134edbd

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

spec/lib/gitlab/database/migration_helpers_spec.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1338,7 +1338,12 @@
13381338
end
13391339

13401340
describe '#index_exists_by_name?' do
1341-
it 'returns true if an index exists' do
1341+
# TODO: remove rails5-only after removing rails4 tests
1342+
# rails 4 can not handle multiple indexes on the same column set if
1343+
# index was added by 't.index' - t.index is used by default in schema.rb in
1344+
# rails 5. Let's run this test only in rails 5 env:
1345+
# see https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/21492#note_113602758
1346+
it 'returns true if an index exists', :rails5 do
13421347
expect(model.index_exists_by_name?(:projects, 'index_projects_on_path'))
13431348
.to be_truthy
13441349
end

spec/lib/gitlab/github_import/importer/pull_request_importer_spec.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,12 @@
240240
.and_return(user.id)
241241
end
242242

243-
it 'returns the existing merge request' do
243+
# TODO: remove rails5-only after removing rails4 tests
244+
# rails 4 can not handle multiple indexes on the same column set if
245+
# index was added by 't.index' - t.index is used by default in schema.rb in
246+
# rails 5. Let's run this test only in rails 5 env:
247+
# see https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/21492#note_113602758
248+
it 'returns the existing merge request', :rails5 do
244249
mr1, exists1 = importer.create_merge_request
245250
mr2, exists2 = importer.create_merge_request
246251

spec/spec_helper.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,10 @@
235235
example.run if Gitlab::Database.mysql?
236236
end
237237

238+
config.around(:each, :rails5) do |example|
239+
example.run if Gitlab.rails5?
240+
end
241+
238242
# This makes sure the `ApplicationController#can?` method is stubbed with the
239243
# original implementation for all view specs.
240244
config.before(:each, type: :view) do

0 commit comments

Comments
 (0)