Sha256: 6512aebd14b939092f495c33a728ac527e1e337a24a79b7584804081009dfb9a

Contents?: true

Size: 984 Bytes

Versions: 3

Compression:

Stored size: 984 Bytes

Contents

require 'spec_helper'

describe ReputationBehaviour do
  
  before(:each) { 
    @rule = ReputationRule.create!(:name => "foo") 
    @user = User.create!(:name => "bob")
    ReputationBehaviour.create!(:user => @user, :rule => @rule, :metric => 0)
  }

  it { should belong_to :user }
  it { should belong_to :rule }
    
  it { should validate_presence_of :user }
  it { should validate_presence_of :rule }
  it { should validate_numericality_of :metric }

  it { should validate_uniqueness_of( :user_id ).scoped_to(:rule_id) }

  it { should allow_mass_assignment_of :user }
  it { should allow_mass_assignment_of :metric }
  
  it "should allow the rule to be set via a name" do
    ReputationBehaviour.create!(:user => User.create!, :rule => @rule.name, :metric => 0).rule.should eql @rule
  end
  
  it "should allow the rule to be set using a Rule object" do
    ReputationBehaviour.create!(:user => User.create!, :rule => @rule, :metric => 0).rule.should eql @rule
  end
  
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
reputation-0.0.4 spec/models/behaviour_spec.rb
reputation-0.0.3 spec/models/behaviour_spec.rb
reputation-0.0.2 spec/models/behaviour_spec.rb