Merge pull request #11 from CactusPuppy/176894810/add_summision_text

Add submission text to event proposals
This commit is contained in:
CactusPuppy 2021-03-01 23:38:06 -08:00 committed by GitHub
commit 207046dc65
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 147 additions and 14 deletions

View file

@ -18,6 +18,7 @@
# require_registration :boolean
# start_time :datetime
# state :string default("new"), not null
# submission_text :text
# subtitle :string
# title :string not null
# week :integer

View file

@ -13,6 +13,10 @@ feature 'BaseController' do
describe 'GET #verify_user_admin' do
context 'when user is a guest' do
before(:each) do
sign_out
end
it 'redirects to sign in page' do
visit admin_conferences_path
expect(current_path).to eq new_user_session_path

View file

@ -97,6 +97,7 @@ feature Event do
fill_in 'event_title', with: 'Example Proposal'
select('Example Event Type', from: 'event[event_type_id]')
fill_in 'event_abstract', with: 'Lorem ipsum abstract'
fill_in 'event_submission_text', with: 'Lorem ipsum submission'
click_button 'Submit Proposal'
page.find('#flash')
@ -138,6 +139,9 @@ feature Event do
fill_in 'event_abstract', with: 'Lorem ipsum abstract'
expect(page).to have_text('You have used 3 words')
fill_in 'event_submission_text', with: 'Lorem ipsum submission_text'
expect(page).to have_text('Submission description')
click_link 'Do you require something special?'
fill_in 'event_description', with: 'Lorem ipsum description'

View file

@ -5,6 +5,7 @@ require 'spec_helper'
describe EventsHelper, type: :helper do
let(:conference) { create(:conference) }
let(:event) { create(:event_full, program: conference.program) }
let(:event_schedule) { create(:event_schedule) }
let(:my_vote) { 3 }
let(:max_rating) { 5 }
let(:fraction) { my_vote.to_s + '/' + max_rating.to_s }
@ -28,6 +29,27 @@ describe EventsHelper, type: :helper do
end
end
describe '#canceled_replacement_event_label' do
describe 'returns nothing' do
it "when the event isn't cancelled and is not a replacement" do
event.state = 'confirmed'
expect(canceled_replacement_event_label(event, nil, 'text-class')).to eq nil
end
it 'when the event is canceled' do
event.state = 'canceled'
expect(canceled_replacement_event_label(event, nil, 'test-class')).to eq '<span class="label label-danger test-class">CANCELED</span>'
end
it 'when the event is a replacement but is not canceled' do
event.state = 'confirmed'
allow(event_schedule).to receive(:replacement?) { true }
expect(canceled_replacement_event_label(event, event_schedule, 'tent-class')).to eq '<span class="label label-info tent-class">REPLACEMENT</span>'
end
end
end
describe '#rating_tooltip' do
let(:vote_count) { pluralize(event.voters.length, 'vote') }

View file

@ -18,6 +18,7 @@
# require_registration :boolean
# start_time :datetime
# state :string default("new"), not null
# submission_text :text
# subtitle :string
# title :string not null
# week :integer
@ -109,6 +110,35 @@ describe Event do
end
end
describe '#submission_limit' do
before :each do
event.event_type.maximum_abstract_length = 3
event.event_type.minimum_abstract_length = 2
end
context 'is invalid' do
it 'when submission text is too long' do
event.submission_text = 'four too many words'
expect(event.valid?).to eq false
expect(event.errors[:submission_text]).to eq ['cannot have more than 3 words']
end
it 'when submission text is too short' do
event.submission_text = 'word'
expect(event.valid?).to eq false
expect(event.errors[:submission_text]).to eq ['cannot have less than 2 words']
end
end
context 'is valid' do
it 'when submission text is within limts' do
event.abstract = 'the magic three'
expect(event.valid?).to eq true
expect(event.errors.size).to eq 0
end
end
end
describe '#before_end_of_conference' do
context 'is invalid' do
it 'when event is created after the conference end_date, and returns an error message' do

View file

@ -18,6 +18,7 @@
# require_registration :boolean
# start_time :datetime
# state :string default("new"), not null
# submission_text :text
# subtitle :string
# title :string not null
# week :integer