2017-09-10 17:25:29 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
require Rails.root.join('db', 'post_migrate', '20170815060945_remove_duplicate_mr_events.rb')
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
describe RemoveDuplicateMrEvents, :delete do
|
2017-09-10 17:25:29 +05:30
|
|
|
let(:migration) { described_class.new }
|
|
|
|
|
|
|
|
describe '#up' do
|
2018-05-09 12:01:36 +05:30
|
|
|
let(:user) { create(:user) } # rubocop:disable RSpec/FactoriesInMigrationSpecs
|
|
|
|
let(:merge_requests) { create_list(:merge_request, 2) } # rubocop:disable RSpec/FactoriesInMigrationSpecs
|
|
|
|
let(:issue) { create(:issue) } # rubocop:disable RSpec/FactoriesInMigrationSpecs
|
2017-09-10 17:25:29 +05:30
|
|
|
let!(:events) do
|
|
|
|
[
|
2018-05-09 12:01:36 +05:30
|
|
|
create(:event, :created, author: user, target: merge_requests.first), # rubocop:disable RSpec/FactoriesInMigrationSpecs
|
|
|
|
create(:event, :created, author: user, target: merge_requests.first), # rubocop:disable RSpec/FactoriesInMigrationSpecs
|
|
|
|
create(:event, :updated, author: user, target: merge_requests.first), # rubocop:disable RSpec/FactoriesInMigrationSpecs
|
|
|
|
create(:event, :created, author: user, target: merge_requests.second), # rubocop:disable RSpec/FactoriesInMigrationSpecs
|
|
|
|
create(:event, :created, author: user, target: issue), # rubocop:disable RSpec/FactoriesInMigrationSpecs
|
|
|
|
create(:event, :created, author: user, target: issue) # rubocop:disable RSpec/FactoriesInMigrationSpecs
|
2017-09-10 17:25:29 +05:30
|
|
|
]
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'removes duplicated merge request create records' do
|
|
|
|
expect { migration.up }.to change { Event.count }.from(6).to(5)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|