Created
April 4, 2014 09:26
-
-
Save donbonifacio/9971146 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 Updater | |
def self.update_total_points(employee) | |
employee.total_points = employee.rocket_actions.sum(:points) | |
gateway.persist_employee_total(employee) | |
end | |
def gateway | |
if defined? Rails | |
rails gateway | |
else | |
mem gateway | |
end | |
end | |
end | |
AR | |
Updater.update_total_points(Employee.find(1)) | |
expect(employee.total_points).to eql(123) | |
Mem | |
employee = OpenStruct.new({ | |
:total_points => 0, | |
:rocket_actions => [ | |
OpenStruct.new({ :points => 123 }) | |
] | |
}) | |
Updater.update_total_points(employee) | |
expect(employee.total_points).to eql(123) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment