mirror of
https://github.com/discourse/discourse.git
synced 2025-05-25 00:32:52 +08:00
Fix all the errors to get our tests green on Rails 5.1.
This commit is contained in:
@ -10,7 +10,7 @@ describe Admin::ApiController do
|
||||
|
||||
context '.index' do
|
||||
it "succeeds" do
|
||||
xhr :get, :index
|
||||
get :index, format: :json
|
||||
expect(response).to be_success
|
||||
end
|
||||
end
|
||||
@ -19,14 +19,14 @@ describe Admin::ApiController do
|
||||
let(:api_key) { Fabricate(:api_key) }
|
||||
|
||||
it "returns 404 when there is no key" do
|
||||
xhr :put, :regenerate_key, id: 1234
|
||||
put :regenerate_key, params: { id: 1234 }, format: :json
|
||||
expect(response).not_to be_success
|
||||
expect(response.status).to eq(404)
|
||||
end
|
||||
|
||||
it "delegates to the api key's `regenerate!` method" do
|
||||
ApiKey.any_instance.expects(:regenerate!)
|
||||
xhr :put, :regenerate_key, id: api_key.id
|
||||
put :regenerate_key, params: { id: api_key.id }, format: :json
|
||||
end
|
||||
end
|
||||
|
||||
@ -34,22 +34,22 @@ describe Admin::ApiController do
|
||||
let(:api_key) { Fabricate(:api_key) }
|
||||
|
||||
it "returns 404 when there is no key" do
|
||||
xhr :delete, :revoke_key, id: 1234
|
||||
delete :revoke_key, params: { id: 1234 }, format: :json
|
||||
expect(response).not_to be_success
|
||||
expect(response.status).to eq(404)
|
||||
end
|
||||
|
||||
it "delegates to the api key's `regenerate!` method" do
|
||||
ApiKey.any_instance.expects(:destroy)
|
||||
xhr :delete, :revoke_key, id: api_key.id
|
||||
delete :revoke_key, params: { id: api_key.id }, format: :json
|
||||
end
|
||||
end
|
||||
|
||||
context '.create_master_key' do
|
||||
it "creates a record" do
|
||||
expect {
|
||||
xhr :post, :create_master_key
|
||||
}.to change(ApiKey, :count).by(1)
|
||||
expect do
|
||||
post :create_master_key, format: :json
|
||||
end.to change(ApiKey, :count).by(1)
|
||||
end
|
||||
end
|
||||
|
||||
|
Reference in New Issue
Block a user