diff --git a/app/assets/stylesheets/pages/_error.scss b/app/assets/stylesheets/pages/_error.scss index e94f826..2915ced 100644 --- a/app/assets/stylesheets/pages/_error.scss +++ b/app/assets/stylesheets/pages/_error.scss @@ -25,6 +25,16 @@ background-color: #f39c12; } +.success { + @extend .error; + background-color: $brand-success; +} + +.notice { + @extend .error; + background-color: $brand-info; +} + [data-id="live-coder-finish-later"] { .warning { margin-top: 0; diff --git a/app/controllers/admin/question_controller.rb b/app/controllers/admin/question_controller.rb index ee5a355..7ee4266 100644 --- a/app/controllers/admin/question_controller.rb +++ b/app/controllers/admin/question_controller.rb @@ -14,7 +14,7 @@ module Admin @question = Question.create(process_question_params) if @question.persisted? - redirect_to admin_questions_path, flash: { notice: "Sucessfully created question" } + redirect_to admin_questions_path, flash: { success: "Sucessfully created question" } else flash[:error] = "Failed to save question." render :new @@ -36,7 +36,7 @@ module Admin if @question.update_attributes(process_question_params) redirect_to admin_question_path(@question.to_i), - flash: { notice: "Sucessfully updated question" } + flash: { success: "Sucessfully updated question" } else flash[:error] = "Failed to update question." render :edit diff --git a/app/controllers/admin/user_controller.rb b/app/controllers/admin/user_controller.rb index 23c11dd..0d3d38e 100644 --- a/app/controllers/admin/user_controller.rb +++ b/app/controllers/admin/user_controller.rb @@ -14,7 +14,7 @@ module Admin if @user.persisted? # TODO: UserMailer.welcome(@user, default_passwd).deliver_now - redirect_to admin_users_path, flash: { notice: "Sucessfully created user #{@user.name}" } + redirect_to admin_users_path, flash: { success: "Sucessfully created user #{@user.name}" } else flash[:error] = "Failed to save user." render :new @@ -34,7 +34,7 @@ module Admin if @user.update_attributes(user_params) redirect_to admin_user_path(@user.to_i), - flash: { notice: "Sucessfully updated #{@user.name}" } + flash: { success: "Sucessfully updated #{@user.name}" } else flash[:error] = "Failed to update user." render :edit diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index e6bb02d..430edcd 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,6 +1,8 @@ class ApplicationController < ActionController::Base protect_from_forgery with: :exception + add_flash_types :warning, :success + def current_recruiter user_parms = { id: session[:user], role: %w(admin recruiter) } @current_recruiter ||= User.find_by(user_parms) if session[:user] diff --git a/app/controllers/recruiter_controller.rb b/app/controllers/recruiter_controller.rb index dcb145a..23a3238 100644 --- a/app/controllers/recruiter_controller.rb +++ b/app/controllers/recruiter_controller.rb @@ -16,7 +16,7 @@ class RecruiterController < ApplicationController if @candidate.persisted? CandidateMailer.welcome(@candidate).deliver_now RecruiterMailer.candidate_created(@candidate).deliver_now - redirect_to recruiter_path, flash: { notice: "Sucessfully created candidate #{@candidate.name}" } + redirect_to recruiter_path, flash: { success: "Sucessfully created candidate #{@candidate.name}" } else flash[:error] = "Failed to save candidate." render :form diff --git a/app/views/shared/_generic_flash.html.erb b/app/views/shared/_generic_flash.html.erb new file mode 100644 index 0000000..bd703c4 --- /dev/null +++ b/app/views/shared/_generic_flash.html.erb @@ -0,0 +1,15 @@ +<% if flash[:error].present? %> +
<%= flash[:error] %>
+<% end %> + +<% if flash[:success].present? %> +
<%= flash[:success] %>
+<% end %> + +<% if flash[:warning].present? %> +
<%= flash[:warning] %>
+<% end %> + +<% if flash[:notice].present? %> +
<%= flash[:notice] %>
+<% end %> diff --git a/app/views/styleguide.html.erb b/app/views/styleguide.html.erb index eaa69e6..5594fe8 100644 --- a/app/views/styleguide.html.erb +++ b/app/views/styleguide.html.erb @@ -150,7 +150,9 @@
This is a sample error message.
- +
This is a sample success message.
+
This is a sample warning message.
+
This is a sample notice message.

diff --git a/test/controllers/recruiter_controller_test.rb b/test/controllers/recruiter_controller_test.rb index d63c300..41343cc 100644 --- a/test/controllers/recruiter_controller_test.rb +++ b/test/controllers/recruiter_controller_test.rb @@ -74,7 +74,7 @@ class RecruiterControllerTest < ActionDispatch::IntegrationTest end end assert_redirected_to recruiter_path - assert flash[:notice] + assert flash[:success] end test "should fail creation with message" do