From 46fa17b55c6c755fcb21b0fb3f38e5b3550cc745 Mon Sep 17 00:00:00 2001 From: madhekare Date: Tue, 16 Feb 2021 13:44:15 -0800 Subject: [PATCH 01/15] submission_text field migration --- db/migrate/20210215213515_add_submission_text_to_events.rb | 5 +++++ db/schema.rb | 6 ++---- 2 files changed, 7 insertions(+), 4 deletions(-) create mode 100644 db/migrate/20210215213515_add_submission_text_to_events.rb diff --git a/db/migrate/20210215213515_add_submission_text_to_events.rb b/db/migrate/20210215213515_add_submission_text_to_events.rb new file mode 100644 index 00000000..90270eb3 --- /dev/null +++ b/db/migrate/20210215213515_add_submission_text_to_events.rb @@ -0,0 +1,5 @@ +class AddSubmissionTextToEvents < ActiveRecord::Migration[5.2] + def change + add_column :events, :submission_text, :text + end +end diff --git a/db/schema.rb b/db/schema.rb index e8ac08e8..dee892f6 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,10 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2020_07_16_181602) do - - # These are extensions that must be enabled in order to support this database - enable_extension "plpgsql" +ActiveRecord::Schema.define(version: 2021_02_15_213515) do create_table "answers", force: :cascade do |t| t.string "title" @@ -257,6 +254,7 @@ ActiveRecord::Schema.define(version: 2020_07_16_181602) do t.integer "program_id" t.integer "max_attendees" t.integer "comments_count", default: 0, null: false + t.text "submission_text" end create_table "events_registrations", force: :cascade do |t| From baf488ad8adcd50199d3ab329fa120fe6b0082f4 Mon Sep 17 00:00:00 2001 From: madhekare Date: Tue, 16 Feb 2021 13:45:38 -0800 Subject: [PATCH 02/15] sumbission text views --- app/views/admin/events/_proposal.html.haml | 4 ++++ app/views/proposals/_proposal_form.html.haml | 14 ++++++++++++++ app/views/proposals/new.html.haml | 16 ++++++++++++++++ 3 files changed, 34 insertions(+) diff --git a/app/views/admin/events/_proposal.html.haml b/app/views/admin/events/_proposal.html.haml index 722387ac..3442bc80 100644 --- a/app/views/admin/events/_proposal.html.haml +++ b/app/views/admin/events/_proposal.html.haml @@ -111,6 +111,10 @@ %td %b Abstract %td= markdown(@event.abstract) + %tr + %td + %b Submission Description + %td= markdown(@event.submission_text) %tr %td %b Requirements diff --git a/app/views/proposals/_proposal_form.html.haml b/app/views/proposals/_proposal_form.html.haml index f385bdeb..e175df54 100644 --- a/app/views/proposals/_proposal_form.html.haml +++ b/app/views/proposals/_proposal_form.html.haml @@ -46,6 +46,20 @@ 250 words. + = f.input :submission_text, input_html: { rows: 5, data: { provide: 'markdown' } }, + hint: markdown_hint('[Tips to improve your presentations.](http://blog.hubspot.com/blog/tabid/6307/bid/5975/10-Rules-to-Instantly-Improve-Your-Presentations.aspx)') + + %p + You have used + %span#abstract-count #{@event.submission_word_count} + words. Submission descriptions must be between + %span#abstract-minimum-word-count + 0 + and + %span#abstract-maximum-word-count + 250 + words. + - if current_user.is_admin? or @program.cfp.enable_registrations? = f.inputs 'Enable pre-registration' do = f.input :require_registration, label: 'Require participants to register to your event' diff --git a/app/views/proposals/new.html.haml b/app/views/proposals/new.html.haml index b7fc22f5..eed58560 100644 --- a/app/views/proposals/new.html.haml +++ b/app/views/proposals/new.html.haml @@ -61,6 +61,22 @@ 250 words. + = f.input :submission_text, input_html: { rows: 5, data: { provide: 'markdown' } }, + hint: markdown_hint + + %p + You have used + %span#abstract-count #{@event.submission_word_count} + words. Submission descriptions must be between + %span#abstract-minimum-word-count + 0 + and + %span#abstract-maximum-word-count + 250 + words. + + + - if @program.cfp.enable_registrations? = f.input :require_registration, label: 'Require participants to register to your event' From b8f531783b2907073861e6b69b388c9ae8ae3f57 Mon Sep 17 00:00:00 2001 From: madhekare Date: Tue, 16 Feb 2021 13:46:54 -0800 Subject: [PATCH 03/15] submission text control/model modifications --- app/controllers/admin/events_controller.rb | 2 +- app/controllers/proposals_controller.rb | 2 +- app/models/event.rb | 17 +++++++++++++++++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/app/controllers/admin/events_controller.rb b/app/controllers/admin/events_controller.rb index b24882f3..f5e68165 100644 --- a/app/controllers/admin/events_controller.rb +++ b/app/controllers/admin/events_controller.rb @@ -175,7 +175,7 @@ module Admin def event_params params.require(:event).permit( # Set also in proposals controller - :title, :subtitle, :event_type_id, :abstract, :description, :require_registration, :difficulty_level_id, + :title, :subtitle, :event_type_id, :abstract, :submission_text, :description, :require_registration, :difficulty_level_id, # Set only in admin/events controller :track_id, :state, :language, :is_highlight, :max_attendees, # Not used anymore? diff --git a/app/controllers/proposals_controller.rb b/app/controllers/proposals_controller.rb index adfdbea0..bf1b3adc 100644 --- a/app/controllers/proposals_controller.rb +++ b/app/controllers/proposals_controller.rb @@ -170,7 +170,7 @@ class ProposalsController < ApplicationController def event_params params.require(:event).permit(:event_type_id, :track_id, :difficulty_level_id, - :title, :subtitle, :abstract, :description, + :title, :subtitle, :abstract, :submission_text, :description, :require_registration, :max_attendees, :language, speaker_ids: [], volunteer_ids: [] ) diff --git a/app/models/event.rb b/app/models/event.rb index 0370926b..dd86efec 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -73,6 +73,7 @@ class Event < ApplicationRecord before_create :generate_guid validate :abstract_limit + validate :submission_limit validate :before_end_of_conference, on: :create validates :title, presence: true validates :abstract, presence: true @@ -217,6 +218,10 @@ class Event < ApplicationRecord abstract.to_s.split.size end + def submission_word_count + submission_text.to_s.split.size + end + def self.get_state_color(state) COLORS[state.to_sym] || '#00FFFF' # azure end @@ -353,6 +358,18 @@ class Event < ApplicationRecord errors.add(:abstract, "cannot have more than #{max_words} words") if len > max_words end + def submission_limit + # If we don't have an event type, there is no need to count anything + return unless event_type && submission_text + + len = submission_text.split.size + max_words = event_type.maximum_abstract_length + min_words = event_type.minimum_abstract_length + + errors.add(:submission_text, "cannot have less than #{min_words} words") if len < min_words + errors.add(:submission_text, "cannot have more than #{max_words} words") if len > max_words + end + # TODO: create a module to be mixed into model to perform same operation # venue.rb has same functionality which can be shared # TODO: rename guid to UUID as guid is specifically Microsoft term From 16d9dfef4c61599c35df713c6dfa749ed58659fd Mon Sep 17 00:00:00 2001 From: madhekare Date: Wed, 17 Feb 2021 17:27:41 -0800 Subject: [PATCH 04/15] submission_text rspec --- spec/features/proposals_spec.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/spec/features/proposals_spec.rb b/spec/features/proposals_spec.rb index 4d25e9ce..7df6b7d7 100644 --- a/spec/features/proposals_spec.rb +++ b/spec/features/proposals_spec.rb @@ -82,6 +82,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') @@ -123,6 +124,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' From d46e1e73978458f8ec9ae94e0412c7c58a5e7480 Mon Sep 17 00:00:00 2001 From: CactusPuppy Date: Thu, 18 Feb 2021 23:27:20 -0800 Subject: [PATCH 05/15] Add JavaScript to make placeholder text update along with word count --- app/assets/javascripts/osem.js | 15 ++++++++++++++- app/views/proposals/_proposal_form.html.haml | 14 ++++++++------ app/views/proposals/new.html.haml | 6 +++--- 3 files changed, 25 insertions(+), 10 deletions(-) diff --git a/app/assets/javascripts/osem.js b/app/assets/javascripts/osem.js index dcab692c..0839f13b 100644 --- a/app/assets/javascripts/osem.js +++ b/app/assets/javascripts/osem.js @@ -149,15 +149,21 @@ function word_count(text, divId, maxcount) { /* Wait for the DOM to be ready before attaching events to the elements */ $( document ).ready(function() { - /* Set the minimum and maximum proposal abstract word length */ + /* Set the minimum and maximum proposal abstract and submission text word length */ $("#event_event_type_id").change(function () { var $selected = $("#event_event_type_id option:selected") var max = $selected.data("max-words"); var min = $selected.data("min-words"); $("#abstract-maximum-word-count").text(max); + $("#submission-maximum-word-count").text(max); $("#abstract-minimum-word-count").text(min); + $("#submission-minimum-word-count").text(min); word_count($('#event_abstract').get(0), 'abstract-count', max); + word_count($('#event_submission_text').get(0), 'submission-count', max); + + // Set the placeholder text for the abstract + $('#event_submission_text').attr("placeholder", $selected.data("help")); }) .trigger('change'); @@ -167,6 +173,13 @@ $( document ).ready(function() { var max = $selected.data("max-words"); word_count(this, 'abstract-count', max); } ); + + /* Count the submission text length */ + $("#event_submission_text").bind('change keyup paste input', function() { + var $selected = $("event_event_type_id option:selected") + var max = $selected.data("max-words"); + word_count(this, 'submission-count', max); + }); }); /* Commodity function for modal windows */ diff --git a/app/views/proposals/_proposal_form.html.haml b/app/views/proposals/_proposal_form.html.haml index e175df54..5b4e7079 100644 --- a/app/views/proposals/_proposal_form.html.haml +++ b/app/views/proposals/_proposal_form.html.haml @@ -13,7 +13,7 @@ = f.input :event_type_id, as: :select, collection: @conference.program.event_types.map {|type| ["#{type.title} - #{show_time(type.length)}", type.id, - data: { min_words: type.minimum_abstract_length, max_words: type.maximum_abstract_length }]}, + data: { min_words: type.minimum_abstract_length, max_words: type.maximum_abstract_length, help: type.description }]}, include_blank: false, label: 'Type', input_html: { class: 'select-help-toggle' } - if @program.languages.present? @@ -46,17 +46,19 @@ 250 words. - = f.input :submission_text, input_html: { rows: 5, data: { provide: 'markdown' } }, - hint: markdown_hint('[Tips to improve your presentations.](http://blog.hubspot.com/blog/tabid/6307/bid/5975/10-Rules-to-Instantly-Improve-Your-Presentations.aspx)') + %br + + = f.input :submission_text, input_html: { rows: 5, data: { provide: 'markdown' }, placeholder: '' }, + hint: markdown_hint('Only conference organizers will read this.') %p You have used - %span#abstract-count #{@event.submission_word_count} + %span#submission-count #{@event.submission_word_count} words. Submission descriptions must be between - %span#abstract-minimum-word-count + %span#submission-minimum-word-count 0 and - %span#abstract-maximum-word-count + %span#submission-maximum-word-count 250 words. diff --git a/app/views/proposals/new.html.haml b/app/views/proposals/new.html.haml index eed58560..bdd16e11 100644 --- a/app/views/proposals/new.html.haml +++ b/app/views/proposals/new.html.haml @@ -66,12 +66,12 @@ %p You have used - %span#abstract-count #{@event.submission_word_count} + %span#submission-count #{@event.submission_word_count} words. Submission descriptions must be between - %span#abstract-minimum-word-count + %span#submission-minimum-word-count 0 and - %span#abstract-maximum-word-count + %span#submission-maximum-word-count 250 words. From 42d43319c56225971e7d4daba3155f8a2c45062e Mon Sep 17 00:00:00 2001 From: CactusPuppy Date: Thu, 25 Feb 2021 20:12:20 -0800 Subject: [PATCH 06/15] fix indentation error --- app/models/event.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/event.rb b/app/models/event.rb index dd86efec..4fd3cbcf 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -358,7 +358,7 @@ class Event < ApplicationRecord errors.add(:abstract, "cannot have more than #{max_words} words") if len > max_words end - def submission_limit + def submission_limit # If we don't have an event type, there is no need to count anything return unless event_type && submission_text From 974d12db30d70159d44aec7462f6575f04cde976 Mon Sep 17 00:00:00 2001 From: CactusPuppy Date: Thu, 25 Feb 2021 20:30:27 -0800 Subject: [PATCH 07/15] Fix some rubocop complaints --- db/migrate/20210215213515_add_submission_text_to_events.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/migrate/20210215213515_add_submission_text_to_events.rb b/db/migrate/20210215213515_add_submission_text_to_events.rb index 90270eb3..cf935e18 100644 --- a/db/migrate/20210215213515_add_submission_text_to_events.rb +++ b/db/migrate/20210215213515_add_submission_text_to_events.rb @@ -1,5 +1,5 @@ class AddSubmissionTextToEvents < ActiveRecord::Migration[5.2] def change - add_column :events, :submission_text, :text + add_column :events, :submission_text, :text end end From b94894fe87ad3f02aa42cbfffea752140de61612 Mon Sep 17 00:00:00 2001 From: CactusPuppy Date: Fri, 26 Feb 2021 11:04:20 -0800 Subject: [PATCH 08/15] Update annotate_models --- app/models/event.rb | 1 + app/serializers/event_serializer.rb | 1 + spec/factories/events.rb | 1 + spec/models/event_spec.rb | 1 + spec/serializers/event_serializer_spec.rb | 1 + 5 files changed, 5 insertions(+) diff --git a/app/models/event.rb b/app/models/event.rb index 4fd3cbcf..6e5cda1b 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -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 diff --git a/app/serializers/event_serializer.rb b/app/serializers/event_serializer.rb index 4e81ef3b..8c30b1a1 100644 --- a/app/serializers/event_serializer.rb +++ b/app/serializers/event_serializer.rb @@ -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 diff --git a/spec/factories/events.rb b/spec/factories/events.rb index 18d40a3b..c8360449 100644 --- a/spec/factories/events.rb +++ b/spec/factories/events.rb @@ -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 diff --git a/spec/models/event_spec.rb b/spec/models/event_spec.rb index c2dca815..305275d6 100644 --- a/spec/models/event_spec.rb +++ b/spec/models/event_spec.rb @@ -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 diff --git a/spec/serializers/event_serializer_spec.rb b/spec/serializers/event_serializer_spec.rb index b365a310..506134cf 100644 --- a/spec/serializers/event_serializer_spec.rb +++ b/spec/serializers/event_serializer_spec.rb @@ -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 From 0aa33c497c25a099cb6c84ce6a42e15dd69d4434 Mon Sep 17 00:00:00 2001 From: CactusPuppy Date: Sat, 27 Feb 2021 11:25:37 -0800 Subject: [PATCH 09/15] Ensure that user is actually guest when testing --- spec/features/base_controller_spec.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/spec/features/base_controller_spec.rb b/spec/features/base_controller_spec.rb index 57d5be94..6bfd0622 100644 --- a/spec/features/base_controller_spec.rb +++ b/spec/features/base_controller_spec.rb @@ -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 From f207d070ac669bbb1ab62700bb96ce4b280875f8 Mon Sep 17 00:00:00 2001 From: CactusPuppy Date: Sat, 27 Feb 2021 11:29:27 -0800 Subject: [PATCH 10/15] Add spec for submission limits --- spec/models/event_spec.rb | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/spec/models/event_spec.rb b/spec/models/event_spec.rb index 305275d6..14e0b044 100644 --- a/spec/models/event_spec.rb +++ b/spec/models/event_spec.rb @@ -110,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 From 16f5ed6138175177aa6bb6d642802dba4a2e6bc6 Mon Sep 17 00:00:00 2001 From: CactusPuppy Date: Sat, 27 Feb 2021 22:54:35 -0800 Subject: [PATCH 11/15] Refactor calculation of submission limit and abstract limit into helper function --- app/models/event.rb | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/app/models/event.rb b/app/models/event.rb index 6e5cda1b..7c00b4d3 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -347,28 +347,28 @@ class Event < ApplicationRecord errors.add(:max_attendees, "cannot be more than the room's capacity (#{room.size})") if max_attendees && (max_attendees > room.size) end - def abstract_limit - # If we don't have an event type, there is no need to count anything - return unless event_type && abstract + def word_limit(field) + # If we don't have an event type or the requested field, don't count + return unless event_type && self.respond_to?(field) && self[field] - len = abstract.split.size + len = self[field].split.size + # TODO: Use different limits for different text fields + # Uncomment the two lines below this when the separate word limits are implemented. + # max_words = event_type["maximum_#{field}_length"] + # min_words = event_type["minimum_#{field}_length"] max_words = event_type.maximum_abstract_length min_words = event_type.minimum_abstract_length - errors.add(:abstract, "cannot have less than #{min_words} words") if len < min_words - errors.add(:abstract, "cannot have more than #{max_words} words") if len > max_words + errors.add(field.to_sym, "cannot have less than #{min_words} words") if len < min_words + errors.add(field.to_sym, "cannot have more than #{max_words} words") if len > max_words + end + + def abstract_limit + word_limit(:abstract) end def submission_limit - # If we don't have an event type, there is no need to count anything - return unless event_type && submission_text - - len = submission_text.split.size - max_words = event_type.maximum_abstract_length - min_words = event_type.minimum_abstract_length - - errors.add(:submission_text, "cannot have less than #{min_words} words") if len < min_words - errors.add(:submission_text, "cannot have more than #{max_words} words") if len > max_words + word_limit(:submission_text) end # TODO: create a module to be mixed into model to perform same operation From 626eaee761b361046b40c987f45cdc9e04bee960 Mon Sep 17 00:00:00 2001 From: CactusPuppy Date: Sat, 27 Feb 2021 23:03:29 -0800 Subject: [PATCH 12/15] Remove unnecessary self --- app/models/event.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/event.rb b/app/models/event.rb index 7c00b4d3..ba04ba20 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -349,7 +349,7 @@ class Event < ApplicationRecord def word_limit(field) # If we don't have an event type or the requested field, don't count - return unless event_type && self.respond_to?(field) && self[field] + return unless event_type && respond_to?(field) && self[field] len = self[field].split.size # TODO: Use different limits for different text fields From c8e6dc86d768f6df7b6a67635bde6cb8bdb309a2 Mon Sep 17 00:00:00 2001 From: CactusPuppy Date: Mon, 1 Mar 2021 22:56:45 -0800 Subject: [PATCH 13/15] Increase test coverage to stop codecov from complaining --- spec/helpers/events_helper_spec.rb | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/spec/helpers/events_helper_spec.rb b/spec/helpers/events_helper_spec.rb index c1cf5344..077d599e 100644 --- a/spec/helpers/events_helper_spec.rb +++ b/spec/helpers/events_helper_spec.rb @@ -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 'CANCELED' + 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 'REPLACEMENT' + end + + end + end + describe '#rating_tooltip' do let(:vote_count) { pluralize(event.voters.length, 'vote') } From 30ec69282d6c9a0d51de0fd269c3e6667074d1f6 Mon Sep 17 00:00:00 2001 From: CactusPuppy Date: Mon, 1 Mar 2021 23:00:04 -0800 Subject: [PATCH 14/15] Fix '==' instead of assignment operator --- spec/helpers/events_helper_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/helpers/events_helper_spec.rb b/spec/helpers/events_helper_spec.rb index 077d599e..71ed8b16 100644 --- a/spec/helpers/events_helper_spec.rb +++ b/spec/helpers/events_helper_spec.rb @@ -32,7 +32,7 @@ describe EventsHelper, type: :helper do 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' + event.state = 'confirmed' expect(canceled_replacement_event_label(event, nil, 'text-class')).to eq nil end @@ -42,7 +42,7 @@ describe EventsHelper, type: :helper do end it "when the event is a replacement but is not canceled" do - event.state == 'confirmed' + event.state = 'confirmed' allow(event_schedule).to receive(:replacement?) { true } expect(canceled_replacement_event_label(event, event_schedule, 'tent-class')).to eq 'REPLACEMENT' end From 54a5f84d8bd85064a39c259638088498e5c4ec60 Mon Sep 17 00:00:00 2001 From: CactusPuppy Date: Mon, 1 Mar 2021 23:01:28 -0800 Subject: [PATCH 15/15] Prefer single-quoted strings --- spec/helpers/events_helper_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/helpers/events_helper_spec.rb b/spec/helpers/events_helper_spec.rb index 71ed8b16..35866d6b 100644 --- a/spec/helpers/events_helper_spec.rb +++ b/spec/helpers/events_helper_spec.rb @@ -41,7 +41,7 @@ describe EventsHelper, type: :helper do expect(canceled_replacement_event_label(event, nil, 'test-class')).to eq 'CANCELED' end - it "when the event is a replacement but is not canceled" do + 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 'REPLACEMENT'