Commit 632cdc87dabe59f9025045cc52ecd0f767497f1c
Exists in
colab
and in
4 other branches
Merge pull request #118 from mezuro/load_errored_processing_spec
Unit tests for case when the processing returned with ERROR state
Showing
2 changed files
with
20 additions
and
0 deletions
Show diff stats
spec/controllers/repositories_controller_spec.rb
| ... | ... | @@ -310,6 +310,20 @@ describe RepositoriesController, :type => :controller do |
| 310 | 310 | it { is_expected.to respond_with(:ok) } |
| 311 | 311 | it { is_expected.not_to render_with_layout } |
| 312 | 312 | end |
| 313 | + | |
| 314 | + context 'with a ERROR state' do | |
| 315 | + let(:errored_processing) { FactoryGirl.build(:errored_processing) } | |
| 316 | + | |
| 317 | + before :each do | |
| 318 | + repository.expects(:last_processing).returns(errored_processing) | |
| 319 | + Repository.expects(:find).at_least_once.with(repository.id).returns(repository) | |
| 320 | + | |
| 321 | + xhr :get, :state, {project_id: project.id.to_s, id: repository.id, last_state: 'ANALYZING'} | |
| 322 | + end | |
| 323 | + | |
| 324 | + it { is_expected.to respond_with(:success) } | |
| 325 | + it { is_expected.to render_template(:load_error) } | |
| 326 | + end | |
| 313 | 327 | end |
| 314 | 328 | |
| 315 | 329 | describe 'process_repository' do | ... | ... |
spec/factories/processings.rb
| ... | ... | @@ -5,5 +5,11 @@ FactoryGirl.define do |
| 5 | 5 | state "READY" |
| 6 | 6 | process_time {[FactoryGirl.build(:process_time)]} |
| 7 | 7 | results_root_id "13" |
| 8 | + | |
| 9 | + trait :errored do | |
| 10 | + state "ERROR" | |
| 11 | + end | |
| 12 | + | |
| 13 | + factory :errored_processing, traits: [:errored] | |
| 8 | 14 | end |
| 9 | 15 | end |
| 10 | 16 | \ No newline at end of file | ... | ... |