discourse/spec/controllers/steps_controller_spec.rb

36 lines
941 B
Ruby
Raw Normal View History

2016-08-25 12:14:56 -05:00
require 'rails_helper'
describe StepsController do
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
log_in
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
it "updates properly if you are staff" do
xhr :put, :update, id: 'contact', fields: { contact_email: "eviltrout@example.com" }
2016-08-25 12:14:56 -05:00
expect(response).to be_success
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 12:14:56 -05:00
end
end
end