Created
May 31, 2012 11:32
-
-
Save NARKOZ/2842801 to your computer and use it in GitHub Desktop.
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
def evaluation_value(reputation_name, source, *args) | |
scope = args.first | |
srn = ReputationSystem::Network.get_scoped_reputation_name(self.class.name, reputation_name, scope) | |
evaluation = RSEvaluation.find_by_reputation_name_and_source_and_target(srn, source, self) | |
evaluation.present? ? evaluation.value : 0 | |
end | |
def has_evaluation?(reputation_name, source, *args) | |
scope = args.first | |
srn = ReputationSystem::Network.get_scoped_reputation_name(self.class.name, reputation_name, scope) | |
evaluation = RSEvaluation.find_by_reputation_name_and_source_and_target(srn, source, self) | |
evaluation.present? | |
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 "#evaluation_value" do | |
it "should return evaluation value" do | |
@question.add_evaluation(:total_votes, 1, @user) | |
@question.evaluation_value(:total_votes, @user).should == 1 | |
end | |
end | |
describe "#has_evaluation?" do | |
it "should return evaluation state" do | |
@question.add_evaluation(:total_votes, 1, @user) | |
@question.has_evaluation?(:total_votes, @user).should be_true | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment