Change update/save failures to use flash type :error instead of :alert

This commit is contained in:
Nishanth Vijayan 2016-03-16 11:20:56 +05:30
parent 19c54bd935
commit 1c1e56ed46
10 changed files with 13 additions and 13 deletions

View file

@ -90,7 +90,7 @@ module Admin
notice: 'Conference was successfully updated.' notice: 'Conference was successfully updated.'
else else
redirect_to edit_admin_conference_path(id: short_title), redirect_to edit_admin_conference_path(id: short_title),
alert: 'Updating conference failed. ' \ error: 'Updating conference failed. ' \
"#{@conference.errors.full_messages.join('. ')}." "#{@conference.errors.full_messages.join('. ')}."
end end
end end

View file

@ -183,7 +183,7 @@ module Admin
@event = @conference.program.events.find(params[:id]) @event = @conference.program.events.find(params[:id])
if !@event if !@event
redirect_to admin_conference_program_events_path(conference_id: @conference.short_title), redirect_to admin_conference_program_events_path(conference_id: @conference.short_title),
alert: 'Error! Could not find event!' error: 'Error! Could not find event!'
return return
end end
@event @event

View file

@ -40,7 +40,7 @@ module Admin
# GET questions/1/edit # GET questions/1/edit
def edit def edit
if @question.global if @question.global
redirect_to admin_conference_questions_path(conference_id: @conference.short_title), alert: 'Sorry, you cannot edit global questions. Create a new one.' redirect_to admin_conference_questions_path(conference_id: @conference.short_title), error: 'Sorry, you cannot edit global questions. Create a new one.'
end end
end end

View file

@ -35,7 +35,7 @@ module Admin
if @splashpage.destroy if @splashpage.destroy
redirect_to admin_conference_splashpage_path, notice: 'Splashpage was successfully destroyed.' redirect_to admin_conference_splashpage_path, notice: 'Splashpage was successfully destroyed.'
else else
redirect_to admin_conference_splashpage_path, alert: 'An error prohibited this Splashpage from being destroyed: '\ redirect_to admin_conference_splashpage_path, error: 'An error prohibited this Splashpage from being destroyed: '\
"#{@splashpage.errors.full_messages.join('. ')}." "#{@splashpage.errors.full_messages.join('. ')}."
end end
end end

View file

@ -30,7 +30,7 @@ module Admin
if @user.update_attributes(user_params) if @user.update_attributes(user_params)
redirect_to admin_users_path, notice: "Updated #{@user.name} (#{@user.email})!" + message redirect_to admin_users_path, notice: "Updated #{@user.name} (#{@user.email})!" + message
else else
redirect_to admin_users_path, alert: "Could not update #{@user.name} (#{@user.email}). #{@user.errors.full_messages.join('. ')}." redirect_to admin_users_path, error: "Could not update #{@user.name} (#{@user.email}). #{@user.errors.full_messages.join('. ')}."
end end
end end

View file

@ -36,7 +36,7 @@ module Admin
if @venue.destroy if @venue.destroy
redirect_to admin_conference_venue_path, notice: 'Venue was successfully deleted.' redirect_to admin_conference_venue_path, notice: 'Venue was successfully deleted.'
else else
redirect_to admin_conference_venue_path, alert: 'An error prohibited this Venue from being destroyed: '\ redirect_to admin_conference_venue_path, error: 'An error prohibited this Venue from being destroyed: '\
"#{@venue.errors.full_messages.join('. ')}." "#{@venue.errors.full_messages.join('. ')}."
end end
end end

View file

@ -26,7 +26,7 @@ module Admin
if @conference.update_attributes(conference_params) if @conference.update_attributes(conference_params)
redirect_to admin_conference_volunteers_info_path(conference_id: params[:conference_id]), notice: 'Volunteering options were successfully updated.' redirect_to admin_conference_volunteers_info_path(conference_id: params[:conference_id]), notice: 'Volunteering options were successfully updated.'
else else
redirect_to admin_conference_volunteers_info_path(conference_id: params[:conference_id]), alert: "Volunteering options update failed: #{@conference.errors.full_messages.join '. '}" redirect_to admin_conference_volunteers_info_path(conference_id: params[:conference_id]), error: "Volunteering options update failed: #{@conference.errors.full_messages.join '. '}"
end end
end end

View file

@ -21,7 +21,7 @@ class ConferenceRegistrationsController < ApplicationController
end end
if @conference.registration_limit_exceeded? if @conference.registration_limit_exceeded?
redirect_to root_path, alert: "Sorry, registration limit exceeded for #{@conference.title}" redirect_to root_path, error: "Sorry, registration limit exceeded for #{@conference.title}"
return return
end end
@ -102,7 +102,7 @@ class ConferenceRegistrationsController < ApplicationController
@registration = Registration.find_by(conference: @conference, user: current_user) @registration = Registration.find_by(conference: @conference, user: current_user)
if !@registration if !@registration
redirect_to new_conference_conference_registrations_path(@conference.short_title), redirect_to new_conference_conference_registrations_path(@conference.short_title),
alert: "Can't find a registration for #{@conference.title} for you. Please register." error: "Can't find a registration for #{@conference.title} for you. Please register."
end end
end end

View file

@ -14,7 +14,7 @@ class TicketPurchasesController < ApplicationController
end end
else else
redirect_to conference_conference_registrations_path(@conference.short_title), redirect_to conference_conference_registrations_path(@conference.short_title),
alert: "Oops, something went wrong with your purchase! #{message}" error: "Oops, something went wrong with your purchase! #{message}"
end end
end end
@ -25,7 +25,7 @@ class TicketPurchasesController < ApplicationController
notice: 'Ticket successfully deleted.' notice: 'Ticket successfully deleted.'
else else
redirect_to conference_conference_registrations_path(@conference.short_title), redirect_to conference_conference_registrations_path(@conference.short_title),
alert: 'An error prohibited deleting your purchase! '\ error: 'An error prohibited deleting your purchase! '\
"#{@ticket_purchases.errors.full_messages.join('. ')}." "#{@ticket_purchases.errors.full_messages.join('. ')}."
end end
end end

View file

@ -56,7 +56,7 @@ describe Admin::ConferenceController do
short_title: nil) short_title: nil)
conference.reload conference.reload
expect(flash[:alert]). expect(flash[:error]).
to eq("Updating conference failed. Short title can't be blank.") to eq("Updating conference failed. Short title can't be blank.")
expect(conference.title).to eq('The dog and pony show') expect(conference.title).to eq('The dog and pony show')
expect(conference.short_title).to eq("#{conference.short_title}") expect(conference.short_title).to eq("#{conference.short_title}")
@ -67,7 +67,7 @@ describe Admin::ConferenceController do
attributes_for(:conference, title: 'Example Con', attributes_for(:conference, title: 'Example Con',
short_title: nil) short_title: nil)
expect(flash[:alert]). expect(flash[:error]).
to eq("Updating conference failed. Short title can't be blank.") to eq("Updating conference failed. Short title can't be blank.")
expect(response).to redirect_to edit_admin_conference_path( expect(response).to redirect_to edit_admin_conference_path(
conference.short_title) conference.short_title)