mirror of
https://github.com/discourse/discourse.git
synced 2025-05-23 11:12:40 +08:00
Fix all the errors to get our tests green on Rails 5.1.
This commit is contained in:
@ -7,14 +7,20 @@ describe StepsController do
|
||||
end
|
||||
|
||||
it 'needs you to be logged in' do
|
||||
expect {
|
||||
xhr :put, :update, id: 'made-up-id', fields: { forum_title: "updated title" }
|
||||
}.to raise_error(Discourse::NotLoggedIn)
|
||||
expect do
|
||||
put :update, params: {
|
||||
id: 'made-up-id', fields: { forum_title: "updated title" }
|
||||
}, format: :json
|
||||
end.to raise_error(Discourse::NotLoggedIn)
|
||||
end
|
||||
|
||||
it "raises an error if you aren't an admin" do
|
||||
log_in(:moderator)
|
||||
xhr :put, :update, id: 'made-up-id', fields: { forum_title: "updated title" }
|
||||
|
||||
put :update, params: {
|
||||
id: 'made-up-id', fields: { forum_title: "updated title" }
|
||||
}, format: :json
|
||||
|
||||
expect(response).to be_forbidden
|
||||
end
|
||||
|
||||
@ -25,18 +31,26 @@ describe StepsController do
|
||||
|
||||
it "raises an error if the wizard is disabled" do
|
||||
SiteSetting.wizard_enabled = false
|
||||
xhr :put, :update, id: 'contact', fields: { contact_email: "eviltrout@example.com" }
|
||||
put :update, params: {
|
||||
id: 'contact', fields: { contact_email: "eviltrout@example.com" }
|
||||
}, format: :json
|
||||
expect(response).to be_forbidden
|
||||
end
|
||||
|
||||
it "updates properly if you are staff" do
|
||||
xhr :put, :update, id: 'contact', fields: { contact_email: "eviltrout@example.com" }
|
||||
put :update, params: {
|
||||
id: 'contact', fields: { contact_email: "eviltrout@example.com" }
|
||||
}, format: :json
|
||||
|
||||
expect(response).to be_success
|
||||
expect(SiteSetting.contact_email).to eq("eviltrout@example.com")
|
||||
end
|
||||
|
||||
it "returns errors if the field has them" do
|
||||
xhr :put, :update, id: 'contact', fields: { contact_email: "not-an-email" }
|
||||
put :update, params: {
|
||||
id: 'contact', fields: { contact_email: "not-an-email" }
|
||||
}, format: :json
|
||||
|
||||
expect(response).to_not be_success
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user