2016-08-25 13:14:56 -04:00
|
|
|
require 'rails_helper'
|
|
|
|
|
|
|
|
describe StepsController do
|
|
|
|
|
2016-09-14 16:36:08 -04:00
|
|
|
before do
|
|
|
|
SiteSetting.wizard_enabled = true
|
|
|
|
end
|
|
|
|
|
2016-08-25 13:14:56 -04:00
|
|
|
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)
|
|
|
|
end
|
|
|
|
|
|
|
|
it "raises an error if you aren't an admin" do
|
2016-09-22 11:12:34 -04:00
|
|
|
log_in(:moderator)
|
2016-08-25 13:14:56 -04:00
|
|
|
xhr :put, :update, id: 'made-up-id', fields: { forum_title: "updated title" }
|
|
|
|
expect(response).to be_forbidden
|
|
|
|
end
|
|
|
|
|
|
|
|
context "as an admin" do
|
|
|
|
before do
|
|
|
|
log_in(:admin)
|
|
|
|
end
|
|
|
|
|
2016-09-14 16:36:08 -04:00
|
|
|
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" }
|
|
|
|
expect(response).to be_forbidden
|
|
|
|
end
|
|
|
|
|
2016-08-25 13:14:56 -04:00
|
|
|
it "updates properly if you are staff" do
|
2016-08-31 13:35:49 -04:00
|
|
|
xhr :put, :update, id: 'contact', fields: { contact_email: "eviltrout@example.com" }
|
2016-08-25 13:14:56 -04:00
|
|
|
expect(response).to be_success
|
2016-08-31 13:35:49 -04:00
|
|
|
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" }
|
|
|
|
expect(response).to_not be_success
|
2016-08-25 13:14:56 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|