diff options
author | Felipe Artur <felipefac@gmail.com> | 2019-02-12 14:40:37 -0200 |
---|---|---|
committer | Felipe Artur <felipefac@gmail.com> | 2019-02-12 14:40:37 -0200 |
commit | 362d56e65a0e23fcf4fd5bd4535d258c3659ffd5 (patch) | |
tree | 2b3082775f496d79e7657d4fa92363fc3bebbe91 /spec/migrations | |
parent | e9b84f50e961ee7c3abfb8192de8f4fc778df041 (diff) | |
download | gitlab-ce-362d56e65a0e23fcf4fd5bd4535d258c3659ffd5.tar.gz |
Schedule background migrations and specs
Diffstat (limited to 'spec/migrations')
-rw-r--r-- | spec/migrations/add_state_id_to_issuables_spec.rb | 60 |
1 files changed, 12 insertions, 48 deletions
diff --git a/spec/migrations/add_state_id_to_issuables_spec.rb b/spec/migrations/add_state_id_to_issuables_spec.rb index 4416f416c18..b0e285db1f3 100644 --- a/spec/migrations/add_state_id_to_issuables_spec.rb +++ b/spec/migrations/add_state_id_to_issuables_spec.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true require 'spec_helper' -require Rails.root.join('db', 'migrate', '20190206144959_change_issuable_states_to_integer.rb') +require Rails.root.join('db', 'migrate', '20190211131150_add_state_id_to_issuables.rb') describe AddStateIdToIssuables, :migration do let(:namespaces) { table(:namespaces) } @@ -20,14 +20,15 @@ describe AddStateIdToIssuables, :migration do it 'migrates state column to integer' do opened_issue = issues.create!(description: 'first', state: 'opened') closed_issue = issues.create!(description: 'second', state: 'closed') + invalid_state_issue = issues.create!(description: 'fourth', state: 'not valid') nil_state_issue = issues.create!(description: 'third', state: nil) migrate! - issues.reset_column_information - expect(opened_issue.reload.state).to eq(Issue.states.opened) - expect(closed_issue.reload.state).to eq(Issue.states.closed) - expect(nil_state_issue.reload.state).to eq(nil) + expect(opened_issue.reload.state_id).to eq(Issue.states.opened) + expect(closed_issue.reload.state_id).to eq(Issue.states.closed) + expect(invalid_state_issue.reload.state_id).to be_nil + expect(nil_state_issue.reload.state_id).to be_nil end end @@ -37,52 +38,15 @@ describe AddStateIdToIssuables, :migration do closed_merge_request = merge_requests.create!(state: 'closed', target_project_id: @project.id, target_branch: 'feature2', source_branch: 'master') merged_merge_request = merge_requests.create!(state: 'merged', target_project_id: @project.id, target_branch: 'feature3', source_branch: 'master') locked_merge_request = merge_requests.create!(state: 'locked', target_project_id: @project.id, target_branch: 'feature4', source_branch: 'master') - nil_state_merge_request = merge_requests.create!(state: nil, target_project_id: @project.id, target_branch: 'feature5', source_branch: 'master') + invalid_state_merge_request = merge_requests.create!(state: 'not valid', target_project_id: @project.id, target_branch: 'feature5', source_branch: 'master') migrate! - merge_requests.reset_column_information - expect(opened_merge_request.reload.state).to eq(MergeRequest.states.opened) - expect(closed_merge_request.reload.state).to eq(MergeRequest.states.closed) - expect(merged_merge_request.reload.state).to eq(MergeRequest.states.merged) - expect(locked_merge_request.reload.state).to eq(MergeRequest.states.locked) - expect(nil_state_merge_request.reload.state).to eq(nil) - end - end - end - - describe '#down' do - context 'issues' do - it 'migrates state column to string' do - opened_issue = issues.create!(description: 'first', state: 1) - closed_issue = issues.create!(description: 'second', state: 2) - nil_state_issue = issues.create!(description: 'third', state: nil) - - migration.down - - issues.reset_column_information - expect(opened_issue.reload.state).to eq('opened') - expect(closed_issue.reload.state).to eq('closed') - expect(nil_state_issue.reload.state).to eq(nil) - end - end - - context 'merge requests' do - it 'migrates state column to string' do - opened_merge_request = merge_requests.create!(state: 1, target_project_id: @project.id, target_branch: 'feature1', source_branch: 'master') - closed_merge_request = merge_requests.create!(state: 2, target_project_id: @project.id, target_branch: 'feature2', source_branch: 'master') - merged_merge_request = merge_requests.create!(state: 3, target_project_id: @project.id, target_branch: 'feature3', source_branch: 'master') - locked_merge_request = merge_requests.create!(state: 4, target_project_id: @project.id, target_branch: 'feature4', source_branch: 'master') - nil_state_merge_request = merge_requests.create!(state: nil, target_project_id: @project.id, target_branch: 'feature5', source_branch: 'master') - - migration.down - - merge_requests.reset_column_information - expect(opened_merge_request.reload.state).to eq('opened') - expect(closed_merge_request.reload.state).to eq('closed') - expect(merged_merge_request.reload.state).to eq('merged') - expect(locked_merge_request.reload.state).to eq('locked') - expect(nil_state_merge_request.reload.state).to eq(nil) + expect(opened_merge_request.reload.state_id).to eq(MergeRequest.states.opened) + expect(closed_merge_request.reload.state_id).to eq(MergeRequest.states.closed) + expect(merged_merge_request.reload.state_id).to eq(MergeRequest.states.merged) + expect(locked_merge_request.reload.state_id).to eq(MergeRequest.states.locked) + expect(invalid_state_merge_request.reload.state_id).to be_nil end end end |