Skip to content

Instantly share code, notes, and snippets.

@NARKOZ
Created May 31, 2012 11:32
Show Gist options
  • Save NARKOZ/2842801 to your computer and use it in GitHub Desktop.
Save NARKOZ/2842801 to your computer and use it in GitHub Desktop.
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
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