2019-04-30 08:27:42 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2022-07-28 10:27:38 +08:00
|
|
|
RSpec.describe StepsController do
|
2016-09-15 04:36:08 +08:00
|
|
|
before { SiteSetting.wizard_enabled = true }
|
|
|
|
|
2016-08-26 01:14:56 +08:00
|
|
|
it "needs you to be logged in" do
|
2018-06-06 17:49:43 +08:00
|
|
|
put "/wizard/steps/made-up-id.json", params: { fields: { forum_title: "updated title" } }
|
2018-01-12 11:15:10 +08:00
|
|
|
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
|
2018-06-06 17:49:43 +08:00
|
|
|
sign_in(Fabricate(:moderator))
|
2017-08-31 12:06:56 +08:00
|
|
|
|
2018-06-06 17:49:43 +08:00
|
|
|
put "/wizard/steps/made-up-id.json", params: { fields: { forum_title: "updated title" } }
|
2017-08-31 12:06:56 +08:00
|
|
|
|
2016-08-26 01:14:56 +08:00
|
|
|
expect(response).to be_forbidden
|
|
|
|
end
|
|
|
|
|
|
|
|
context "as an admin" do
|
2018-06-06 17:49:43 +08:00
|
|
|
before { sign_in(Fabricate(:admin)) }
|
2016-08-26 01:14:56 +08:00
|
|
|
|
2016-09-15 04:36:08 +08:00
|
|
|
it "raises an error if the wizard is disabled" do
|
|
|
|
SiteSetting.wizard_enabled = false
|
2022-07-27 09:23:01 +08:00
|
|
|
put "/wizard/steps/introduction.json",
|
|
|
|
params: {
|
2018-06-06 17:49:43 +08:00
|
|
|
fields: {
|
|
|
|
contact_email: "eviltrout@example.com",
|
|
|
|
},
|
|
|
|
}
|
2016-09-15 04:36:08 +08:00
|
|
|
expect(response).to be_forbidden
|
|
|
|
end
|
|
|
|
|
2016-08-26 01:14:56 +08:00
|
|
|
it "updates properly if you are staff" do
|
2022-07-27 09:23:01 +08:00
|
|
|
put "/wizard/steps/introduction.json",
|
|
|
|
params: {
|
2022-12-20 08:24:09 +08:00
|
|
|
fields: {
|
|
|
|
title: "FooBar",
|
|
|
|
default_locale: SiteSetting.default_locale,
|
|
|
|
},
|
2018-06-06 17:49:43 +08:00
|
|
|
}
|
2017-08-31 12:06:56 +08:00
|
|
|
|
2018-06-07 16:11:09 +08:00
|
|
|
expect(response.status).to eq(200)
|
2016-09-01 01:35:49 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
it "returns errors if the field has them" do
|
2022-07-27 09:23:01 +08:00
|
|
|
put "/wizard/steps/introduction.json", params: { fields: { title: "" } }
|
2017-08-31 12:06:56 +08:00
|
|
|
|
2018-06-06 17:49:43 +08:00
|
|
|
expect(response.status).to eq(422)
|
2016-08-26 01:14:56 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|