8_increase_test_coverage_controllers #36
1 changed files with 11 additions and 5 deletions
|
@ -12,6 +12,7 @@ describe ArticlesController, type: :controller do
|
||||||
|
|
||||||
let(:supplier) { create :supplier, articles: [article_a, article_b] }
|
let(:supplier) { create :supplier, articles: [article_a, article_b] }
|
||||||
let(:order) { create :order }
|
let(:order) { create :order }
|
||||||
|
let(:order2) { create :order }
|
||||||
|
|
||||||
def get_with_supplier(action, params: {}, xhr: false, format: nil)
|
def get_with_supplier(action, params: {}, xhr: false, format: nil)
|
||||||
params['supplier_id'] = supplier.id
|
params['supplier_id'] = supplier.id
|
||||||
|
@ -141,7 +142,8 @@ describe ArticlesController, type: :controller do
|
||||||
get_with_supplier :update_selected, params: { selected_articles: [article_a.id, article_b.id], selected_action: 'destroy' }
|
get_with_supplier :update_selected, params: { selected_articles: [article_a.id, article_b.id], selected_action: 'destroy' }
|
||||||
article_a.reload
|
article_a.reload
|
||||||
article_b.reload
|
article_b.reload
|
||||||
expect(article_a.deleted? && article_b.deleted?).to be_truthy
|
expect(article_a).to be_deleted
|
||||||
|
expect(article_b).to be_deleted
|
||||||
expect(response).to have_http_status(:redirect)
|
expect(response).to have_http_status(:redirect)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -149,7 +151,8 @@ describe ArticlesController, type: :controller do
|
||||||
get_with_supplier :update_selected, params: { selected_articles: [article_a.id, article_b.id], selected_action: 'setNotAvailable' }
|
get_with_supplier :update_selected, params: { selected_articles: [article_a.id, article_b.id], selected_action: 'setNotAvailable' }
|
||||||
article_a.reload
|
article_a.reload
|
||||||
article_b.reload
|
article_b.reload
|
||||||
expect(article_a.availability || article_b.availability).to be_falsey
|
expect(article_a).not_to be_availability
|
||||||
|
expect(article_b).not_to be_availability
|
||||||
expect(response).to have_http_status(:redirect)
|
expect(response).to have_http_status(:redirect)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -157,7 +160,8 @@ describe ArticlesController, type: :controller do
|
||||||
get_with_supplier :update_selected, params: { selected_articles: [article_a.id, article_b.id], selected_action: 'setAvailable' }
|
get_with_supplier :update_selected, params: { selected_articles: [article_a.id, article_b.id], selected_action: 'setAvailable' }
|
||||||
article_a.reload
|
article_a.reload
|
||||||
article_b.reload
|
article_b.reload
|
||||||
expect(article_a.availability && article_b.availability).to be_truthy
|
expect(article_a).to be_availability
|
||||||
|
expect(article_b).to be_availability
|
||||||
expect(response).to have_http_status(:redirect)
|
expect(response).to have_http_status(:redirect)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -165,7 +169,8 @@ describe ArticlesController, type: :controller do
|
||||||
get_with_supplier :update_selected, params: { selected_articles: [article_a.id, article_c.id], selected_action: 'destroy' }
|
get_with_supplier :update_selected, params: { selected_articles: [article_a.id, article_c.id], selected_action: 'destroy' }
|
||||||
article_a.reload
|
article_a.reload
|
||||||
article_c.reload
|
article_c.reload
|
||||||
expect(article_a.deleted? || article_c.deleted?).to be_falsey
|
expect(article_a).not_to be_deleted
|
||||||
|
expect(article_c).not_to be_deleted
|
||||||
expect(response).to have_http_status(:redirect)
|
expect(response).to have_http_status(:redirect)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -236,7 +241,8 @@ describe ArticlesController, type: :controller do
|
||||||
get_with_supplier :update_synchronized, params: { outlisted_articles: { article_a.id => article_a, article_b.id => article_b } }
|
get_with_supplier :update_synchronized, params: { outlisted_articles: { article_a.id => article_a, article_b.id => article_b } }
|
||||||
article_a.reload
|
article_a.reload
|
||||||
article_b.reload
|
article_b.reload
|
||||||
expect(article_a.deleted? && article_b.deleted?).to be_truthy
|
expect(article_a).to be_deleted
|
||||||
|
expect(article_b).to be_deleted
|
||||||
expect(response).to have_http_status(:redirect)
|
expect(response).to have_http_status(:redirect)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue