|
|
|
@ -41,17 +41,6 @@ describe FakesController do
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
describe "action raise unauthorized" do
|
|
|
|
|
context "when xhr" do
|
|
|
|
|
before { allow(request).to receive(:xhr?).and_return(true) }
|
|
|
|
|
|
|
|
|
|
it "responds with 401" do
|
|
|
|
|
get :foo
|
|
|
|
|
|
|
|
|
|
expect(response.status).to eq(401)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
context "when normal request" do
|
|
|
|
|
it "redirects to login page" do
|
|
|
|
|
expect(@controller).to receive(:store_location)
|
|
|
|
|
|
|
|
|
@ -61,20 +50,8 @@ describe FakesController do
|
|
|
|
|
should redirect_to(new_login_path)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
context "when action raises Pundit::NotAuthorizedError" do
|
|
|
|
|
context "when xhr" do
|
|
|
|
|
before { allow(request).to receive(:xhr?).and_return(true) }
|
|
|
|
|
|
|
|
|
|
it "responds with 403" do
|
|
|
|
|
get :bar
|
|
|
|
|
|
|
|
|
|
expect(response.status).to eq(403)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
context "when normal request" do
|
|
|
|
|
it "redirects to root_path" do
|
|
|
|
|
get :bar
|
|
|
|
|
|
|
|
|
@ -82,7 +59,6 @@ describe FakesController do
|
|
|
|
|
should redirect_to(root_path)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
describe '#store_location / #get_stored_location' do
|
|
|
|
|
it 'stores current request path to be later retrieved' do
|
|
|
|
|