mirror of
https://github.com/discourse/discourse.git
synced 2025-05-28 01:56:58 +08:00
Fix all the errors to get our tests green on Rails 5.1.
This commit is contained in:
@ -15,20 +15,16 @@ describe Admin::DashboardController do
|
||||
let!(:admin) { log_in(:admin) }
|
||||
|
||||
context '.index' do
|
||||
it 'should be successful' do
|
||||
xhr :get, :index
|
||||
expect(response).to be_successful
|
||||
end
|
||||
|
||||
context 'version checking is enabled' do
|
||||
before do
|
||||
SiteSetting.version_checks = true
|
||||
end
|
||||
|
||||
it 'returns discourse version info' do
|
||||
xhr :get, :index
|
||||
json = JSON.parse(response.body)
|
||||
expect(json['version_check']).to be_present
|
||||
get :index, format: :json
|
||||
|
||||
expect(response).to be_success
|
||||
expect(JSON.parse(response.body)['version_check']).to be_present
|
||||
end
|
||||
end
|
||||
|
||||
@ -38,7 +34,7 @@ describe Admin::DashboardController do
|
||||
end
|
||||
|
||||
it 'does not return discourse version info' do
|
||||
xhr :get, :index
|
||||
get :index, format: :json
|
||||
json = JSON.parse(response.body)
|
||||
expect(json['version_check']).not_to be_present
|
||||
end
|
||||
@ -46,19 +42,15 @@ describe Admin::DashboardController do
|
||||
end
|
||||
|
||||
context '.problems' do
|
||||
it 'should be successful' do
|
||||
AdminDashboardData.stubs(:fetch_problems).returns([])
|
||||
xhr :get, :problems
|
||||
expect(response).to be_successful
|
||||
end
|
||||
|
||||
context 'when there are no problems' do
|
||||
before do
|
||||
AdminDashboardData.stubs(:fetch_problems).returns([])
|
||||
end
|
||||
|
||||
it 'returns an empty array' do
|
||||
xhr :get, :problems
|
||||
get :problems, format: :json
|
||||
|
||||
expect(response).to be_success
|
||||
json = JSON.parse(response.body)
|
||||
expect(json['problems'].size).to eq(0)
|
||||
end
|
||||
@ -70,7 +62,7 @@ describe Admin::DashboardController do
|
||||
end
|
||||
|
||||
it 'returns an array of strings' do
|
||||
xhr :get, :problems
|
||||
get :problems, format: :json
|
||||
json = JSON.parse(response.body)
|
||||
expect(json['problems'].size).to eq(2)
|
||||
expect(json['problems'][0]).to be_a(String)
|
||||
|
Reference in New Issue
Block a user