Last active
August 29, 2015 14:17
-
-
Save maxinspace/afed5d12985932c7acb3 to your computer and use it in GitHub Desktop.
Vast Tests Crashing Course 3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
123 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class RisksController | |
def update_from_origin | |
SourceTrackableUpdater.new(trackable_resource).update_from_origin | |
redirect_to trackable_resource | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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