Skip to content

Instantly share code, notes, and snippets.

@NARKOZ NARKOZ/evaluation.rb
Created May 31, 2012

Embed
What would you like to do?
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
You can’t perform that action at this time.