Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- rspec2:
- describe 'Project User with invalid rights' do
- before(:each) do
- @project_user = Factory.create(:project_user)
- @project_user.rights << :A_BAD_RIGHT
- @project_user.save
- end
- it "show all invalid rights in an invalid rights error message" do
- @project_user.errors[:base].should =~ /\[:A_BAD_RIGHT\]/
- end
- end
- rails c test:
- ruby-1.9.2-p0 > @project_user = Factory.create(:project_user)
- => #<ProjectUser id: 1, first_name: "Joe", last_name: "User1", type: "ProjectUser", rights: [], email: "joe.user1@project.com", username: "lokimem", password: "najutaw", created_at: "2010-11-02 00:35:51", updated_at: "2010-11-02 00:35:51">
- ruby-1.9.2-p0 > @project_user.rights << :A_BAD_RIGHT
- => [:A_BAD_RIGHT]
- ruby-1.9.2-p0 > @project_user.save
- => false
- ruby-1.9.2-p0 > @project_user.errors[:base]
- => ["[:A_BAD_RIGHT] is an invalid set of rights for this user"]
Add Comment
Please, Sign In to add comment