Add repositories_changed_event to Geo::EventLog model

parent 07b389d1
......@@ -16,10 +16,15 @@ module Geo
class_name: 'Geo::RepositoryRenamedEvent',
foreign_key: :repository_renamed_event_id
belongs_to :repositories_changed_event,
class_name: 'Geo::RepositoriesChangedEvent',
foreign_key: :repositories_changed_event_id
def event
repository_updated_event ||
repository_deleted_event ||
repository_renamed_event
repository_renamed_event ||
repositories_changed_event
end
end
end
......@@ -37,4 +37,8 @@ FactoryGirl.define do
old_path { project.path }
new_path { project.path }
end
factory :geo_repositories_changed_event, class: Geo::RepositoriesChangedEvent do
geo_node
end
end
......@@ -5,6 +5,7 @@ RSpec.describe Geo::EventLog, type: :model do
it { is_expected.to belong_to(:repository_updated_event).class_name('Geo::RepositoryUpdatedEvent').with_foreign_key('repository_updated_event_id') }
it { is_expected.to belong_to(:repository_deleted_event).class_name('Geo::RepositoryDeletedEvent').with_foreign_key('repository_deleted_event_id') }
it { is_expected.to belong_to(:repository_renamed_event).class_name('Geo::RepositoryRenamedEvent').with_foreign_key('repository_renamed_event_id') }
it { is_expected.to belong_to(:repositories_changed_event).class_name('Geo::RepositoriesChangedEvent').with_foreign_key('repositories_changed_event_id') }
end
describe '#event' do
......@@ -32,6 +33,13 @@ RSpec.describe Geo::EventLog, type: :model do
expect(subject.event).to eq repository_renamed_event
end
it 'returns repositories_changed_event when set' do
repositories_changed_event = build(:geo_repositories_changed_event)
subject.repositories_changed_event = repositories_changed_event
expect(subject.event).to eq repositories_changed_event
end
end
describe '#project_id' 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