Skip to content

Commit

Permalink
Fix skipped specs by wrong factory callbacks
Browse files Browse the repository at this point in the history
teammate didn't save correctly
  • Loading branch information
unasuke authored and amatsuda committed Dec 7, 2024
1 parent 61d0639 commit 9090a76
Show file tree
Hide file tree
Showing 21 changed files with 33 additions and 76 deletions.
4 changes: 1 addition & 3 deletions spec/controllers/proposals_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,7 @@
end

it "sends an in-app notification to reviewers" do
skip("Rating not recognized as a proposal.reviewer and I haven't figured out how to make FactoryBot happy")
create(:rating, proposal: proposal, user: create(:organizer))
create(:rating, proposal: proposal, user: create(:reviewer, event: event))
expect {
post :withdraw, params: {event_slug: event.slug, uuid: proposal.uuid}
}.to change { Notification.count }.by(1)
Expand Down Expand Up @@ -157,7 +156,6 @@
end

it "sends a notifications to an organizer" do
skip("Rating not recognized as a proposal.reviewer and I haven't figured out how to make FactoryBot happy")
proposal.update(title: 'orig_title', pitch: 'orig_pitch')
organizer = create(:organizer, event: proposal.event)
create(:rating, proposal: proposal, user: organizer)
Expand Down
4 changes: 1 addition & 3 deletions spec/controllers/staff/grids/time_slots_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@

describe Staff::Grids::TimeSlotsController, type: :controller do
let(:event) { create(:event) }
let(:proposal) { create(:proposal_with_track) }
let(:proposal) { create(:proposal_with_track, event: event) }
before { sign_in(create(:organizer, event: event)) }

describe "PUT 'update'" do
it "can update a time slot with ajax" do
skip "FactoryBot 😤"
conf_time_slot = create(:time_slot, conference_day: 3, event: event)
put :update, xhr: true, params: {id: conf_time_slot, event_slug: conf_time_slot.event,
time_slot: { conference_day: 5 }}, format: :json
Expand All @@ -18,7 +17,6 @@
end

it "can set the program session" do
skip "FactoryBot 😤"
program_session = create(:program_session, event: event, proposal: proposal, track: proposal.track)
conf_time_slot = create(:time_slot, event: program_session.event)
put :update, xhr: true, params: {id: conf_time_slot, event_slug: conf_time_slot.event,
Expand Down
3 changes: 1 addition & 2 deletions spec/controllers/staff/proposals_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,7 @@
end

it "sends appropriate emails" do
skip "Record not found -- need to figure out the factory magic here"
proposal = create(:proposal_with_track, state: Proposal::State::SOFT_ACCEPTED)
proposal = create(:proposal_with_track, event: event, state: Proposal::State::SOFT_ACCEPTED)
mail = double(:mail, deliver_now: nil)
expect(Staff::ProposalMailer).to receive('send_email').and_return(mail)
post :finalize, params: {event_slug: event, proposal_uuid: proposal.uuid}
Expand Down
1 change: 0 additions & 1 deletion spec/controllers/staff/rooms_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

describe "DELETE 'destroy'" do
it "destroys the room with ajax" do
skip "FactoryBot 😤"
room = create(:room, event: event)
expect {
delete :destroy, xhr: true, params: {id: room, event_slug: event}
Expand Down
3 changes: 0 additions & 3 deletions spec/controllers/staff/time_slots_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

describe "DELETE 'destroy'" do
it "destroys the time slot" do
skip "FactoryBot 😤"
conf_time_slot = create(:time_slot, event: event)
expect {
delete :destroy, xhr: true, params: {id: conf_time_slot, event_slug: conf_time_slot.event}
Expand All @@ -16,7 +15,6 @@

describe "PUT 'update'" do
it "can update a time slot with ajax" do
skip "FactoryBot 😤"
conf_time_slot = create(:time_slot, conference_day: 3, event: event)
put :update, xhr: true, params: {id: conf_time_slot, event_slug: conf_time_slot.event,
time_slot: { conference_day: 5 }}
Expand All @@ -25,7 +23,6 @@
end

it "can set the program session" do
skip "FactoryBot 😤"
program_session = create(:program_session, event: event)
conf_time_slot = create(:time_slot, event: program_session.event)
put :update, xhr: true, params: {id: conf_time_slot, event_slug: conf_time_slot.event,
Expand Down
2 changes: 1 addition & 1 deletion spec/factories/proposals.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

trait :with_reviewer_public_comment do
after(:create) do |proposal|
reviewer = FactoryBot.create(:user, :reviewer)
reviewer = FactoryBot.create(:reviewer, event: proposal.event)
FactoryBot.create(:comment, proposal: proposal, type: "PublicComment", user: reviewer, body: "Reviewer comment" )
end
end
Expand Down
4 changes: 2 additions & 2 deletions spec/factories/users.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
after(:create) do |user, evaluator|
teammate = user.organizer_teammates.first
teammate.event = evaluator.event
teammate.event.save
teammate.save
end
end

Expand All @@ -60,7 +60,7 @@
after(:create) do |user, evaluator|
teammate = user.reviewer_teammates.first
teammate.event = evaluator.event
teammate.event.save
teammate.save
end
end

Expand Down
2 changes: 0 additions & 2 deletions spec/features/staff/sponsor_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
end

it 'can delete an event sponsor', js: true do
skip "FactoryBot 😤"
sponsor = create(:sponsor, event: event)
visit edit_event_staff_sponsor_path(event, sponsor)

Expand All @@ -60,7 +59,6 @@
end

it 'sponsons are listed in tier order on the index page' do
skip "FactoryBot 😤"
Sponsor::TIERS.each { |tier| create(:sponsor, tier: tier) }
visit event_staff_sponsors_path(event)

Expand Down
3 changes: 0 additions & 3 deletions spec/features/website/configuration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
let(:organizer) { create(:organizer, event: event) }

scenario "Organizer creates a new website for event" do
skip "FactoryBot 😤"
login_as(organizer)

visit event_path(event)
Expand All @@ -18,7 +17,6 @@
end

scenario "Organizer configures domain for an existing website for event", :js do
skip "FactoryBot 😤"
website = create(:website, event: event)
home_page = create(:page, website: website)

Expand Down Expand Up @@ -50,7 +48,6 @@
end

scenario "Organizer fails to add font file correctly", :js do
skip "FactoryBot 😤"
website = create(:website, event: event)

login_as(organizer)
Expand Down
14 changes: 5 additions & 9 deletions spec/features/website/program_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,15 @@
let!(:website) { create(:website, event: event) }

scenario "A program session is on the program session page", js: true do
skip "FactoryBot 😤"
regular_session = create(:regular_session)
regular_session = create(:regular_session, event: event)

visit program_path(event)
expect(page).to have_content(regular_session.title)
end

scenario "the website program page displays sessions under the correct session format", js: true do
skip "FactoryBot 😤"
regular_session = create(:regular_session)
workshop = create(:workshop_session)
regular_session = create(:regular_session, event: event)
workshop = create(:workshop_session, event: event)
visit program_path(event)

expect(page).to have_content(regular_session.title)
Expand All @@ -27,9 +25,8 @@
end

scenario "the event website program page reflects updates to program sessions", js: true do
skip "FactoryBot 😤"
login_as(organizer)
regular_session = create(:regular_session)
regular_session = create(:regular_session, event: event)

visit program_path(event)
expect(page).to have_content(regular_session.title)
Expand All @@ -44,9 +41,8 @@
end

scenario "the event website page stops displaying deleted program sessions", js: true do
skip "FactoryBot 😤"
login_as(organizer)
regular_session = create(:regular_session)
regular_session = create(:regular_session, event: event)

visit program_path(event)
expect(page).to have_content(regular_session.title)
Expand Down
2 changes: 0 additions & 2 deletions spec/features/website/schedule_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,13 @@
end

scenario "the event website schedule page displays time slots that have program sessions", js: true do
skip "FactoryBot 😤"
time_slot = create(:with_workshop_session, event: event)

visit schedule_path(event)
expect(page).to have_content(time_slot.title)
end

scenario "the event website schedule page displays updates to time slots that have program sessions", js: true do
skip "FactoryBot 😤"
time_slot = create(:with_workshop_session, event: event)

time_slot.update(start_time: (time_slot.start_time - 1.hour))
Expand Down
5 changes: 1 addition & 4 deletions spec/mailers/comment_notification_mailer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

describe "reviewer_notification" do
let(:proposal) { create(:proposal, :with_reviewer_public_comment) }
let(:reviewer) { create(:user, :reviewer) }
let(:reviewer) { create(:reviewer, event: proposal.event) }
let(:comment) { create(:comment, proposal: proposal, type: "PublicComment", user: reviewer, body: "Reviewer comment as a Reviewer on Proposal") }
let(:speaker) { create(:speaker) }
let(:speaker_comment) { create(:comment, user: speaker.user, proposal: proposal) }
Expand All @@ -48,19 +48,16 @@
end

it "emails reviewers when speaker comments" do
skip "FactoryBot 😤"
expect(proposal.reviewers.count).to eq(2)
expect(mail.to.count).to eq(2)
expect(mail.to).to match_array([proposal.reviewers.first.email, reviewer.email])
end

it "has proper subject" do
skip "FactoryBot 😤"
expect(mail.subject).to eq("#{proposal.event.name} CFP: New comment on '#{proposal.title}'")
end

it "has proper body content" do
skip "FactoryBot 😤"
expect(mail.body.encoded).to match(proposal.event.name)
expect(mail.body.encoded).to match(proposal.title)
expect(mail.body.encoded).to match("A comment has been left on the proposal '#{proposal.title}' for #{proposal.event.name}:")
Expand Down
21 changes: 7 additions & 14 deletions spec/models/proposal_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -334,12 +334,11 @@

describe "#update" do
let(:proposal) { create(:proposal_with_track, title: 't') }
let(:organizer) { create(:user, :organizer) }
let(:organizer) { create(:organizer, event: proposal.event) }

describe ".last_change" do
describe "when role organizer" do
it "is cleared" do
skip "FactoryBot 😤"
proposal.update(title: 'Organizer Edited Title', updating_user: organizer)
expect(proposal.last_change).to be_nil
end
Expand Down Expand Up @@ -410,11 +409,10 @@

describe "#reviewers" do
let!(:proposal) { create(:proposal_with_track) }
let!(:reviewer) { create(:user, :reviewer) }
let!(:reviewer) { create(:reviewer, event: proposal.event) }
let!(:organizer) { create(:organizer, event: proposal.event) }

it "can return the list of reviewers" do
skip "FactoryBot 😤"
create(:rating, user: reviewer, proposal: proposal)
proposal.public_comments.create(attributes_for(:comment, user: organizer))

Expand All @@ -426,7 +424,6 @@
end

it "does not list a reviewer more than once" do
skip "FactoryBot 😤"
create(:rating, user: reviewer, proposal: proposal)
proposal.public_comments.create(attributes_for(:comment, user: reviewer))

Expand All @@ -437,34 +434,32 @@
describe 'emailable_reviewers' do
let!(:proposal) { create(:proposal_with_track) }
let!(:no_email_reviewer) do
reviewer = create(:user, :reviewer)
reviewer = create(:reviewer, event: proposal.event)
reviewer.teammates.first.update_attribute(:notification_preference, Teammate::IN_APP_ONLY)
create(:rating, user: reviewer, proposal: proposal)
reviewer
end
let!(:mentions_only_reviewer) do
reviewer = create(:user, :reviewer)
reviewer = create(:reviewer, event: proposal.event)
reviewer.teammates.first.update_attribute(:notification_preference, Teammate::MENTIONS)
create(:rating, user: reviewer, proposal: proposal)
reviewer
end
let!(:reviewer) do
reviewer = create(:user, :reviewer)
reviewer = create(:reviewer, event: proposal.event)
create(:rating, user: reviewer, proposal: proposal)
reviewer
end

it 'returns only reviewers with all emails turned on' do
skip "FactoryBot 😤"
expect(proposal.emailable_reviewers).to match_array([ reviewer ])
end
end

describe "#speaker_update_and_notify" do
it "sends notification to all reviewers" do
skip "FactoryBot 😤"
proposal = create(:proposal_with_track, title: 'orig_title', pitch: 'orig_pitch')
reviewer = create(:user, :reviewer)
reviewer = create(:reviewer, event: proposal.event)
organizer = create(:organizer, event: proposal.event)

create(:rating, user: reviewer, proposal: proposal)
Expand All @@ -481,9 +476,8 @@
end

it "uses the old title in the notification message" do
skip "FactoryBot 😤"
proposal = create(:proposal_with_track, title: 'orig_title')
reviewer = create(:user, :reviewer)
reviewer = create(:reviewer, event: proposal.event)
create(:rating, user: reviewer, proposal: proposal)

proposal.speaker_update_and_notify(title: 'new_title')
Expand Down Expand Up @@ -516,7 +510,6 @@
end

it "sends a notification to reviewers" do
skip "FactoryBot 😤"
proposal = create(:proposal_with_track, :with_reviewer_public_comment,
state: SUBMITTED)
expect {
Expand Down
8 changes: 1 addition & 7 deletions spec/models/public_comment_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
let(:proposal) { create(:proposal_with_track, :with_organizer_public_comment, :with_speaker) }
let(:organizer) { Teammate.for_event(proposal.event).organizer.first.user }
it "creates a notification" do
skip "FactoryBot 😤"
expect {
proposal.public_comments.create(attributes_for(:comment, user: speaker))
}.to change {
Expand All @@ -18,7 +17,6 @@
end

it "does not show the name of the speaker" do
skip "FactoryBot 😤"
proposal.public_comments.create(attributes_for(:comment, user: speaker))
expect(organizer.reload.notifications.last.message).to_not match(speaker.name)
end
Expand All @@ -29,7 +27,6 @@
let(:reviewer) { Teammate.for_event(proposal.event).reviewer.first.user }

it "creates a notification" do
skip "FactoryBot 😤"
expect {
proposal.public_comments.create(attributes_for(:comment, user: speaker))
}.to change {
Expand All @@ -38,7 +35,6 @@
end

it "does not show the name of the speaker" do
skip "FactoryBot 😤"
proposal.public_comments.create(attributes_for(:comment, user: speaker))
expect(reviewer.reload.notifications.last.message).to_not match(speaker.name)
end
Expand Down Expand Up @@ -89,7 +85,6 @@

describe "for organizers who have rated the proposal" do
it "creates a notification" do
skip "FactoryBot 😤"
proposal = create(:proposal_with_track, :with_speaker)
organizer = create(:organizer, event: proposal.event)
create(:rating, proposal: proposal, user: organizer)
Expand Down Expand Up @@ -134,7 +129,7 @@
describe "#send_emails" do
let!(:proposal) { create(:proposal_with_track) }
let!(:speakers) { create_list(:speaker, 3, proposal: proposal) }
let!(:reviewer) { create(:user, :reviewer) }
let!(:reviewer) { create(:reviewer, event: proposal.event) }
context "when reviewer creates a PublicComment" do
it "should send notication to each speaker" do
expect {
Expand All @@ -148,7 +143,6 @@
context 'Speaker create a PublicComment' do
before { proposal.public_comments.create(attributes_for(:comment, user: reviewer)) }
it 'should send notification to reviewer if speaker comments' do
skip "FactoryBot 😤"
expect {
proposal.public_comments.create(attributes_for(:comment, user: speakers.first.user))
}.to change(ActionMailer::Base.deliveries, :count).by(1)
Expand Down
Loading

0 comments on commit 9090a76

Please sign in to comment.