Commit 18e78d23 authored by Max Woolf's avatar Max Woolf

Remove substransaction from wiki event creation

Removes a use of `safe_find_or_create_by!` when
adding a wiki-related Event.

Changelog: fixed
parent 4ba24381
...@@ -10,11 +10,9 @@ module WikiPages ...@@ -10,11 +10,9 @@ module WikiPages
end end
def execute(slug, page, action, event_fingerprint) def execute(slug, page, action, event_fingerprint)
event = Event.transaction do wiki_page_meta = WikiPage::Meta.find_or_create(slug, page)
wiki_page_meta = WikiPage::Meta.find_or_create(slug, page)
::EventCreateService.new.wiki_event(wiki_page_meta, author, action, event_fingerprint) event = ::EventCreateService.new.wiki_event(wiki_page_meta, author, action, event_fingerprint)
end
ServiceResponse.success(payload: { event: event }) ServiceResponse.success(payload: { event: event })
rescue ::EventCreateService::IllegalActionError, ::ActiveRecord::ActiveRecordError => e rescue ::EventCreateService::IllegalActionError, ::ActiveRecord::ActiveRecordError => e
......
...@@ -34,10 +34,6 @@ RSpec.describe WikiPages::EventCreateService do ...@@ -34,10 +34,6 @@ RSpec.describe WikiPages::EventCreateService do
it 'does not create an event' do it 'does not create an event' do
expect { response }.not_to change(Event, :count) expect { response }.not_to change(Event, :count)
end end
it 'does not create a metadata record' do
expect { response }.not_to change(WikiPage::Meta, :count)
end
end end
it 'returns a successful response' do it 'returns a successful response' 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