mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 20:54:31 +08:00
89ad2b5900
This updates tests to use latest rails 5 practice and updates ALL dependencies that could be updated Performance testing shows that performance has not regressed if anything it is marginally faster now.
58 lines
1.4 KiB
Ruby
58 lines
1.4 KiB
Ruby
require 'rails_helper'
|
|
|
|
describe StepsController do
|
|
|
|
before do
|
|
SiteSetting.wizard_enabled = true
|
|
end
|
|
|
|
it 'needs you to be logged in' do
|
|
put :update, params: {
|
|
id: 'made-up-id', fields: { forum_title: "updated title" }
|
|
}, format: :json
|
|
expect(response.status).to eq(403)
|
|
end
|
|
|
|
it "raises an error if you aren't an admin" do
|
|
log_in(:moderator)
|
|
|
|
put :update, params: {
|
|
id: 'made-up-id', fields: { forum_title: "updated title" }
|
|
}, format: :json
|
|
|
|
expect(response).to be_forbidden
|
|
end
|
|
|
|
context "as an admin" do
|
|
before do
|
|
log_in(:admin)
|
|
end
|
|
|
|
it "raises an error if the wizard is disabled" do
|
|
SiteSetting.wizard_enabled = false
|
|
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
|
|
put :update, params: {
|
|
id: 'contact', fields: { contact_email: "eviltrout@example.com" }
|
|
}, format: :json
|
|
|
|
expect(response).to be_successful
|
|
expect(SiteSetting.contact_email).to eq("eviltrout@example.com")
|
|
end
|
|
|
|
it "returns errors if the field has them" do
|
|
put :update, params: {
|
|
id: 'contact', fields: { contact_email: "not-an-email" }
|
|
}, format: :json
|
|
|
|
expect(response).to_not be_successful
|
|
end
|
|
end
|
|
|
|
end
|