Skip to content

Commit

Permalink
Use more specific flashes than notice
Browse files Browse the repository at this point in the history
This affects the pretty styling via bootstrap alerts.  Intuitively, a
message that starts with `Success!` is a `:success` flash.
  • Loading branch information
atz committed Oct 2, 2018
1 parent 946c8a8 commit 816af47
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
3 changes: 2 additions & 1 deletion app/controllers/bundle_contexts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ def new
def create
@bundle_context = BundleContext.new(bundle_contexts_params)
if @bundle_context.save
redirect_to controller: 'job_runs', created: 1
flash[:success] = 'Success! Your job is queued. A link to your validation report will be emailed to you when it is ready.'
redirect_to controller: 'job_runs'
else
render :new
end
Expand Down
3 changes: 1 addition & 2 deletions app/controllers/job_runs_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
class JobRunsController < ApplicationController
def index
flash[:notice] = 'Success! Your job is queued. A link to your validation report will be emailed to you when it is ready.' if params[:created]
@job_runs = JobRun.order('created_at desc').page params[:page]
end

Expand All @@ -13,7 +12,7 @@ def download
if @job_run.output_location
send_file @job_run.output_location
else
flash[:notice] = 'Job is not complete. Please check back later.'
flash[:warning] = 'Job is not complete. Please check back later.'
render 'show'
end
end
Expand Down
3 changes: 2 additions & 1 deletion spec/controllers/bundle_contexts_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@
post :create, params: params
expect(assigns(:bundle_context)).to be_a(BundleContext).and be_persisted
expect(response).to have_http_status(302) # HTTP code for found
expect(response).to redirect_to(job_runs_path(created: 1))
expect(response).to redirect_to(job_runs_path)
expect(flash[:success]).to start_with('Success! Your job is queued.')
end
it 'has the correct attributes' do
post :create, params: params
Expand Down
4 changes: 2 additions & 2 deletions spec/controllers/job_runs_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
it 'before job is complete, renders page with flash' do
allow(JobRun).to receive(:find).with('123').and_return(instance_double(JobRun, output_location: nil))
get :download, params: { id: 123 }
expect(flash[:notice]).to eq('Job is not complete. Please check back later.')
expect(flash[:warning]).to eq('Job is not complete. Please check back later.')
end
it 'when job is complete, returns file attachment' do
job_run_double = instance_double(JobRun, output_location: 'spec/test_data/input/mock_progress_log.yaml')
Expand All @@ -42,7 +42,7 @@
'Content-Type' => 'application/x-yaml',
'Content-Disposition' => 'attachment; filename="mock_progress_log.yaml"'
)
expect(flash[:notice]).to be_nil
expect(flash[:warning]).to be_nil
end
it 'requires ID param' do
expect { get :download }.to raise_error(ActionController::UrlGenerationError)
Expand Down

0 comments on commit 816af47

Please sign in to comment.