discourse/spec/requests/steps_controller_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

56 lines
1.4 KiB
Ruby
Raw Normal View History

# frozen_string_literal: true
RSpec.describe StepsController do
before do
SiteSetting.wizard_enabled = true
end
2016-08-26 01:14:56 +08:00
it 'needs you to be logged in' do
put "/wizard/steps/made-up-id.json", params: {
fields: { forum_title: "updated title" }
}
expect(response.status).to eq(403)
2016-08-26 01:14:56 +08:00
end
it "raises an error if you aren't an admin" do
sign_in(Fabricate(:moderator))
put "/wizard/steps/made-up-id.json", params: {
fields: { forum_title: "updated title" }
}
2016-08-26 01:14:56 +08:00
expect(response).to be_forbidden
end
context "as an admin" do
before do
sign_in(Fabricate(:admin))
2016-08-26 01:14:56 +08:00
end
it "raises an error if the wizard is disabled" do
SiteSetting.wizard_enabled = false
put "/wizard/steps/introduction.json", params: {
fields: { contact_email: "eviltrout@example.com" }
}
expect(response).to be_forbidden
end
2016-08-26 01:14:56 +08:00
it "updates properly if you are staff" do
put "/wizard/steps/introduction.json", params: {
fields: { title: "FooBar", default_locale: SiteSetting.default_locale, contact_email: "eviltrout@example.com" }
}
expect(response.status).to eq(200)
expect(SiteSetting.contact_email).to eq("eviltrout@example.com")
end
it "returns errors if the field has them" do
put "/wizard/steps/introduction.json", params: {
fields: { contact_email: "not-an-email" }
}
expect(response.status).to eq(422)
2016-08-26 01:14:56 +08:00
end
end
end