Commit 134edbd7 authored by Jan Provaznik's avatar Jan Provaznik

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.
parent 7dcf3977
...@@ -1338,7 +1338,12 @@ describe Gitlab::Database::MigrationHelpers do ...@@ -1338,7 +1338,12 @@ describe Gitlab::Database::MigrationHelpers do
end end
describe '#index_exists_by_name?' do describe '#index_exists_by_name?' do
it 'returns true if an index exists' do # TODO: remove rails5-only after removing rails4 tests
# rails 4 can not handle multiple indexes on the same column set if
# index was added by 't.index' - t.index is used by default in schema.rb in
# rails 5. Let's run this test only in rails 5 env:
# see https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/21492#note_113602758
it 'returns true if an index exists', :rails5 do
expect(model.index_exists_by_name?(:projects, 'index_projects_on_path')) expect(model.index_exists_by_name?(:projects, 'index_projects_on_path'))
.to be_truthy .to be_truthy
end end
......
...@@ -240,7 +240,12 @@ describe Gitlab::GithubImport::Importer::PullRequestImporter, :clean_gitlab_redi ...@@ -240,7 +240,12 @@ describe Gitlab::GithubImport::Importer::PullRequestImporter, :clean_gitlab_redi
.and_return(user.id) .and_return(user.id)
end end
it 'returns the existing merge request' do # TODO: remove rails5-only after removing rails4 tests
# rails 4 can not handle multiple indexes on the same column set if
# index was added by 't.index' - t.index is used by default in schema.rb in
# rails 5. Let's run this test only in rails 5 env:
# see https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/21492#note_113602758
it 'returns the existing merge request', :rails5 do
mr1, exists1 = importer.create_merge_request mr1, exists1 = importer.create_merge_request
mr2, exists2 = importer.create_merge_request mr2, exists2 = importer.create_merge_request
......
...@@ -235,6 +235,10 @@ RSpec.configure do |config| ...@@ -235,6 +235,10 @@ RSpec.configure do |config|
example.run if Gitlab::Database.mysql? example.run if Gitlab::Database.mysql?
end end
config.around(:each, :rails5) do |example|
example.run if Gitlab.rails5?
end
# This makes sure the `ApplicationController#can?` method is stubbed with the # This makes sure the `ApplicationController#can?` method is stubbed with the
# original implementation for all view specs. # original implementation for all view specs.
config.before(:each, type: :view) do config.before(:each, type: :view) do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment