mirror of
https://github.com/discourse/discourse.git
synced 2025-03-06 11:19:51 +00:00
Merge branch 'wizard-controller' of https://github.com/OsamaSayegh/discourse into OsamaSayegh-wizard-controller
This commit is contained in:
commit
47ddb3a7ca
@ -1,51 +1,47 @@
|
|||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
describe WizardController do
|
describe WizardController do
|
||||||
|
|
||||||
context 'wizard enabled' do
|
context 'wizard enabled' do
|
||||||
render_views
|
|
||||||
|
|
||||||
before do
|
before do
|
||||||
SiteSetting.wizard_enabled = true
|
SiteSetting.wizard_enabled = true
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'needs you to be logged in' do
|
it 'needs you to be logged in' do
|
||||||
get :index, format: :json
|
get "/wizard.json"
|
||||||
expect(response.status).to eq(403)
|
expect(response.status).to eq(403)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'needs you to be logged in' do
|
it 'needs you to be logged in' do
|
||||||
get :index
|
get "/wizard"
|
||||||
# for whatever reason, no access is 404
|
# for whatever reason, no access is 404
|
||||||
# we may want to revisit this at some point and make it 403
|
# we may want to revisit this at some point and make it 403
|
||||||
expect(response.status).to eq(404)
|
expect(response.status).to eq(404)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "raises an error if you aren't an admin" do
|
it "raises an error if you aren't an admin" do
|
||||||
log_in(:moderator)
|
sign_in(Fabricate(:moderator))
|
||||||
get :index, format: :json
|
get "/wizard.json"
|
||||||
expect(response).to be_forbidden
|
expect(response).to be_forbidden
|
||||||
end
|
end
|
||||||
|
|
||||||
it "raises an error if the wizard is disabled" do
|
it "raises an error if the wizard is disabled" do
|
||||||
SiteSetting.wizard_enabled = false
|
SiteSetting.wizard_enabled = false
|
||||||
log_in(:admin)
|
sign_in(Fabricate(:admin))
|
||||||
get :index, format: :json
|
get "/wizard.json"
|
||||||
expect(response).to be_forbidden
|
expect(response).to be_forbidden
|
||||||
end
|
end
|
||||||
|
|
||||||
it "renders the wizard if you are an admin" do
|
it "renders the wizard if you are an admin" do
|
||||||
log_in(:admin)
|
sign_in(Fabricate(:admin))
|
||||||
get :index, format: :json
|
get "/wizard.json"
|
||||||
expect(response).to be_successful
|
expect(response.status).to eq(200)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns JSON when the mime type is appropriate" do
|
it "returns JSON when the mime type is appropriate" do
|
||||||
log_in(:admin)
|
sign_in(Fabricate(:admin))
|
||||||
get :index, format: 'json'
|
get "/wizard.json"
|
||||||
expect(response).to be_successful
|
expect(response.status).to eq(200)
|
||||||
expect(::JSON.parse(response.body).has_key?('wizard')).to eq(true)
|
expect(::JSON.parse(response.body).has_key?('wizard')).to eq(true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
Loading…
x
Reference in New Issue
Block a user