Guest User

Untitled

a guest
Jun 20th, 2018
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. rspec2:
  2.  
  3. describe 'Project User with invalid rights' do
  4. before(:each) do
  5. @project_user = Factory.create(:project_user)
  6. @project_user.rights << :A_BAD_RIGHT
  7. @project_user.save
  8. end
  9.  
  10. it "show all invalid rights in an invalid rights error message" do
  11. @project_user.errors[:base].should =~ /\[:A_BAD_RIGHT\]/
  12. end
  13. end
  14.  
  15. rails c test:
  16.  
  17. ruby-1.9.2-p0 > @project_user = Factory.create(:project_user)
  18. => #<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">
  19.  
  20. ruby-1.9.2-p0 > @project_user.rights << :A_BAD_RIGHT
  21. => [:A_BAD_RIGHT]
  22.  
  23. ruby-1.9.2-p0 > @project_user.save
  24. => false
  25.  
  26. ruby-1.9.2-p0 > @project_user.errors[:base]
  27. => ["[:A_BAD_RIGHT] is an invalid set of rights for this user"]
Add Comment
Please, Sign In to add comment