discourse/spec/controllers/request_access_controller_spec.rb

57 lines
1.1 KiB
Ruby
Raw Normal View History

2013-02-06 03:16:51 +08:00
require 'spec_helper'
describe RequestAccessController do
context '.new' do
it "sets a default return path" do
get :new
assigns(:return_path).should == "/"
end
it "assigns the return path we provide" do
get :new, return_path: '/asdf'
assigns(:return_path).should == "/asdf"
2013-02-26 00:42:20 +08:00
end
2013-02-06 03:16:51 +08:00
end
context '.create' do
context 'without an invalid password' do
before do
post :create, password: 'asdf'
end
it "adds a flash" do
flash[:error].should be_present
end
it "doesn't set the cookie" do
cookies[:_access].should be_blank
end
end
context 'with a valid password' do
before do
SiteSetting.stubs(:access_password).returns 'test password'
post :create, password: 'test password', return_path: '/the-path'
end
it 'creates the cookie' do
cookies[:_access].should == 'test password'
end
it 'redirects to the return path' do
response.should redirect_to('/the-path')
2013-02-26 00:42:20 +08:00
end
2013-02-06 03:16:51 +08:00
it 'sets no flash error' do
flash[:error].should be_blank
end
end
end
end