Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'spec_helper'
- describe "Organization" do
- let(:organization) { Organization.create! }
- describe "#admins" do
- let!(:person) do
- Person.create!(
- :first_name => "Ted",
- :last_name => "Owens",
- :username => "tedo",
- :email => "towens2727@gmail.com",
- :password => "password123",
- :password_confirmation => "password123",
- :phone => "1234567890",
- :gender => "male",
- :net_id => "F000G4Y"
- )
- end
- subject { organization.admins }
- context "when there are no admins" do
- it "returns an empty array" do
- expect(subject).to eq []
- end
- end
- context "when there is a president" do
- let(:president) { Membership.create!(:organization => organization, :person => person, :is_president => true) }
- before do
- organization.memberships << president
- end
- it "returns the president" do
- expect(subject).to eq [president]
- end
- end
- context "when there is a captain" do
- let(:captain) { Membership.create!(:organization => organization, :person => person, :is_captain => true) }
- before do
- organization.memberships << captain
- end
- it "returns the captain" do
- expect(subject).to eq [captain]
- end
- end
- context "when there is a president and a captain" do
- let!(:other_person) do
- Person.create!(
- :first_name => "Matt",
- :last_name => "Marcus",
- :username => "mattm",
- :email => "mgm@gmail.com",
- :password => "password123",
- :password_confirmation => "password123",
- :phone => "1234567890",
- :gender => "male",
- :net_id => "DZ56715"
- )
- end
- let(:president) { Membership.create!(:organization => organization, :person => person, :is_president => true) }
- let(:captain) { Membership.create!(:organization => organization, :person => other_person, :is_captain => true) }
- before do
- organization.memberships << captain
- organization.memberships << president
- end
- it "returns the president and captain" do
- expect(subject).to match_array [president, captain]
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement