-
Notifications
You must be signed in to change notification settings - Fork 242
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4659 from mishaschwartz/v1.9.3
v1.9.3
- Loading branch information
Showing
9 changed files
with
107 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,76 +1,85 @@ | ||
describe JobMessagesController do | ||
describe '.get' do | ||
let(:admin) { create :admin } | ||
let(:job) { ApplicationJob.perform_later } | ||
let(:status) { ActiveJob::Status.get(job.job_id) } | ||
context 'when a job has been enqueued' do | ||
before :each do | ||
status[:status] = status_type | ||
params = { job_id: job.job_id } | ||
get_as admin, :get, params: params, session: params | ||
end | ||
after :each do | ||
flash.discard | ||
end | ||
context 'when the job failed' do | ||
let(:status_type) { :failed } | ||
it 'should flash an error message' do | ||
expect(flash[:error]).not_to be_nil | ||
shared_examples 'job messages' do | ||
describe '.get' do | ||
let(:job) { ApplicationJob.perform_later } | ||
let(:status) { ActiveJob::Status.get(job.job_id) } | ||
context 'when a job has been enqueued' do | ||
before :each do | ||
status[:status] = status_type | ||
params = { job_id: job.job_id } | ||
get_as user, :get, params: params, session: params | ||
end | ||
it 'should set the session[:job_id] to nil' do | ||
expect(request.session[:job_id]).to be_nil | ||
after :each do | ||
flash.discard | ||
end | ||
it 'should remove any progress flash messages' do | ||
expect(response.headers['X-Message-Discard']).to include 'notice' | ||
context 'when the job failed' do | ||
let(:status_type) { :failed } | ||
it 'should flash an error message' do | ||
expect(flash[:error]).not_to be_nil | ||
end | ||
it 'should set the session[:job_id] to nil' do | ||
expect(request.session[:job_id]).to be_nil | ||
end | ||
it 'should remove any progress flash messages' do | ||
expect(response.headers['X-Message-Discard']).to include 'notice' | ||
end | ||
end | ||
end | ||
context 'when the job completed successfully' do | ||
let(:status_type) { :completed } | ||
it 'should flash an success message' do | ||
expect(flash[:success]).not_to be_nil | ||
context 'when the job completed successfully' do | ||
let(:status_type) { :completed } | ||
it 'should flash an success message' do | ||
expect(flash[:success]).not_to be_nil | ||
end | ||
it 'should set the session[:job_id] to nil' do | ||
expect(request.session[:job_id]).to be_nil | ||
end | ||
it 'should remove any progress flash messages' do | ||
expect(response.headers['X-Message-Discard']).to include 'notice' | ||
end | ||
end | ||
it 'should set the session[:job_id] to nil' do | ||
expect(request.session[:job_id]).to be_nil | ||
context 'when the job is queued' do | ||
let(:status_type) { :queued } | ||
it 'should flash a notice message' do | ||
expect(flash[:notice]).to include "<p>#{I18n.t('poll_job.queued')}</p>" | ||
end | ||
it 'should not set the session[:job_id] to nil' do | ||
expect(request.session[:job_id]).to eq job.job_id | ||
end | ||
it 'should not remove any progress flash messages' do | ||
expect(response.headers['X-Message-Discard']).to be_nil | ||
end | ||
end | ||
it 'should remove any progress flash messages' do | ||
expect(response.headers['X-Message-Discard']).to include 'notice' | ||
context 'when the job is working' do | ||
let(:status_type) { :working } | ||
it 'should flash a notice message' do | ||
expect(flash[:notice]).to include "<p>#{ApplicationJob.show_status(status)}</p>" | ||
end | ||
it 'should not set the session[:job_id] to nil' do | ||
expect(request.session[:job_id]).to eq job.job_id | ||
end | ||
it 'should not remove any progress flash messages' do | ||
expect(response.headers['X-Message-Discard']).to be_nil | ||
end | ||
end | ||
end | ||
context 'when the job is queued' do | ||
let(:status_type) { :queued } | ||
it 'should flash a notice message' do | ||
expect(flash[:notice]).to include "<p>#{I18n.t('poll_job.queued')}</p>" | ||
context 'when no job has been enqueued' do | ||
before :each do | ||
get_as user, :get, params: { job_id: 'a' } | ||
end | ||
it 'should not set the session[:job_id] to nil' do | ||
expect(request.session[:job_id]).to eq job.job_id | ||
end | ||
it 'should not remove any progress flash messages' do | ||
expect(response.headers['X-Message-Discard']).to be_nil | ||
end | ||
end | ||
context 'when the job is working' do | ||
let(:status_type) { :working } | ||
it 'should flash a notice message' do | ||
expect(flash[:notice]).to include "<p>#{ApplicationJob.show_status(status)}</p>" | ||
end | ||
it 'should not set the session[:job_id] to nil' do | ||
expect(request.session[:job_id]).to eq job.job_id | ||
it 'should flash an error message' do | ||
expect(flash[:error]).not_to be_nil | ||
end | ||
it 'should not remove any progress flash messages' do | ||
expect(response.headers['X-Message-Discard']).to be_nil | ||
it 'should set the session[:job_id] to nil' do | ||
expect(request.session[:job_id]).to be_nil | ||
end | ||
end | ||
end | ||
context 'when no job has been enqueued' do | ||
before :each do | ||
get_as admin, :get, params: { job_id: 'a' } | ||
end | ||
it 'should flash an error message' do | ||
expect(flash[:error]).not_to be_nil | ||
end | ||
it 'should set the session[:job_id] to nil' do | ||
expect(request.session[:job_id]).to be_nil | ||
end | ||
end | ||
end | ||
context 'as an admin' do | ||
let(:user) { create :admin } | ||
it_behaves_like 'job messages' | ||
end | ||
context 'as a grader' do | ||
let(:user) { create :ta } | ||
it_behaves_like 'job messages' | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters