Skip to content

Instantly share code, notes, and snippets.

@elomar
Created May 21, 2009 02:40
Show Gist options
  • Select an option

  • Save elomar/115233 to your computer and use it in GitHub Desktop.

Select an option

Save elomar/115233 to your computer and use it in GitHub Desktop.
require File.dirname(__FILE__) + '/../spec_helper'
describe Event do
it { should belong_to(:organizer, :class_name => "User") }
it { should have_many(:registrations) }
it { should have_many(:users, :through => :registrations) }
it { should have_many(:promocodes)}
it { should validate_presence_of(:title, :location, :description, :start_at, :finish_at)}
it { should validate_numericality_of(:price, :allow_nil => true)}
describe 'confirmed users' do
it 'should return confirmed users' do
event = Event.make(:free)
user = User.make
Registration.make(:event => event, :user => user)
event.confirmed_users.should == [user]
end
it 'should not return pending users' do
event = Event.make(:paid)
Registration.make(:event => event, :user => User.make)
event.confirmed_users.should == []
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment