Sha256: 60c3b5739e8e4d52a0a04d1c5f448d4c3ab7c1860f6272dec2b253bf96c81a7d

Contents?: true

Size: 1.32 KB

Versions: 1

Compression:

Stored size: 1.32 KB

Contents

require File.dirname(__FILE__) + '/../spec_helper'

describe Share do

  before do
    @user = Factory(:user)
    @friend = Factory(:user)
    @share = @user.shares.build(Factory.attributes_for(:share))
    @share.save!
  end
  
  it { should validate_presence_of :uri }
  
  it { should belong_to :shared_by }
  it { should have_many :comments }
  
  it { should scope_by_newest }
  it { should scope_by_oldest }
  it { should scope_recent }
  
  it "should require uri" do
    lambda{
      u = Factory.build(:share, :uri => nil)
      u.should_not be_valid
      u.errors[:uri].should_not be_empty
    }.should_not change(Share, :count)
  end
  
  it "should add an activity" do
    lambda{
      @share.add_share_activity(@user)
    }.should change(Activity, :count).by(1)
  end
  
  it "should add an activity without specifying share_to" do
    lambda{
      @share.add_share_activity
    }.should change(Activity, :count).by(1)
  end
  
  it "should add an activity for self and friend" do
    activity = @share.add_share_activity([@user, @friend])
    @user.reload
    @friend.reload      
    @user.activities.should include(activity)
    @friend.activities.should include(activity)
  end
  
  describe "user that created share" do
    it "should be able to edit the share" do
      @share.can_edit?(@user).should be_true
    end
  end
  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
muck-shares-3.0.0 test/rails_test/spec/models/share_spec.rb