Skip to content

Commit

Permalink
Added tests participants view for an event
Browse files Browse the repository at this point in the history
  • Loading branch information
nikhilgupta1211 committed Jul 26, 2017
1 parent d18351c commit 0e6ed8f
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/models/event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class Event < ActiveRecord::Base
has_many :users, -> { distinct }, through: :requests do
# Users with travel requests
def travel
where(requests: { type: 'TravelSponsorship' } )
where(requests: { type: 'TravelSponsorship' })
end
end

Expand Down
6 changes: 3 additions & 3 deletions spec/features/event_email.spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,17 @@

page.check('Submitted')
page.check('Incomplete')
page.should have_field('To', with: 'gial.ackbar@rebel-alliance.org,luke.skywalker@rebel-alliance.org,evram.lajaie@rebel-alliance.org,c3po@droids.com,wedge.antilles@rebel-alliance.org')
page.should have_field('To', with: 'gial.ackbar@rebel-alliance.org,luke.skywalker@rebel-alliance.org,evram.lajaie@rebel-alliance.org,john.skywalker@rebel-alliance.org,c3po@droids.com,wedge.antilles@rebel-alliance.org')

page.check('All')
page.should have_field('To', with: 'gial.ackbar@rebel-alliance.org,luke.skywalker@rebel-alliance.org,wedge.antilles@rebel-alliance.org,evram.lajaie@rebel-alliance.org,c3po@droids.com')
page.should have_field('To', with: 'gial.ackbar@rebel-alliance.org,luke.skywalker@rebel-alliance.org,wedge.antilles@rebel-alliance.org,evram.lajaie@rebel-alliance.org,john.skywalker@rebel-alliance.org,c3po@droids.com')

fill_in 'Subject', with: "Death Star's destruction celebration"
fill_in 'Body', with: "Event Death Star's destruction celebration to be conducted soon. Be ready."

page.find('.btn-primary').trigger('click')
page.should have_content 'Email Delivered'
ActionMailer::Base.deliveries.size.should == @deliveries + 5
ActionMailer::Base.deliveries.size.should == @deliveries + 6
end

scenario 'Sending mail without a body and a subject', js: true do
Expand Down
15 changes: 15 additions & 0 deletions spec/features/events_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,15 @@
scenario 'When a user is not logged in' do
visit events_path
click_link "Death Star's destruction celebration"
page.should_not have_link('Participants')
page.should_not have_link('Email')
end

scenario 'User logged in is not a tsp member' do
sign_in_as_user(users(:luke))
visit events_path
click_link "Death Star's destruction celebration"
page.should_not have_link('Participants')
page.should_not have_link('Email')
end

Expand All @@ -72,8 +74,21 @@

click_link "Death Star's destruction celebration"
page.should have_link('Email')
page.should have_link('Participants')

click_link 'Email'
page.should have_content "Emails for Death Star's destruction celebration"

visit event_path(events(:party))
click_link 'Participants'
page.should have_content "Participants of Death Star's destruction celebration"
page.all('.table tr').count.should == 7

page.should_not have_content 'john.skywalker@rebel-alliance.org' # User with a shipment request

within(:xpath, "(//table[contains(@class, 'table')]//tr)[2]") do
page.should have_content 'acalamari'
page.should have_content 'gial.ackbar@rebel-alliance.org'
end
end
end
7 changes: 7 additions & 0 deletions spec/fixtures/requests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -151,3 +151,10 @@ tspmember_customes_for_party:
event: party
created_at: <%= 4.days.ago.to_s(:db) %>
type: "Shipment"

john_customes_for_party:
state: "incomplete"
user: john
event: party
created_at: <%= 4.days.ago.to_s(:db) %>
type: "Shipment"
4 changes: 4 additions & 0 deletions spec/fixtures/users.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,8 @@ shipper:
josh:
email: "josh.skywalker@rebel-alliance.org"
nickname: "josh27"
encrypted_password: "$2a$10$9avVKOmjbCWh0m5p/frG7uX3S0LbF8ZtRS/QocBkmXiiDbh9.bKsq"
john:
email: "john.skywalker@rebel-alliance.org"
nickname: "johnsnow"
encrypted_password: "$2a$10$9avVKOmjbCWh0m5p/frG7uX3S0LbF8ZtRS/QocBkmXiiDbh9.bKsq"

0 comments on commit 0e6ed8f

Please sign in to comment.