REFACTOR: admin dashboard controller specs to requests (#5967)
This commit is contained in:
parent
a4574cf2ca
commit
325f975ed3
|
@ -12,16 +12,20 @@ describe Admin::DashboardController do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'while logged in as an admin' do
|
context 'while logged in as an admin' do
|
||||||
let!(:admin) { log_in(:admin) }
|
let(:admin) { Fabricate(:admin) }
|
||||||
|
|
||||||
context '.index' do
|
before do
|
||||||
|
sign_in(admin)
|
||||||
|
end
|
||||||
|
|
||||||
|
describe '#index' do
|
||||||
context 'version checking is enabled' do
|
context 'version checking is enabled' do
|
||||||
before do
|
before do
|
||||||
SiteSetting.version_checks = true
|
SiteSetting.version_checks = true
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns discourse version info' do
|
it 'returns discourse version info' do
|
||||||
get :index, format: :json
|
get "/admin/dashboard.json"
|
||||||
|
|
||||||
expect(response.status).to eq(200)
|
expect(response.status).to eq(200)
|
||||||
expect(JSON.parse(response.body)['version_check']).to be_present
|
expect(JSON.parse(response.body)['version_check']).to be_present
|
||||||
|
@ -34,21 +38,22 @@ describe Admin::DashboardController do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does not return discourse version info' do
|
it 'does not return discourse version info' do
|
||||||
get :index, format: :json
|
get "/admin/dashboard.json"
|
||||||
|
expect(response.status).to eq(200)
|
||||||
json = JSON.parse(response.body)
|
json = JSON.parse(response.body)
|
||||||
expect(json['version_check']).not_to be_present
|
expect(json['version_check']).not_to be_present
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context '.problems' do
|
describe '#problems' do
|
||||||
context 'when there are no problems' do
|
context 'when there are no problems' do
|
||||||
before do
|
before do
|
||||||
AdminDashboardData.stubs(:fetch_problems).returns([])
|
AdminDashboardData.stubs(:fetch_problems).returns([])
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns an empty array' do
|
it 'returns an empty array' do
|
||||||
get :problems, format: :json
|
get "/admin/dashboard/problems.json"
|
||||||
|
|
||||||
expect(response.status).to eq(200)
|
expect(response.status).to eq(200)
|
||||||
json = JSON.parse(response.body)
|
json = JSON.parse(response.body)
|
||||||
|
@ -62,7 +67,8 @@ describe Admin::DashboardController do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns an array of strings' do
|
it 'returns an array of strings' do
|
||||||
get :problems, format: :json
|
get "/admin/dashboard/problems.json"
|
||||||
|
expect(response.status).to eq(200)
|
||||||
json = JSON.parse(response.body)
|
json = JSON.parse(response.body)
|
||||||
expect(json['problems'].size).to eq(2)
|
expect(json['problems'].size).to eq(2)
|
||||||
expect(json['problems'][0]).to be_a(String)
|
expect(json['problems'][0]).to be_a(String)
|
Loading…
Reference in New Issue