Don't test XHR scenario as we don't have one anymore

private-asciicasts
Marcin Kulik 9 years ago
parent e05fbd574f
commit dbc18f9ce6

@ -41,46 +41,22 @@ describe FakesController do
end
describe "action raise unauthorized" do
context "when xhr" do
before { allow(request).to receive(:xhr?).and_return(true) }
it "redirects to login page" do
expect(@controller).to receive(:store_location)
it "responds with 401" do
get :foo
expect(response.status).to eq(401)
end
end
get :foo
context "when normal request" do
it "redirects to login page" do
expect(@controller).to receive(:store_location)
get :foo
expect(flash[:notice]).to eq("Please log in to proceed")
should redirect_to(new_login_path)
end
expect(flash[:notice]).to eq("Please log in to proceed")
should redirect_to(new_login_path)
end
end
context "when action raises Pundit::NotAuthorizedError" do
context "when xhr" do
before { allow(request).to receive(:xhr?).and_return(true) }
it "redirects to root_path" do
get :bar
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
expect(flash[:alert]).to_not be(nil)
should redirect_to(root_path)
end
expect(flash[:alert]).to_not be(nil)
should redirect_to(root_path)
end
end

Loading…
Cancel
Save