Skip to content

Commit

Permalink
Merge pull request #533 from amatsuda/TOPLEVEL_include
Browse files Browse the repository at this point in the history
Don't include anything on TOPLEVEL
  • Loading branch information
amatsuda authored Mar 9, 2025
2 parents 32b0cd8 + f8f3448 commit 6557c73
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 36 deletions.
20 changes: 9 additions & 11 deletions spec/decorators/proposal_decorator_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
require 'rails_helper'

include Proposal::State

describe ProposalDecorator do
describe "#speaker_names" do
it "returns speaker names as a comma separated string" do
Expand All @@ -27,19 +25,19 @@

describe "#state" do
it "returns 'not accepted' for a rejected state" do
proposal = create(:proposal_with_track, state: REJECTED)
expect(proposal.decorate.state).to eq(NOT_ACCEPTED)
proposal = create(:proposal_with_track, state: ProposalDecorator::REJECTED)
expect(proposal.decorate.state).to eq(ProposalDecorator::NOT_ACCEPTED)
end

it "returns the current state for non-rejected states" do
states = [
ACCEPTED,
WAITLISTED,
WITHDRAWN,
SUBMITTED,
SOFT_ACCEPTED,
SOFT_WAITLISTED,
SOFT_REJECTED
ProposalDecorator::ACCEPTED,
ProposalDecorator::WAITLISTED,
ProposalDecorator::WITHDRAWN,
ProposalDecorator::SUBMITTED,
ProposalDecorator::SOFT_ACCEPTED,
ProposalDecorator::SOFT_WAITLISTED,
ProposalDecorator::SOFT_REJECTED
]

states.each do |state|
Expand Down
44 changes: 20 additions & 24 deletions spec/models/proposal_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
require 'rails_helper'

include Proposal::State

describe Proposal do
describe "scope :unrated" do
it "returns all unrated proposals" do
Expand Down Expand Up @@ -48,10 +46,10 @@
describe "state methods" do
let(:state_method_map) do
{
SUBMITTED => :draft?,
WITHDRAWN => :withdrawn?,
ACCEPTED => :accepted?,
WAITLISTED => :waitlisted?
Proposal::SUBMITTED => :draft?,
Proposal::WITHDRAWN => :withdrawn?,
Proposal::ACCEPTED => :accepted?,
Proposal::WAITLISTED => :waitlisted?
}
end

Expand Down Expand Up @@ -140,8 +138,7 @@
describe "state changing" do
describe "#finalized?" do
it "returns false for all soft states" do
soft_states = [ SOFT_ACCEPTED, SOFT_WAITLISTED,
SOFT_REJECTED, SUBMITTED ]
soft_states = [ Proposal::SOFT_ACCEPTED, Proposal::SOFT_WAITLISTED, Proposal::SOFT_REJECTED, Proposal::SUBMITTED ]

soft_states.each do |state|
proposal = create(:proposal_with_track, state: state)
Expand All @@ -161,7 +158,7 @@

describe "#becomes_program_session?" do
it "returns true for WAITLISTED and ACCEPTED" do
states = [ ACCEPTED, WAITLISTED ]
states = [ Proposal::ACCEPTED, Proposal::WAITLISTED ]

states.each do |state|
proposal = create(:proposal_with_track, state: state)
Expand All @@ -170,7 +167,7 @@
end

it "returns false for SUBMITTED and REJECTED" do
states = [ SUBMITTED, REJECTED ]
states = [ Proposal::SUBMITTED, Proposal::REJECTED ]

states.each do |state|
proposal = create(:proposal_with_track, state: state)
Expand All @@ -189,16 +186,16 @@
end

it "changes a SUBMITTED proposal to REJECTED" do
proposal = create(:proposal_with_track, state: SUBMITTED)
proposal = create(:proposal_with_track, state: Proposal::SUBMITTED)
expect(proposal.finalize).to be_truthy
expect(proposal.reload.state).to eq(REJECTED)
expect(proposal.reload.state).to eq(Proposal::REJECTED)
end

it "creates a draft program session for WAITLISTED and ACCEPTED proposals, but not for REJECTED or SUBMITTED" do
waitlisted_proposal = create(:proposal_with_track, state: SOFT_WAITLISTED)
accepted_proposal = create(:proposal_with_track, state: SOFT_ACCEPTED)
rejected_proposal = create(:proposal_with_track, state: SOFT_REJECTED)
submitted_proposal = create(:proposal_with_track, state: SUBMITTED)
waitlisted_proposal = create(:proposal_with_track, state: Proposal::SOFT_WAITLISTED)
accepted_proposal = create(:proposal_with_track, state: Proposal::SOFT_ACCEPTED)
rejected_proposal = create(:proposal_with_track, state: Proposal::SOFT_REJECTED)
submitted_proposal = create(:proposal_with_track, state: Proposal::SUBMITTED)

Proposal.all.each do |prop|
prop.finalize
Expand All @@ -213,13 +210,13 @@

describe "#update_state" do
it "updates the state" do
proposal = create(:proposal_with_track, state: ACCEPTED)
proposal.update_state(WAITLISTED)
expect(proposal.state).to eq(WAITLISTED)
proposal = create(:proposal_with_track, state: Proposal::ACCEPTED)
proposal.update_state(Proposal::WAITLISTED)
expect(proposal.state).to eq(Proposal::WAITLISTED)
end

it "rejects invalid states" do
proposal = create(:proposal_with_track, state: ACCEPTED)
proposal = create(:proposal_with_track, state: Proposal::ACCEPTED)
proposal.update_state('almonds!')
expect(proposal.errors.messages[:state][0]).to eq("'almonds!' not a valid state.")
end
Expand Down Expand Up @@ -503,15 +500,14 @@

describe "#withdraw" do
it "sets proposal's state to withdrawn" do
proposal = create(:proposal_with_track, state: SUBMITTED)
proposal = create(:proposal_with_track, state: Proposal::SUBMITTED)
proposal.withdraw

expect(proposal.state).to eq(WITHDRAWN)
expect(proposal.state).to eq(Proposal::WITHDRAWN)
end

it "sends a notification to reviewers" do
proposal = create(:proposal_with_track, :with_reviewer_public_comment,
state: SUBMITTED)
proposal = create(:proposal_with_track, :with_reviewer_public_comment, state: Proposal::SUBMITTED)
expect {
proposal.withdraw
}.to change { Notification.count }.by(1)
Expand Down
3 changes: 2 additions & 1 deletion spec/system/website/configuration_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
require 'rails_helper'

include ActionView::Helpers::SanitizeHelper
feature "Website Configuration", type: :system do
include ActionView::Helpers::SanitizeHelper

let(:event) { create(:event) }
let(:organizer) { create(:organizer, event: event) }

Expand Down

0 comments on commit 6557c73

Please sign in to comment.