Commit 76f16dd6
Changed files (3)
app
controllers
services
application
app/controllers/creations_controller.rb
@@ -25,8 +25,7 @@ class CreationsController < ApplicationController
end
def create_cake_succeeded(cake)
- @creation = cake
- redirect_to new_my_cake_photo_path(@creation)
+ redirect_to new_my_cake_photo_path(cake)
end
def create_cake_failed(cake)
app/services/application/handlers/publish_cake_to_twitter.rb
@@ -1,14 +1,15 @@
class PublishCakeToTwitter
- def initialize(twitter_publisher)
+ def initialize(twitter_publisher, cakes = Creation)
@twitter = twitter_publisher
+ @cakes = cakes
end
def handles?(event)
- :new_creation_added == event
+ :cake_published == event
end
def handle(message)
- tweet_about(Creation.find(message[:creation_id]))
+ tweet_about(cakes.find(message[:cake_id]))
end
private
app/services/application/create_cake_command.rb
@@ -10,7 +10,7 @@ class CreateCakeCommand
@current_user.tag(cake, with: tags, on: :tags)
if cake.save
- @message_bus.publish(:new_creation_added, creation_id: cake.id)
+ @message_bus.publish(:cake_published, cake_id: cake.id)
@context.create_cake_succeeded(cake)
else
@context.create_cake_failed(cake)