Sha256: d4b0d175d9bf70c07e7d182d4cc4ee5b723cf29bc33b9dcec1e99f5b0a2509ef

Contents?: true

Size: 1.01 KB

Versions: 4

Compression:

Stored size: 1.01 KB

Contents

require 'spec_helper'

describe OpenConferenceWare::UserFavorite do
  fixtures :all

  before(:each) do
    @user = users(:quentin)
    @proposal = proposals(:clio_chupacabras)
  end

  def add_favorite
    return UserFavorite.add(@user.id, @proposal.id)
  end

  def remove_favorite
    return UserFavorite.remove(@user.id, @proposal.id)
  end

  it "should add and create new record" do
    proc { add_favorite  }.should change(UserFavorite, :count).by(1)
  end

  it "should add and accept existing record" do
    add_favorite
    proc { add_favorite }.should_not change(UserFavorite, :count)
  end

  it "should remove and destroy existing record" do
    add_favorite
    proc { remove_favorite }.should change(UserFavorite, :count).by(-1)
  end

  it "should remove and do nothing if no existing record" do
    proc { remove_favorite }.should_not change(UserFavorite, :count)
  end

  it "should return ids of user's favorite proposals" do
    add_favorite
    UserFavorite.proposal_ids_for(@user).should == [@proposal.id]
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
open_conference_ware-1.0.0.pre4 spec/models/open_conference_ware/user_favorite_spec.rb
open_conference_ware-1.0.0.pre3 spec/models/open_conference_ware/user_favorite_spec.rb
open_conference_ware-1.0.0.pre2 spec/models/open_conference_ware/user_favorite_spec.rb
open_conference_ware-1.0.0.pre1 spec/models/open_conference_ware/user_favorite_spec.rb