2017-12-27 06:22:18 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
require Rails.root.join('db', 'migrate', '20171106151218_issues_moved_to_id_foreign_key.rb')
|
|
|
|
|
|
|
|
# The schema version has to be far enough in advance to have the
|
|
|
|
# only_mirror_protected_branches column in the projects table to create a
|
|
|
|
# project via FactoryBot.
|
2017-12-27 11:22:46 +00:00
|
|
|
describe IssuesMovedToIdForeignKey, :migration, schema: 20171114150259 do
|
2018-03-30 15:18:44 +00:00
|
|
|
let!(:issue_first) { create(:issue, moved_to_id: issue_second.id) } # rubocop:disable RSpec/FactoriesInMigrationSpecs
|
|
|
|
let!(:issue_second) { create(:issue, moved_to_id: issue_third.id) } # rubocop:disable RSpec/FactoriesInMigrationSpecs
|
|
|
|
let!(:issue_third) { create(:issue) } # rubocop:disable RSpec/FactoriesInMigrationSpecs
|
2017-12-27 06:22:18 +00:00
|
|
|
|
|
|
|
subject { described_class.new }
|
|
|
|
|
|
|
|
it 'removes the orphaned moved_to_id' do
|
|
|
|
subject.down
|
|
|
|
|
|
|
|
issue_third.update_attributes(moved_to_id: 100000)
|
|
|
|
|
|
|
|
subject.up
|
|
|
|
|
|
|
|
expect(issue_first.reload.moved_to_id).to eq(issue_second.id)
|
|
|
|
expect(issue_second.reload.moved_to_id).to eq(issue_third.id)
|
|
|
|
expect(issue_third.reload.moved_to_id).to be_nil
|
|
|
|
end
|
|
|
|
end
|