Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions spec/fabricators/chapter_fabricator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,16 @@
city { Faker::Lorem.word }
email { Faker::Internet.email }
time_zone { 'London' }
end

Fabricator(:chapter_with_organiser, from: :chapter) do
after_create do |chapter|
member = Fabricate(:member)
member.add_role :organiser, chapter
end
end

Fabricator(:chapter_with_groups, from: :chapter) do
name { Fabricate.sequence(:name) }
city { Faker::Lorem.word }
email { Faker::Internet.email }
time_zone { 'London' }

after_create do |chapter|
Fabricate(:students, chapter: chapter)
Fabricate(:coaches, chapter: chapter)
Expand Down
3 changes: 3 additions & 0 deletions spec/fabricators/event_fabricator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
slug { Fabricate.sequence(:slug) }
info Faker::Lorem.sentence
chapters { [Fabricate(:chapter)] }
end

Fabricator(:event_with_sponsorship, from: :event) do
after_build do |event|
Fabricate(:sponsorship, event: event, sponsor: Fabricate(:sponsor))
end
Expand Down
4 changes: 2 additions & 2 deletions spec/fabricators/group_fabricator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@

Fabricator(:students, from: :group) do
name 'Students'
members(count: 5)
members(count: 2)
end

Fabricator(:coaches, from: :group) do
name 'Coaches'
members(count: 5)
members(count: 2)
end
4 changes: 2 additions & 2 deletions spec/features/admin/chapters_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
end

context '#editing a chapter' do
let(:chapter) { Fabricate(:chapter) }
let(:chapter) { Fabricate(:chapter_with_organiser) }

context 'organiser editing their chapter' do
before do
Expand Down Expand Up @@ -146,7 +146,7 @@
end

context 'eligible members tooltip' do
let(:chapter) { Fabricate(:chapter_with_groups) }
let(:chapter) { Fabricate(:chapter) }

before do
login_as_admin(member)
Expand Down
2 changes: 1 addition & 1 deletion spec/features/admin/event_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
RSpec.feature 'Event creation', type: :feature do
let(:member) { Fabricate(:member) }
let(:chapter) { Fabricate(:chapter_with_groups) }
let(:chapter) { Fabricate(:chapter) }

describe 'an authorised member' do
before do
Expand Down
2 changes: 1 addition & 1 deletion spec/features/admin/filtering_sponsors_list_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
end

describe 'when visiting the sponsors page' do
let!(:sponsors) { Fabricate.times(2, :sponsor_with_contacts) }
let!(:sponsors) { Fabricate.times(2, :sponsor) }

before(:each) do
visit admin_sponsors_path
Expand Down
2 changes: 1 addition & 1 deletion spec/features/admin/manage_event_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
RSpec.feature 'Managing events', type: :feature do
let(:member) { Fabricate(:member) }
let!(:chapter) { Fabricate(:chapter_with_groups) }
let!(:chapter) { Fabricate(:chapter) }
let!(:event) { Fabricate(:event, confirmation_required: true) }

before do
Expand Down
2 changes: 1 addition & 1 deletion spec/features/admin/managing_organisers_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
RSpec.feature 'Managing organisers', type: :feature do
let(:member) { Fabricate(:member) }
let(:chapter) { Fabricate(:chapter) }
let(:chapter) { Fabricate(:chapter_with_organiser) }

scenario 'non admin cannot manage organisers' do
login(member)
Expand Down
11 changes: 5 additions & 6 deletions spec/features/admin/meeting_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,20 +104,19 @@
end

scenario 'does not send the invitations to banned members' do
# With 4 total members (2 students + 2 coaches), ban 2 active, 1 expired
# Expected: 4 total - 2 active bans = 2 emails sent
chapter = Fabricate(:chapter_with_groups)
meeting = Fabricate(:meeting, chapters: [chapter])
chapter.members[1..2].each do |member|
chapter.members[0..1].each do |member|
Fabricate(:ban, member: member)
end
permanent_ban = Fabricate.build(:ban, member: chapter.members[3], permanent: true, expires_at: nil)
permanent_ban.save(validate: false)
Fabricate(:ban, member: chapter.members[4], expires_at: Time.zone.today + 2.months)
expired_ban = Fabricate.build(:ban, member: chapter.members[5], expires_at: Time.zone.today - 1.month)
expired_ban = Fabricate.build(:ban, member: chapter.members[2], expires_at: Time.zone.today - 1.month)
expired_ban.save(validate: false)

expect do
visit invite_admin_meeting_path(meeting)
end.to change { ActionMailer::Base.deliveries.count }.by(chapter.members.count - 4)
end.to change { ActionMailer::Base.deliveries.count }.by(2)
end
end
end
4 changes: 2 additions & 2 deletions spec/features/admin/sponsor_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
end

context 'Sponsors list' do
let(:sponsor) { Fabricate(:sponsor_with_contacts) }
let(:sponsor2) { Fabricate(:sponsor_with_contacts) }
let(:sponsor) { Fabricate(:sponsor) }
let(:sponsor2) { Fabricate(:sponsor) }

scenario 'can filter by chapter' do
sponsored_workshop = Fabricate(:workshop_sponsor, sponsor: sponsor).workshop
Expand Down
4 changes: 4 additions & 0 deletions spec/features/admin/workshops_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,10 @@
context 'Labels' do
it 'returns a CSV with all workshop participants that can be used to generate the labels' do
workshop = Fabricate(:workshop)
# Add an organiser to ensure ORGANISER appears in the CSV
organiser = Fabricate(:member)
organiser.add_role :organiser, workshop.chapter

visit admin_workshop_path(workshop)
click_on 'Labels'

Expand Down