Skip to content

Instantly share code, notes, and snippets.

@maxinspace
Last active August 29, 2015 14:17
Show Gist options
  • Save maxinspace/afed5d12985932c7acb3 to your computer and use it in GitHub Desktop.
Save maxinspace/afed5d12985932c7acb3 to your computer and use it in GitHub Desktop.
Vast Tests Crashing Course 3
class FindingAction
belongs_to :creator
def notify_creator(updater)
FindingActionNotifier.send_creator_notification(self) if should_notify_creator?(updater)
end
private
def should_notify_creator?(updater)
updater != creator
end
end
class RisksController
def update_from_origin
SourceTrackableUpdater.new(trackable_resource).update_from_origin
redirect_to trackable_resource
end
end
describe RisksController do
let(:risk) { create(:risk) }
#ask this
before do
allow(SourceTrackableUpdater).to receive(:update_from_origin).and_return(true)
end
describe "#update_from_origin" do
def do_update
put :update_from_origin, :id => risk.id
end
it "updates source trackable object from origin" do
expect(SourceTrackableUpdater).to receive(:update_from_origin)
do_update
end
it "redirects back to the source trackable object" do
do_update
expect(response).to redirect_to(risk.path)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment