Advertisement
Guest User

Untitled

a guest
Jan 19th, 2016
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.19 KB | None | 0 0
  1. require 'spec_helper'
  2.  
  3. describe "Organization" do
  4. let(:organization) { Organization.create! }
  5.  
  6. describe "#admins" do
  7. let!(:person) do
  8. Person.create!(
  9. :first_name => "Ted",
  10. :last_name => "Owens",
  11. :username => "tedo",
  12. :email => "towens2727@gmail.com",
  13. :password => "password123",
  14. :password_confirmation => "password123",
  15. :phone => "1234567890",
  16. :gender => "male",
  17. :net_id => "F000G4Y"
  18. )
  19. end
  20.  
  21. subject { organization.admins }
  22. context "when there are no admins" do
  23. it "returns an empty array" do
  24. expect(subject).to eq []
  25. end
  26. end
  27.  
  28. context "when there is a president" do
  29. let(:president) { Membership.create!(:organization => organization, :person => person, :is_president => true) }
  30.  
  31. before do
  32. organization.memberships << president
  33. end
  34.  
  35. it "returns the president" do
  36. expect(subject).to eq [president]
  37. end
  38. end
  39.  
  40. context "when there is a captain" do
  41. let(:captain) { Membership.create!(:organization => organization, :person => person, :is_captain => true) }
  42.  
  43. before do
  44. organization.memberships << captain
  45. end
  46.  
  47. it "returns the captain" do
  48. expect(subject).to eq [captain]
  49. end
  50. end
  51.  
  52. context "when there is a president and a captain" do
  53. let!(:other_person) do
  54. Person.create!(
  55. :first_name => "Matt",
  56. :last_name => "Marcus",
  57. :username => "mattm",
  58. :email => "mgm@gmail.com",
  59. :password => "password123",
  60. :password_confirmation => "password123",
  61. :phone => "1234567890",
  62. :gender => "male",
  63. :net_id => "DZ56715"
  64. )
  65. end
  66. let(:president) { Membership.create!(:organization => organization, :person => person, :is_president => true) }
  67. let(:captain) { Membership.create!(:organization => organization, :person => other_person, :is_captain => true) }
  68.  
  69. before do
  70. organization.memberships << captain
  71. organization.memberships << president
  72. end
  73.  
  74. it "returns the president and captain" do
  75. expect(subject).to match_array [president, captain]
  76. end
  77.  
  78. end
  79. end
  80. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement