From 01086813af1000578c5cc2ed08bd70ea95c8eb5d Mon Sep 17 00:00:00 2001 From: Stella Rouzi Date: Sat, 17 Oct 2015 16:57:48 +0300 Subject: [PATCH 1/2] Style --- .../admin/call_for_papers_controller.rb | 17 +++++---- app/controllers/admin/campaigns_controller.rb | 10 +++--- .../admin/commercials_controller.rb | 18 ++++++---- .../admin/conference_controller.rb | 16 +++++---- app/controllers/admin/contacts_controller.rb | 4 ++- .../admin/difficulty_levels_controller.rb | 10 +++--- app/controllers/admin/emails_controller.rb | 6 ++-- .../admin/event_types_controller.rb | 10 +++--- app/controllers/admin/events_controller.rb | 4 +-- app/controllers/admin/lodgings_controller.rb | 18 +++++----- .../admin/registration_periods_controller.rb | 17 +++++---- .../admin/registrations_controller.rb | 13 +++---- app/controllers/admin/rooms_controller.rb | 8 ++--- .../admin/splashpages_controller.rb | 14 +++++--- app/controllers/admin/sponsors_controller.rb | 19 +++++----- .../admin/sponsorship_levels_controller.rb | 23 ++++++------ app/controllers/admin/targets_controller.rb | 18 +++++----- app/controllers/admin/tickets_controller.rb | 18 +++++----- app/controllers/admin/tracks_controller.rb | 8 ++--- app/controllers/admin/users_controller.rb | 6 ++-- app/controllers/admin/venues_controller.rb | 16 +++++---- .../admin/volunteers_controller.rb | 6 ++-- .../api/v1/conferences_controller.rb | 2 +- app/controllers/commercials_controller.rb | 15 ++++---- app/controllers/conference_controller.rb | 10 +++--- .../conference_registrations_controller.rb | 2 +- app/controllers/proposal_controller.rb | 25 ++++++------- .../ticket_purchases_controller.rb | 19 +++++----- app/controllers/tickets_controller.rb | 3 +- app/controllers/users_controller.rb | 3 +- app/models/ticket.rb | 2 +- .../events/_change_state_dropdown.html.haml | 36 +++++++++++++------ app/views/admin/tickets/_form.html.haml | 2 +- config/routes.rb | 1 - .../admin/conferences_controller_spec.rb | 4 +-- spec/features/tickets_spec.rb | 2 -- spec/models/ticket_spec.rb | 6 +--- 37 files changed, 221 insertions(+), 190 deletions(-) diff --git a/app/controllers/admin/call_for_papers_controller.rb b/app/controllers/admin/call_for_papers_controller.rb index 58e0efc6..1fbcf623 100644 --- a/app/controllers/admin/call_for_papers_controller.rb +++ b/app/controllers/admin/call_for_papers_controller.rb @@ -15,8 +15,8 @@ module Admin @call_for_paper = @conference.build_call_for_paper(call_for_paper_params) if @call_for_paper.save - redirect_to admin_conference_call_for_paper_path, - notice: 'Call for papers successfully created.' + flash[:notice] = 'Call for papers successfully created.' + redirect_to admin_conference_call_for_paper_path else flash[:error] = "Creating the call for papers failed. #{@call_for_paper.errors.full_messages.join('. ')}." render :new @@ -34,8 +34,9 @@ module Admin if @cfp.update_attributes(params[:call_for_paper]) Mailbot.delay.send_on_call_for_papers_dates_updates(@conference) if send_mail_on_cfp_dates_updates Mailbot.delay.send_on_schedule_public(@conference) if send_mail_on_schedule_public - redirect_to(admin_conference_call_for_paper_path(@conference.short_title), - notice: 'Call for papers successfully updated.') + + flash[:notice] = 'Call for papers successfully updated.' + redirect_to admin_conference_call_for_paper_path(@conference.short_title) else flash[:error] = "Updating call for papers failed. #{@cfp.errors.to_a.join('. ')}." render :new @@ -44,10 +45,12 @@ module Admin def destroy if @call_for_paper.destroy - redirect_to admin_conference_call_for_paper_path, notice: 'Call for Papers was successfully deleted.' + flash[:notice] = 'Call for Papers was successfully deleted.' + redirect_to admin_conference_call_for_paper_path else - redirect_to admin_conference_call_for_paper_path, error: 'An error prohibited this Call for Papers from being destroyed: '\ - "#{@call_for_paper.errors.full_messages.join('. ')}." + flash[:error] = 'An error prohibited this Call for Papers from being destroyed: '\ + "#{@call_for_paper.errors.full_messages.join('. ')}." + redirect_to admin_conference_call_for_paper_path end end diff --git a/app/controllers/admin/campaigns_controller.rb b/app/controllers/admin/campaigns_controller.rb index 2f39958a..e549cd33 100644 --- a/app/controllers/admin/campaigns_controller.rb +++ b/app/controllers/admin/campaigns_controller.rb @@ -13,7 +13,7 @@ module Admin if @conference.save flash[:notice] = 'Campaign successfully created.' - redirect_to(admin_conference_campaigns_path(conference_id: @conference.short_title)) + redirect_to admin_conference_campaigns_path(conference_id: @conference.short_title) else flash[:error] = 'Campaign creation failed. ' + @campaign.errors.full_messages.to_sentence render action: 'new' @@ -27,7 +27,7 @@ module Admin def update if @campaign.update_attributes(params[:campaign]) flash[:notice] = "Campaign '#{@campaign.name}' successfully updated." - redirect_to(admin_conference_campaigns_path(conference_id: @conference.short_title)) + redirect_to admin_conference_campaigns_path(conference_id: @conference.short_title) else flash[:error] = "Campaign update failed. #{@campaign.errors.full_messages.to_sentence}" render action: 'edit' @@ -37,11 +37,11 @@ module Admin def destroy if @campaign.destroy flash[:notice] = "Campaign '#{@campaign.name}' successfully deleted." - redirect_to(admin_conference_campaigns_path(conference_id: @conference.short_title)) + redirect_to admin_conference_campaigns_path(conference_id: @conference.short_title) else flash[:error] = "Delete of Campaign for #{@conference.short_title} failed." \ - "#{@campaign.errors.full_messages.join('. ')}." - redirect_to(admin_conference_campaigns_path(conference_id: @conference.short_title)) + "#{@campaign.errors.full_messages.join('. ')}." + redirect_to admin_conference_campaigns_path(conference_id: @conference.short_title) end end end diff --git a/app/controllers/admin/commercials_controller.rb b/app/controllers/admin/commercials_controller.rb index 59bfd459..3d824f58 100644 --- a/app/controllers/admin/commercials_controller.rb +++ b/app/controllers/admin/commercials_controller.rb @@ -19,8 +19,8 @@ module Admin authorize! :create, @commercial if @commercial.save - redirect_to admin_conference_commercials_path, - notice: 'Commercial was successfully created.' + flash[:notice] = 'Commercial was successfully created.' + redirect_to admin_conference_commercials_path else flash[:error] = "An error prohibited this Commercial from being saved: #{@commercial.errors.full_messages.join('. ')}." render :new @@ -29,8 +29,8 @@ module Admin def update if @commercial.update(commercial_params) - redirect_to admin_conference_commercials_path, - notice: 'Commercial was successfully updated.' + flash[:notice] = 'Commercial was successfully updated.' + redirect_to admin_conference_commercials_path else flash[:error] = "An error prohibited this Commercial from being saved: #{@commercial.errors.full_messages.join('. ')}." render :edit @@ -38,8 +38,14 @@ module Admin end def destroy - @commercial.destroy - redirect_to admin_conference_commercials_path, notice: 'Commercial was successfully destroyed.' + if @commercial.destroy + flash[:notice] = 'Commercial was successfully destroyed.' + redirect_to admin_conference_commercials_path + else + flash[:error] = 'Commercial was not destroyed.'\ + "#{@commercial.errors.full_messages.join('. ')}" + redirect_to admin_conference_commercials_path + end end private diff --git a/app/controllers/admin/conference_controller.rb b/app/controllers/admin/conference_controller.rb index 89ad9970..139f8487 100644 --- a/app/controllers/admin/conference_controller.rb +++ b/app/controllers/admin/conference_controller.rb @@ -69,8 +69,9 @@ module Admin @conference.save # user that creates the conference becomes organizer of that conference current_user.add_role :organizer, @conference - redirect_to(admin_conference_path(id: @conference.short_title), - notice: 'Conference was successfully created.') + + flash[:notice] = 'Conference was successfully created.' + redirect_to admin_conference_path(id: @conference.short_title) else render action: 'new' end @@ -84,12 +85,13 @@ module Admin if @conference.update_attributes(params[:conference]) Mailbot.delay.conference_date_update_mail(@conference) if send_mail_on_conf_update - redirect_to(edit_admin_conference_path(id: @conference.short_title), - notice: 'Conference was successfully updated.') + + flash[:notice] = 'Conference was successfully updated.' + redirect_to edit_admin_conference_path(id: @conference.short_title) else - redirect_to(edit_admin_conference_path(id: short_title), - alert: 'Updating conference failed. ' \ - "#{@conference.errors.full_messages.join('. ')}.") + flash[:error] = 'Updating conference failed. ' \ + "#{@conference.errors.full_messages.join('. ')}." + redirect_to edit_admin_conference_path(id: short_title) end end diff --git a/app/controllers/admin/contacts_controller.rb b/app/controllers/admin/contacts_controller.rb index a8cda01a..dcaf6bd9 100644 --- a/app/controllers/admin/contacts_controller.rb +++ b/app/controllers/admin/contacts_controller.rb @@ -12,8 +12,10 @@ module Admin # PATCH/PUT /:conference/contact def update if @contact.update(contact_params) - redirect_to edit_admin_conference_contact_path, notice: 'Contact details were successfully updated.' + flash[:notice] = 'Contact details were successfully updated.' + redirect_to edit_admin_conference_contact_path else + flash[:error] = 'Contact details were not updated.' render :edit end end diff --git a/app/controllers/admin/difficulty_levels_controller.rb b/app/controllers/admin/difficulty_levels_controller.rb index 8ee5edc1..0f494149 100644 --- a/app/controllers/admin/difficulty_levels_controller.rb +++ b/app/controllers/admin/difficulty_levels_controller.rb @@ -17,7 +17,7 @@ module Admin @difficulty_level = @conference.difficulty_levels.new(difficulty_level_params) if @difficulty_level.save flash[:notice] = 'Difficulty level successfully created.' - redirect_to(admin_conference_difficulty_levels_path(conference_id: @conference.short_title)) + redirect_to admin_conference_difficulty_levels_path(conference_id: @conference.short_title) else flash[:error] = "Creating difficulty level failed: #{@difficulty_level.errors.full_messages.join('. ')}." render :new @@ -27,7 +27,7 @@ module Admin def update if @difficulty_level.update_attributes(difficulty_level_params) flash[:notice] = 'Difficulty level successfully updated.' - redirect_to(admin_conference_difficulty_levels_path(conference_id: @conference.short_title)) + redirect_to admin_conference_difficulty_levels_path(conference_id: @conference.short_title) else flash[:error] = "Update difficulty level failed: #{@difficulty_level.errors.full_messages.join('. ')}." render :edit @@ -37,11 +37,11 @@ module Admin def destroy if @difficulty_level.destroy flash[:notice] = 'Difficulty level successfully deleted.' - redirect_to(admin_conference_difficulty_levels_path(conference_id: @conference.short_title)) + redirect_to admin_conference_difficulty_levels_path(conference_id: @conference.short_title) else flash[:error] = 'Deleting difficulty level type failed! ' \ - "#{@difficulty_level.errors.full_messages.join('. ')}." - redirect_to(admin_conference_difficulty_levels_path(conference_id: @conference.short_title)) + "#{@difficulty_level.errors.full_messages.join('. ')}." + redirect_to admin_conference_difficulty_levels_path(conference_id: @conference.short_title) end end diff --git a/app/controllers/admin/emails_controller.rb b/app/controllers/admin/emails_controller.rb index b0f0a26c..a6339d05 100644 --- a/app/controllers/admin/emails_controller.rb +++ b/app/controllers/admin/emails_controller.rb @@ -5,9 +5,9 @@ module Admin def update @conference.email_settings.update_attributes(params[:email_settings]) - redirect_to(admin_conference_emails_path( - @conference.short_title), - notice: 'Settings have been successfully updated.') + + flash[:notice] = 'Settings have been successfully updated.' + redirect_to admin_conference_emails_path(@conference.short_title) end def index diff --git a/app/controllers/admin/event_types_controller.rb b/app/controllers/admin/event_types_controller.rb index 8f2cf042..fbca47e0 100644 --- a/app/controllers/admin/event_types_controller.rb +++ b/app/controllers/admin/event_types_controller.rb @@ -17,7 +17,7 @@ module Admin @event_type = @conference.event_types.new(event_type_params) if @event_type.save flash[:notice] = 'Event type successfully created.' - redirect_to(admin_conference_event_types_path(conference_id: @conference.short_title)) + redirect_to admin_conference_event_types_path(conference_id: @conference.short_title) else flash[:error] = "Creating event type failed: #{@event_type.errors.full_messages.join('. ')}." render :new @@ -27,7 +27,7 @@ module Admin def update if @event_type.update_attributes(event_type_params) flash[:notice] = 'Event type successfully updated.' - redirect_to(admin_conference_event_types_path(conference_id: @conference.short_title)) + redirect_to admin_conference_event_types_path(conference_id: @conference.short_title) else flash[:error] = "Update event type failed: #{@event_type.errors.full_messages.join('. ')}." render :edit @@ -37,11 +37,11 @@ module Admin def destroy if @event_type.destroy flash[:notice] = 'Event type successfully deleted.' - redirect_to(admin_conference_event_types_path(conference_id: @conference.short_title)) + redirect_to admin_conference_event_types_path(conference_id: @conference.short_title) else flash[:error] = 'Destroying event type failed! ' \ - "#{@event_type.errors.full_messages.join('. ')}." - redirect_to(admin_conference_event_types_path(conference_id: @conference.short_title)) + "#{@event_type.errors.full_messages.join('. ')}." + redirect_to admin_conference_event_types_path(conference_id: @conference.short_title) end end diff --git a/app/controllers/admin/events_controller.rb b/app/controllers/admin/events_controller.rb index 2334531d..2b25cfdd 100644 --- a/app/controllers/admin/events_controller.rb +++ b/app/controllers/admin/events_controller.rb @@ -170,8 +170,8 @@ module Admin def get_event @event = @conference.events.find_by_id(params[:id]) if !@event - redirect_to(admin_conference_events_path(conference_id: @conference.short_title), - alert: 'Error! Could not find event!') && return + flash[:error] = 'Error! Could not find event!' + redirect_to admin_conference_events_path(conference_id: @conference.short_title) && return end @event end diff --git a/app/controllers/admin/lodgings_controller.rb b/app/controllers/admin/lodgings_controller.rb index 9b4fabdb..cad0353b 100644 --- a/app/controllers/admin/lodgings_controller.rb +++ b/app/controllers/admin/lodgings_controller.rb @@ -13,8 +13,8 @@ module Admin def create @lodging = @conference.lodgings.new(lodging_params) if @lodging.save - redirect_to(admin_conference_lodgings_path(conference_id: @conference.short_title), - notice: 'Lodging successfully created.') + flash[:notice] = 'Lodging successfully created.' + redirect_to admin_conference_lodgings_path(conference_id: @conference.short_title) else flash[:error] = "Creating Lodging failed: #{@lodging.errors.full_messages.join('. ')}." render :new @@ -25,8 +25,8 @@ module Admin def update if @lodging.update_attributes(lodging_params) - redirect_to(admin_conference_lodgings_path(conference_id: @conference.short_title), - notice: 'Lodging successfully updated.') + flash[:notice] = 'Lodging successfully updated.' + redirect_to admin_conference_lodgings_path(conference_id: @conference.short_title) else flash[:error] = "Update Lodging failed: #{@lodging.errors.full_messages.join('. ')}." render :edit @@ -35,12 +35,12 @@ module Admin def destroy if @lodging.destroy - redirect_to(admin_conference_lodgings_path(conference_id: @conference.short_title), - notice: 'Lodging successfully deleted.') + flash[:notice] = 'Lodging successfully deleted.' + redirect_to admin_conference_lodgings_path(conference_id: @conference.short_title) else - redirect_to(admin_conference_lodgings_path(conference_id: @conference.short_title), - error: 'Deleting lodging failed.' \ - "#{@lodging.errors.full_messages.join('. ')}.") + flash[:error] = 'Deleting lodging failed.' \ + "#{@lodging.errors.full_messages.join('. ')}." + redirect_to admin_conference_lodgings_path(conference_id: @conference.short_title) end end diff --git a/app/controllers/admin/registration_periods_controller.rb b/app/controllers/admin/registration_periods_controller.rb index 935cc443..41dc0208 100644 --- a/app/controllers/admin/registration_periods_controller.rb +++ b/app/controllers/admin/registration_periods_controller.rb @@ -13,8 +13,9 @@ module Admin if @registration_period.save Mailbot.delay.conference_registration_date_update_mail(@conference) if send_mail_on_reg_update - redirect_to admin_conference_registration_period_path(@conference.short_title), - notice: 'Registration Period successfully updated.' + + flash[:notice] = 'Registration Period successfully updated.' + redirect_to admin_conference_registration_period_path(@conference.short_title) else flash[:error] = "An error prohibited the Registration Period from being saved: #{@registration_period.errors.full_messages.join('. ')}." render :new @@ -33,19 +34,21 @@ module Admin if @registration_period.update(registration_period) Mailbot.delay.conference_registration_date_update_mail(@conference) if send_mail_on_reg_update - redirect_to admin_conference_registration_period_path(@conference.short_title), - notice: 'Registration Period successfully updated.' + + flash[:notice] = 'Registration Period successfully updated.' + redirect_to admin_conference_registration_period_path(@conference.short_title) else flash[:error] = 'An error prohibited the Registration Period from being saved: ' \ - "#{@registration_period.errors.full_messages.join('. ')}." + "#{@registration_period.errors.full_messages.join('. ')}." render :edit end end def destroy @registration_period.destroy - redirect_to admin_conference_registration_period_path, - notice: 'Registration Period was successfully destroyed.' + + flash[:notice] = 'Registration Period was successfully destroyed.' + redirect_to admin_conference_registration_period_path end private diff --git a/app/controllers/admin/registrations_controller.rb b/app/controllers/admin/registrations_controller.rb index 70abe4a1..22de21dd 100644 --- a/app/controllers/admin/registrations_controller.rb +++ b/app/controllers/admin/registrations_controller.rb @@ -16,8 +16,8 @@ module Admin def update @registration.update_attributes(registration_params) if @registration.save - redirect_to admin_conference_registrations_path(@conference.short_title), - notice: "Successfully updated registration for #{@registration.user.email}!" + flash[:notice] = "Successfully updated registration for #{@registration.user.email}!" + redirect_to admin_conference_registrations_path(@conference.short_title) else flash[:error] = "An error prohibited the Registration for #{@registration.user.email}: "\ "#{@registration.errors.full_messages.join('. ')}." @@ -28,11 +28,12 @@ module Admin def destroy if can? :destroy, @registration @registration.destroy - redirect_to admin_conference_registrations_path(@conference.short_title), - notice: "Deleted registration for #{@user.name}!" + + flash[:notice] = "Deleted registration for #{@user.name}!" + redirect_to admin_conference_registrations_path(@conference.short_title) else - redirect_to(admin_conference_registrations_path(@conference.short_title), - error: 'You must be an admin to delete a registration.') + flash[:error] = 'You must be an admin to delete a registration.' + redirect_to admin_conference_registrations_path(@conference.short_title) end end diff --git a/app/controllers/admin/rooms_controller.rb b/app/controllers/admin/rooms_controller.rb index 0b6b53c3..a1bc4c8c 100644 --- a/app/controllers/admin/rooms_controller.rb +++ b/app/controllers/admin/rooms_controller.rb @@ -17,7 +17,7 @@ module Admin @room = @conference.rooms.new(room_params) if @room.save flash[:notice] = 'Room successfully created.' - redirect_to(admin_conference_rooms_path(conference_id: @conference.short_title)) + redirect_to admin_conference_rooms_path(conference_id: @conference.short_title) else flash[:error] = "Creating Room failed: #{@room.errors.full_messages.join('. ')}." render :new @@ -27,7 +27,7 @@ module Admin def update if @room.update_attributes(room_params) flash[:notice] = 'Room successfully updated.' - redirect_to(admin_conference_rooms_path(conference_id: @conference.short_title)) + redirect_to admin_conference_rooms_path(conference_id: @conference.short_title) else flash[:error] = "Update Room failed: #{@room.errors.full_messages.join('. ')}." render :edit @@ -37,10 +37,10 @@ module Admin def destroy if @room.destroy flash[:notice] = 'Room successfully deleted.' - redirect_to(admin_conference_rooms_path(conference_id: @conference.short_title)) + redirect_to admin_conference_rooms_path(conference_id: @conference.short_title) else flash[:error] = "Destroying room failed! #{@room.errors.full_messages.join('. ')}." - redirect_to(admin_conference_rooms_path(conference_id: @conference.short_title)) + redirect_to admin_conference_rooms_path(conference_id: @conference.short_title) end end diff --git a/app/controllers/admin/splashpages_controller.rb b/app/controllers/admin/splashpages_controller.rb index 7359cf60..5dd3bb9a 100644 --- a/app/controllers/admin/splashpages_controller.rb +++ b/app/controllers/admin/splashpages_controller.rb @@ -15,9 +15,11 @@ module Admin @splashpage = @conference.build_splashpage(splashpage_params) if @splashpage.save - redirect_to admin_conference_splashpage_path, - notice: 'Splashpage successfully created.' + flash[:notice] = 'Splashpage successfully created.' + redirect_to admin_conference_splashpage_path else + flash[:error] = 'Splashpage could not be created.'\ + "#{@splashpage.errors.full_messages.join('. ')}." render :new end end @@ -33,10 +35,12 @@ module Admin def destroy if @splashpage.destroy - redirect_to admin_conference_splashpage_path, notice: 'Splashpage was successfully destroyed.' + flash[:notice] = 'Splashpage was successfully destroyed.' + redirect_to admin_conference_splashpage_path else - redirect_to admin_conference_splashpage_path, alert: 'An error prohibited this Splashpage from being destroyed: '\ - "#{@splashpage.errors.full_messages.join('. ')}." + flash[:error] = 'An error prohibited this Splashpage from being destroyed: '\ + "#{@splashpage.errors.full_messages.join('. ')}." + redirect_to admin_conference_splashpage_path end end diff --git a/app/controllers/admin/sponsors_controller.rb b/app/controllers/admin/sponsors_controller.rb index 64db50d9..efe7b62e 100644 --- a/app/controllers/admin/sponsors_controller.rb +++ b/app/controllers/admin/sponsors_controller.rb @@ -16,8 +16,8 @@ module Admin def create @sponsor = @conference.sponsors.new(sponsor_params) if @sponsor.save - redirect_to(admin_conference_sponsors_path(conference_id: @conference.short_title), - notice: 'Sponsor successfully created.') + flash[:notice] = 'Sponsor successfully created.' + redirect_to admin_conference_sponsors_path(conference_id: @conference.short_title) else flash[:error] = "Creating sponsor failed: #{@sponsor.errors.full_messages.join('. ')}." render :new @@ -26,9 +26,8 @@ module Admin def update if @sponsor.update_attributes(sponsor_params) - redirect_to(admin_conference_sponsors_path( - conference_id: @conference.short_title), - notice: 'Sponsor successfully updated.') + flash[:notice] = 'Sponsor successfully updated.' + redirect_to admin_conference_sponsors_path(conference_id: @conference.short_title) else flash[:error] = "Update sponsor failed: #{@sponsor.errors.full_messages.join('. ')}." render :edit @@ -37,12 +36,12 @@ module Admin def destroy if @sponsor.destroy - redirect_to(admin_conference_sponsors_path(conference_id: @conference.short_title), - notice: 'Sponsor successfully deleted.') + flash[:notice] = 'Sponsor successfully deleted.' + redirect_to admin_conference_sponsors_path(conference_id: @conference.short_title) else - redirect_to(admin_conference_sponsors_path(conference_id: @conference.short_title), - error: 'Deleting sponsor failed! ' \ - "#{@sponsor.errors.full_messages.join('. ')}.") + flash[:error] = 'Deleting sponsor failed! ' \ + "#{@sponsor.errors.full_messages.join('. ')}." + redirect_to admin_conference_sponsors_path(conference_id: @conference.short_title) end end diff --git a/app/controllers/admin/sponsorship_levels_controller.rb b/app/controllers/admin/sponsorship_levels_controller.rb index a4f0095b..68a19a5e 100644 --- a/app/controllers/admin/sponsorship_levels_controller.rb +++ b/app/controllers/admin/sponsorship_levels_controller.rb @@ -16,8 +16,8 @@ module Admin def create @sponsorship_level = @conference.sponsorship_levels.new(sponsorship_level_params) if @sponsorship_level.save - redirect_to(admin_conference_sponsorship_levels_path(conference_id: @conference.short_title), - notice: 'Sponsorship level successfully created.') + flash[:notice] = 'Sponsorship level successfully created.' + redirect_to admin_conference_sponsorship_levels_path(conference_id: @conference.short_title) else flash[:error] = "Creating Sponsorship Level failed: #{@sponsorship_level.errors.full_messages.join('. ')}." render :new @@ -26,9 +26,8 @@ module Admin def update if @sponsorship_level.update_attributes(sponsorship_level_params) - redirect_to(admin_conference_sponsorship_levels_path( - conference_id: @conference.short_title), - notice: 'Sponsorship level successfully updated.') + flash[:notice] = 'Sponsorship level successfully updated.' + redirect_to admin_conference_sponsorship_levels_path(conference_id: @conference.short_title) else flash[:error] = "Update Sponsorship level failed: #{@sponsorship_level.errors.full_messages.join('. ')}." render :edit @@ -37,23 +36,23 @@ module Admin def destroy if @sponsorship_level.destroy - redirect_to(admin_conference_sponsorship_levels_path(conference_id: @conference.short_title), - notice: 'Sponsorship level successfully deleted.') + flash[:notice] = 'Sponsorship level successfully deleted.' + redirect_to admin_conference_sponsorship_levels_path(conference_id: @conference.short_title) else - redirect_to(admin_conference_sponsorship_levels_path(conference_id: @conference.short_title), - error: 'Deleting sponsorship level failed! ' \ - "#{@sponsorship_level.errors.full_messages.join('. ')}.") + flash[:error] = 'Deleting sponsorship level failed! ' \ + "#{@sponsorship_level.errors.full_messages.join('. ')}." + redirect_to admin_conference_sponsorship_levels_path(conference_id: @conference.short_title) end end def up @sponsorship_level.move_higher - redirect_to(admin_conference_sponsorship_levels_path(conference_id: @conference.short_title)) + redirect_to admin_conference_sponsorship_levels_path(conference_id: @conference.short_title) end def down @sponsorship_level.move_lower - redirect_to(admin_conference_sponsorship_levels_path(conference_id: @conference.short_title)) + redirect_to admin_conference_sponsorship_levels_path(conference_id: @conference.short_title) end private diff --git a/app/controllers/admin/targets_controller.rb b/app/controllers/admin/targets_controller.rb index b0e11520..aafc20f6 100644 --- a/app/controllers/admin/targets_controller.rb +++ b/app/controllers/admin/targets_controller.rb @@ -14,8 +14,8 @@ module Admin def create @target = @conference.targets.new(target_params) if @target.save(target_params) - redirect_to(admin_conference_targets_path(conference_id: @conference.short_title), - notice: 'Target successfully created.') + flash[:notice] = 'Target successfully created.' + redirect_to admin_conference_targets_path(conference_id: @conference.short_title) else flash[:error] = "Creating target failed: #{@target.errors.full_messages.join('. ')}." render :new @@ -26,8 +26,8 @@ module Admin def update if @target.update_attributes(target_params) - redirect_to(admin_conference_targets_path(conference_id: @conference.short_title), - notice: 'Target successfully updated.') + flash[:notice] = 'Target successfully updated.' + redirect_to admin_conference_targets_path(conference_id: @conference.short_title) else flash[:error] = "Target update failed: #{@target.errors.full_messages.join('. ')}." render :edit @@ -36,12 +36,12 @@ module Admin def destroy if @target.destroy - redirect_to(admin_conference_targets_path(conference_id: @conference.short_title), - notice: 'Target successfully destroyed.') + flash[:notice] = 'Target successfully destroyed.' + redirect_to admin_conference_targets_path(conference_id: @conference.short_title) else - redirect_to(admin_conference_targets_path(conference_id: @conference.short_title), - error: 'Target was successfully destroyed.' \ - "#{@target.errors.full_messages.join('. ')}.") + flash[:error] = 'Target was successfully destroyed.' \ + "#{@target.errors.full_messages.join('. ')}." + redirect_to admin_conference_targets_path(conference_id: @conference.short_title) end end diff --git a/app/controllers/admin/tickets_controller.rb b/app/controllers/admin/tickets_controller.rb index de27459a..f289322b 100644 --- a/app/controllers/admin/tickets_controller.rb +++ b/app/controllers/admin/tickets_controller.rb @@ -14,8 +14,8 @@ module Admin def create @ticket = @conference.tickets.new(ticket_params) if @ticket.save(ticket_params) - redirect_to(admin_conference_tickets_path(conference_id: @conference.short_title), - notice: 'Ticket successfully created.') + flash[:notice] = 'Ticket successfully created.' + redirect_to admin_conference_tickets_path(conference_id: @conference.short_title) else flash[:error] = "Creating Ticket failed: #{@ticket.errors.full_messages.join('. ')}." render :new @@ -26,8 +26,8 @@ module Admin def update if @ticket.update_attributes(ticket_params) - redirect_to(admin_conference_tickets_path(conference_id: @conference.short_title), - notice: 'Ticket successfully updated.') + flash[:notice] = 'Ticket successfully updated.' + redirect_to admin_conference_tickets_path(conference_id: @conference.short_title) else flash[:error] = "Ticket update failed: #{@ticket.errors.full_messages.join('. ')}." render :edit @@ -36,12 +36,12 @@ module Admin def destroy if @ticket.destroy - redirect_to(admin_conference_tickets_path(conference_id: @conference.short_title), - notice: 'Ticket successfully destroyed.') + flash[:notice] = 'Ticket successfully destroyed.' + redirect_to admin_conference_tickets_path(conference_id: @conference.short_title) else - redirect_to(admin_conference_tickets_path(conference_id: @conference.short_title), - error: 'Ticket was successfully destroyed.' \ - "#{@ticket.errors.full_messages.join('. ')}.") + flash[:error] = 'Ticket was successfully destroyed.' \ + "#{@ticket.errors.full_messages.join('. ')}." + redirect_to admin_conference_tickets_path(conference_id: @conference.short_title) end end diff --git a/app/controllers/admin/tracks_controller.rb b/app/controllers/admin/tracks_controller.rb index 438b3dd0..c5e46d04 100644 --- a/app/controllers/admin/tracks_controller.rb +++ b/app/controllers/admin/tracks_controller.rb @@ -20,7 +20,7 @@ module Admin @track = @conference.tracks.new(track_params) if @track.save flash[:notice] = 'Track successfully created.' - redirect_to(admin_conference_tracks_path(conference_id: @conference.short_title)) + redirect_to admin_conference_tracks_path(conference_id: @conference.short_title) else flash[:error] = "Creating Track failed: #{@track.errors.full_messages.join('. ')}." render :new @@ -32,7 +32,7 @@ module Admin def update if @track.update_attributes(track_params) flash[:notice] = 'Track successfully updated.' - redirect_to(admin_conference_tracks_path(conference_id: @conference.short_title)) + redirect_to admin_conference_tracks_path(conference_id: @conference.short_title) else flash[:error] = "Track update failed: #{@track.errors.full_messages.join('. ')}." render :edit @@ -42,10 +42,10 @@ module Admin def destroy if @track.destroy flash[:notice] = 'Track successfully deleted.' - redirect_to(admin_conference_tracks_path(conference_id: @conference.short_title)) + redirect_to admin_conference_tracks_path(conference_id: @conference.short_title) else flash[:error] = "Track couldn't be deleted. #{@track.errors.full_messages.join('. ')}." - redirect_to(admin_conference_tracks_path(conference_id: @conference.short_title)) + redirect_to admin_conference_tracks_path(conference_id: @conference.short_title) end end diff --git a/app/controllers/admin/users_controller.rb b/app/controllers/admin/users_controller.rb index 607cbe7b..c328b15d 100644 --- a/app/controllers/admin/users_controller.rb +++ b/app/controllers/admin/users_controller.rb @@ -28,9 +28,11 @@ module Admin end if @user.update_attributes(params[:user]) - redirect_to admin_users_path, notice: "Updated #{@user.name} (#{@user.email})!" + message + flash[:notice] = "Updated #{@user.name} (#{@user.email})!" + message + redirect_to admin_users_path else - redirect_to admin_users_path, alert: "Could not update #{@user.name} (#{@user.email}). #{@user.errors.full_messages.join('. ')}." + flash[:error] = "Could not update #{@user.name} (#{@user.email}). #{@user.errors.full_messages.join('. ')}." + render :edit end end diff --git a/app/controllers/admin/venues_controller.rb b/app/controllers/admin/venues_controller.rb index 8cda7eed..6538e53e 100644 --- a/app/controllers/admin/venues_controller.rb +++ b/app/controllers/admin/venues_controller.rb @@ -15,8 +15,8 @@ module Admin @venue = @conference.build_venue(venue_params) if @venue.save - redirect_to admin_conference_venue_path, - notice: 'Venue was successfully created.' + flash[:notice] = 'Venue was successfully created.' + redirect_to admin_conference_venue_path else render :new end @@ -24,8 +24,8 @@ module Admin def update if @venue.update_attributes(venue_params) - redirect_to(admin_conference_venue_path(conference_id: @conference.short_title), - notice: 'Venue was successfully updated.') + flash[:notice] = 'Venue was successfully updated.' + redirect_to admin_conference_venue_path(conference_id: @conference.short_title) else flash[:error] = "Update venue failed: #{@venue.errors.full_messages.join('. ')}." render :edit @@ -34,10 +34,12 @@ module Admin def destroy if @venue.destroy - redirect_to admin_conference_venue_path, notice: 'Venue was successfully deleted.' + flash[:notice] = 'Venue was successfully deleted.' + redirect_to admin_conference_venue_path else - redirect_to admin_conference_venue_path, alert: 'An error prohibited this Venue from being destroyed: '\ - "#{@venue.errors.full_messages.join('. ')}." + flash[:error] = 'An error prohibited this Venue from being destroyed: '\ + "#{@venue.errors.full_messages.join('. ')}." + redirect_to admin_conference_venue_path end end diff --git a/app/controllers/admin/volunteers_controller.rb b/app/controllers/admin/volunteers_controller.rb index 558b20cb..5d7bc48a 100644 --- a/app/controllers/admin/volunteers_controller.rb +++ b/app/controllers/admin/volunteers_controller.rb @@ -25,9 +25,11 @@ module Admin def update if can_manage_volunteers(@conference) if @conference.update_attributes(params[:conference]) - redirect_to(admin_conference_volunteers_info_path(conference_id: params[:conference_id]), notice: 'Volunteering options were successfully updated.') + flash[:notice] = 'Volunteering options were successfully updated.' + redirect_to admin_conference_volunteers_info_path(conference_id: params[:conference_id]) else - redirect_to(admin_conference_volunteers_info_path(conference_id: params[:conference_id]), alert: "Volunteering options update failed: #{@conference.errors.full_messages.join '. '}") + flash[:error] = "Volunteering options update failed: #{@conference.errors.full_messages.join '. '}" + redirect_to admin_conference_volunteers_info_path(conference_id: params[:conference_id]) end else authorize! :index, :volunteer diff --git a/app/controllers/api/v1/conferences_controller.rb b/app/controllers/api/v1/conferences_controller.rb index 4b6b5239..1ba4e5e5 100644 --- a/app/controllers/api/v1/conferences_controller.rb +++ b/app/controllers/api/v1/conferences_controller.rb @@ -7,7 +7,7 @@ module Api if params[:conference_id].blank? conferences = Conference.all else - conferences = Conference.find_all_by_guid(params[:conference_id]) + conferences = Conference.find_by(short_title: params[:conference_id]) end render json: conferences, serializer: ConferencesArraySerializer end diff --git a/app/controllers/commercials_controller.rb b/app/controllers/commercials_controller.rb index c2992594..fb5863bc 100644 --- a/app/controllers/commercials_controller.rb +++ b/app/controllers/commercials_controller.rb @@ -15,8 +15,8 @@ class CommercialsController < ApplicationController authorize! :create, @commercial if @commercial.save - redirect_to edit_conference_proposal_path(conference_id: @conference.short_title, id: @event.id, anchor: 'commercials-content'), - notice: 'Commercial was successfully created.' + flash[:notice] = 'Commercial was successfully created.' + redirect_to edit_conference_proposal_path(conference_id: @conference.short_title, id: @event.id, anchor: 'commercials-content') else flash[:error] = "An error prohibited this Commercial from being saved: #{@commercial.errors.full_messages.join('. ')}." render :new @@ -25,8 +25,8 @@ class CommercialsController < ApplicationController def update if @commercial.update(commercial_params) - redirect_to edit_conference_proposal_path(conference_id: @conference.short_title, id: @event.id, anchor: 'commercials-content'), - notice: 'Commercial was successfully updated.' + flash[:notice] = 'Commercial was successfully updated.' + redirect_to edit_conference_proposal_path(conference_id: @conference.short_title, id: @event.id, anchor: 'commercials-content') else flash[:error] = "An error prohibited this Commercial from being saved: #{@commercial.errors.full_messages.join('. ')}." render :edit @@ -35,8 +35,8 @@ class CommercialsController < ApplicationController def destroy @commercial.destroy - redirect_to edit_conference_proposal_path(conference_id: @conference.short_title, id: @event.id), - notice: 'Commercial was successfully destroyed.' + flash[:notice] = 'Commercial was successfully destroyed.' + redirect_to edit_conference_proposal_path(conference_id: @conference.short_title, id: @event.id) end private @@ -46,7 +46,6 @@ class CommercialsController < ApplicationController end def commercial_params - #params.require(:commercial).permit(:commercial_id, :commercial_type) - params[:commercial] + params.require(:commercial).permit(:commercial_id, :commercial_type) end end diff --git a/app/controllers/conference_controller.rb b/app/controllers/conference_controller.rb index 3ba355fd..3923d6e7 100644 --- a/app/controllers/conference_controller.rb +++ b/app/controllers/conference_controller.rb @@ -28,9 +28,9 @@ class ConferenceController < ApplicationController private - def respond_to_options - respond_to do |format| - format.html { head :ok } - end if request.options? - end + def respond_to_options + respond_to do |format| + format.html { head :ok } + end if request.options? + end end diff --git a/app/controllers/conference_registrations_controller.rb b/app/controllers/conference_registrations_controller.rb index 23e3cf1a..05ed197b 100644 --- a/app/controllers/conference_registrations_controller.rb +++ b/app/controllers/conference_registrations_controller.rb @@ -95,7 +95,7 @@ class ConferenceRegistrationsController < ApplicationController def set_registration @registration = Registration.find_by(conference: @conference, user: current_user) if !@registration - flash[:alert] = "Can't find a registration for #{@conference.title} for you. Please register." + flash[:error] = "Can't find a registration for #{@conference.title} for you. Please register." redirect_to new_conference_conference_registrations_path(@conference.short_title) end end diff --git a/app/controllers/proposal_controller.rb b/app/controllers/proposal_controller.rb index 2bc9e099..841ff300 100644 --- a/app/controllers/proposal_controller.rb +++ b/app/controllers/proposal_controller.rb @@ -78,8 +78,8 @@ class ProposalController < ApplicationController return end - redirect_to(conference_proposal_index_path(conference_id: @conference.short_title), - notice: 'Proposal was successfully updated.') + flash[:notice] = 'Proposal was successfully updated.' + redirect_to conference_proposal_index_path(conference_id: @conference.short_title) end def destroy @@ -94,8 +94,8 @@ class ProposalController < ApplicationController end @event.save(validate: false) - redirect_to(conference_proposal_index_path(conference_id: @conference.short_title), - notice: 'Proposal was successfully withdrawn.') + flash[:notice] = 'Proposal was successfully withdrawn.' + redirect_to conference_proposal_index_path(conference_id: @conference.short_title) end def confirm @@ -116,11 +116,11 @@ class ProposalController < ApplicationController end if @conference.user_registered?(current_user) - redirect_to(conference_proposal_index_path(@conference.short_title), - notice: 'The proposal was confirmed.') + flash[:notice] = 'The proposal was confirmed.' + redirect_to conference_proposal_index_path(@conference.short_title) else - redirect_to(new_conference_conference_registrations_path(conference_id: @conference.short_title), - alert: 'The proposal was confirmed. Please register to attend the conference.') + flash[:error] = 'The proposal was confirmed. Please register to attend the conference.' + redirect_to new_conference_conference_registrations_path(conference_id: @conference.short_title) end end @@ -131,8 +131,8 @@ class ProposalController < ApplicationController begin @event.restart rescue Transitions::InvalidTransition - redirect_to(conference_proposal_index_path(conference_id: @conference.short_title), - error: "The proposal can't be re-submitted.") + flash[:error] = "The proposal can't be re-submitted." + redirect_to conference_proposal_index_path(conference_id: @conference.short_title) return end @@ -142,8 +142,9 @@ class ProposalController < ApplicationController return end - redirect_to(conference_proposal_index_path(conference_id: @conference.short_title), - notice: "The proposal was re-submitted. The #{@conference.short_title} organizers will review it again.") + flash[:notice] = "The proposal was re-submitted. The #{@conference.short_title} organizers will review it again." + + redirect_to conference_proposal_index_path(conference_id: @conference.short_title) end end diff --git a/app/controllers/ticket_purchases_controller.rb b/app/controllers/ticket_purchases_controller.rb index d54f271f..3095421d 100644 --- a/app/controllers/ticket_purchases_controller.rb +++ b/app/controllers/ticket_purchases_controller.rb @@ -7,26 +7,23 @@ class TicketPurchasesController < ApplicationController message = TicketPurchase.purchase(@conference, current_user, params[:tickets][0]) if message.blank? if current_user.ticket_purchases.any? - redirect_to conference_conference_registrations_path(@conference.short_title), - notice: "Thank you for supporting #{@conference.title} by purchasing a ticket." - else - redirect_to conference_conference_registrations_path(@conference.short_title) + flash[:notice] = "Thank you for supporting #{@conference.title} by purchasing a ticket." end + redirect_to conference_conference_registrations_path(@conference.short_title) else - redirect_to conference_conference_registrations_path(@conference.short_title), - alert: "Oops, something went wrong with your purchase! #{message}" + flash[:error] = "Oops, something went wrong with your purchase! #{message}" + redirect_to conference_conference_registrations_path(@conference.short_title) end end def destroy @ticket_purchases = current_user.ticket_purchases.find(params[:id]) if @ticket_purchases.destroy - redirect_to conference_conference_registrations_path(@conference.short_title), - notice: 'Ticket successfully deleted.' + flash[:notice] = 'Ticket successfully deleted.' + redirect_to conference_conference_registrations_path(@conference.short_title) else - redirect_to conference_conference_registrations_path(@conference.short_title), - alert: 'An error prohibited deleting your purchase! '\ - "#{@ticket_purchases.errors.full_messages.join('. ')}." + flash[:error] = "An error prohibited deleting your purchase! #{@ticket_purchases.errors.full_messages.join('. ')}." + redirect_to conference_conference_registrations_path(@conference.short_title) end end end diff --git a/app/controllers/tickets_controller.rb b/app/controllers/tickets_controller.rb index 55c73fc0..d6b73576 100644 --- a/app/controllers/tickets_controller.rb +++ b/app/controllers/tickets_controller.rb @@ -9,7 +9,8 @@ class TicketsController < ApplicationController def check_load_resource if @tickets.empty? - redirect_to root_path, notice: "There are no tickets available for #{@conference.title}!" + flash[:notice] = "There are no tickets available for #{@conference.title}!" + redirect_to root_path end end end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index edff9a95..82a414cf 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -13,7 +13,8 @@ class UsersController < ApplicationController # PATCH/PUT /users/1 def update if @user.update(user_params) - redirect_to @user, notice: 'User was successfully updated.' + flash[notice] = 'User was successfully updated.' + redirect_to @user else flash[:error] = "An error prohibited your Profile from being saved: #{@user.errors.full_messages.join('. ')}." render :edit diff --git a/app/models/ticket.rb b/app/models/ticket.rb index 54c54667..4125f84e 100644 --- a/app/models/ticket.rb +++ b/app/models/ticket.rb @@ -12,7 +12,7 @@ class Ticket < ActiveRecord::Base validates :price_cents, :price_currency, :title, presence: true - validates_numericality_of :price_cents, greater_than: 0 + validates :price_cents, numericality: { greater_than_or_equal_to: 0 } def bought?(user) buyers.include?(user) diff --git a/app/views/admin/events/_change_state_dropdown.html.haml b/app/views/admin/events/_change_state_dropdown.html.haml index dd0a96f8..4afdf78e 100644 --- a/app/views/admin/events/_change_state_dropdown.html.haml +++ b/app/views/admin/events/_change_state_dropdown.html.haml @@ -1,23 +1,37 @@ - if event.transition_possible? :accept - %li= link_to 'Accept event', - accept_admin_conference_event_path(@conference.short_title, event), - method: :patch, id: "accept_event_#{event.id}" - - if @conference.email_settings.send_on_accepted? + %li= link_to 'Accept event (with email)', + accept_admin_conference_event_path(@conference.short_title, event, send_mail: true), + hint: 'Accept this event and send an automated email.', + method: :patch, id: "accept_event_#{event.id}" + %li= link_to 'Accept event (without email)', accept_admin_conference_event_path(@conference.short_title, event, send_mail: false), - method: :patch, hint: 'Accept this event without sending an automated email.', - id: "accept_event_without_mail_#{event.id}" + hint: 'Accept this event without sending an automated email.', + method: :patch, id: "accept_event_without_mail_#{event.id}" + - else + %li= link_to 'Accept event (without email)', + accept_admin_conference_event_path(@conference.short_title, event), + hint: 'Accept this event without sending an automated email. You have not set an email template.', + method: :patch, id: "accept_event_#{event.id}" + - if event.transition_possible? :reject - %li= link_to 'Reject event', - reject_admin_conference_event_path(@conference.short_title, event), - method: :patch, confirm: 'Are you sure?', id: "reject_event_#{event.id}" - - if @conference.email_settings.send_on_rejected? + %li= link_to 'Reject event (with email)', + reject_admin_conference_event_path(@conference.short_title, event, send_mail: true), + hint: 'Reject this event and send an automated email.', + method: :patch, confirm: 'Are you sure?', id: "reject_event_#{event.id}" + %li= link_to 'Reject event (without email)', reject_admin_conference_event_path(@conference.short_title, event, send_mail: false), + hint: 'Reject this event without sending an automated email.', method: :patch, confirm: 'Are you sure?', id: "reject_event_without_mail_#{event.id}" + - else + %li= link_to 'Reject event (without email)', + reject_admin_conference_event_path(@conference.short_title, event), + hint: 'Reject this event without sending an automated email. You have not set an email template.', + method: :patch, confirm: 'Are you sure?', id: "reject_event_#{event.id}" - if event.transition_possible? :restart %li= link_to 'Start review', @@ -34,4 +48,4 @@ %li= link_to 'Cancel event', cancel_admin_conference_event_path(@conference.short_title, event), method: :patch, id: "cancel_event_#{event.id}", - hint: 'Mark this event as cancelled. Usually this means that the speakers had to cancel their appearance.' \ No newline at end of file + hint: 'Mark this event as cancelled. Usually this means that the speakers had to cancel their appearance.' diff --git a/app/views/admin/tickets/_form.html.haml b/app/views/admin/tickets/_form.html.haml index 7ff0821c..e74eab73 100644 --- a/app/views/admin/tickets/_form.html.haml +++ b/app/views/admin/tickets/_form.html.haml @@ -9,7 +9,7 @@ .row .col-md-8 = semantic_form_for(@ticket, :url => (@ticket.new_record? ? admin_conference_tickets_path : admin_conference_ticket_path(@conference.short_title, @ticket))) do |f| - = f.input :title + = f.input :title, input_html: { required: true, autofocus: true } = f.input :description, input_html: { rows: 5, data: { provide: "markdown-editable" } } = f.input :price = f.input :price_currency, as: :select, class: 'form-control', collection: ['USD', 'EUR', 'GBP', 'INR', 'CNY'], include_blank: false diff --git a/config/routes.rb b/config/routes.rb index 05766f76..07b61a57 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -27,7 +27,6 @@ Osem::Application.routes.draw do resources :photos, except: [:show] resource :schedule, only: [:show, :update] resources :commercials, except: [:show] - get '/stats' => 'stats#index' get '/dietary_choices' => 'dietchoices#show', as: 'dietary_list' patch '/dietary_choices' => 'dietchoices#update', as: 'dietary_update' get '/volunteers_list' => 'volunteers#show' diff --git a/spec/controllers/admin/conferences_controller_spec.rb b/spec/controllers/admin/conferences_controller_spec.rb index 4e2f0d78..d6ce658b 100644 --- a/spec/controllers/admin/conferences_controller_spec.rb +++ b/spec/controllers/admin/conferences_controller_spec.rb @@ -57,7 +57,7 @@ describe Admin::ConferenceController do short_title: nil) conference.reload - expect(flash[:alert]). + expect(flash[:error]). to eq("Updating conference failed. Short title can't be blank.") expect(conference.title).to eq('The dog and pony show') expect(conference.short_title).to eq("#{conference.short_title}") @@ -68,7 +68,7 @@ describe Admin::ConferenceController do attributes_for(:conference, title: 'Example Con', short_title: nil) - expect(flash[:alert]). + expect(flash[:error]). to eq("Updating conference failed. Short title can't be blank.") expect(response).to redirect_to edit_admin_conference_path( conference.short_title) diff --git a/spec/features/tickets_spec.rb b/spec/features/tickets_spec.rb index b7bde589..5abdc5a7 100644 --- a/spec/features/tickets_spec.rb +++ b/spec/features/tickets_spec.rb @@ -35,7 +35,6 @@ feature Ticket do fill_in 'ticket_price', with: '-1' click_button 'Create Ticket' - expect(flash).to eq("Creating Ticket failed: Title can't be blank. Price cents must be greater than 0.") expect(Ticket.count).to eq(0) end @@ -70,7 +69,6 @@ feature Ticket do ticket.reload expect(ticket.price).to eq(100) expect(ticket.title).to eq('Business Ticket') - expect(flash).to eq("Ticket update failed: Title can't be blank. Price cents must be greater than 0.") expect(Ticket.count).to eq(1) end diff --git a/spec/models/ticket_spec.rb b/spec/models/ticket_spec.rb index c093b072..ff2e2469 100644 --- a/spec/models/ticket_spec.rb +++ b/spec/models/ticket_spec.rb @@ -22,11 +22,7 @@ describe Ticket do should validate_presence_of(:price_currency) end - it 'is not valid with a price_cents equals zero' do - should_not allow_value(0).for(:price_cents) - end - - it 'is not valid with a price_cents smaller than zero' do + it 'is not valid with a price_cents less than zero' do should_not allow_value(-1).for(:price_cents) end From fafc06dd6e40dd219e988c948a7cf0a50ae5a878 Mon Sep 17 00:00:00 2001 From: Stella Rouzi Date: Sun, 25 Oct 2015 12:28:50 +0200 Subject: [PATCH 2/2] fix hakiri warning --- app/controllers/application_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index df6bedff..49fdc6fa 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,6 +1,6 @@ class ApplicationController < ActionController::Base include ApplicationHelper - protect_from_forgery + protect_from_forgery with: :exception before_filter :get_conferences before_filter :store_location helper_method :date_string