diff options
author | Akihiko Odaki <akihiko.odaki.4i@stu.hosei.ac.jp> | 2017-05-30 01:12:34 +0900 |
---|---|---|
committer | Eugen Rochko <eugen@zeonfederated.com> | 2017-05-29 18:12:34 +0200 |
commit | 34157d118c03f60df392404e8c617606063c6530 (patch) | |
tree | 7ce166a71c7fd75092199d2ee0e62e91b3e681c7 /spec | |
parent | 7b92950f1c43ad009d169ce1792c9afed109b417 (diff) |
Cover Admin::ReportsController more (#3346)
Diffstat (limited to 'spec')
-rw-r--r-- | spec/controllers/admin/reports_controller_spec.rb | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/spec/controllers/admin/reports_controller_spec.rb b/spec/controllers/admin/reports_controller_spec.rb index 89b58ad07..71a185147 100644 --- a/spec/controllers/admin/reports_controller_spec.rb +++ b/spec/controllers/admin/reports_controller_spec.rb @@ -10,27 +10,38 @@ describe Admin::ReportsController do describe 'GET #index' do it 'returns http success with no filters' do - allow(Report).to receive(:unresolved).and_return(Report.all) + specified = Fabricate(:report, action_taken: false) + Fabricate(:report, action_taken: true) + get :index + reports = assigns(:reports).to_a + expect(reports.size).to eq 1 + expect(reports[0]).to eq specified expect(response).to have_http_status(:success) - expect(Report).to have_received(:unresolved) end it 'returns http success with resolved filter' do - allow(Report).to receive(:resolved).and_return(Report.all) + specified = Fabricate(:report, action_taken: true) + Fabricate(:report, action_taken: false) + get :index, params: { resolved: 1 } + reports = assigns(:reports).to_a + expect(reports.size).to eq 1 + expect(reports[0]).to eq specified + expect(response).to have_http_status(:success) - expect(Report).to have_received(:resolved) end end describe 'GET #show' do - it 'returns http success' do + it 'renders report' do report = Fabricate(:report) get :show, params: { id: report } + + expect(assigns(:report)).to eq report expect(response).to have_http_status(:success) end end |