* Rubocop fixes in spec/requests * Fixed spec/requests/api/v0/articles_spec.rb Co-authored-by: Ridhwana <Ridhwana.Khan16@gmail.com> Co-authored-by: Ridhwana <Ridhwana.Khan16@gmail.com>
78 lines
2 KiB
Ruby
78 lines
2 KiB
Ruby
require "rails_helper"
|
|
|
|
RSpec.describe "/admin/advanced/tools/feed_playground" do
|
|
describe "GET /admin/advanced/tools/feed_playground" do
|
|
context "when the user is not an admin" do
|
|
let(:user) { create(:user) }
|
|
|
|
before do
|
|
sign_in user
|
|
end
|
|
|
|
it "blocks the request" do
|
|
expect do
|
|
get feed_playground_admin_tools_path
|
|
end.to raise_error(Pundit::NotAuthorizedError)
|
|
end
|
|
end
|
|
|
|
context "when the user is a super admin" do
|
|
let(:super_admin) { create(:user, :super_admin) }
|
|
|
|
before do
|
|
sign_in super_admin
|
|
get feed_playground_admin_tools_path
|
|
end
|
|
|
|
it "allows the request" do
|
|
expect(response).to have_http_status(:ok)
|
|
end
|
|
end
|
|
|
|
context "when the user is a single resource admin" do
|
|
let(:single_resource_admin) { create(:user, :single_resource_admin, resource: Tool) }
|
|
|
|
before do
|
|
sign_in single_resource_admin
|
|
get feed_playground_admin_tools_path
|
|
end
|
|
|
|
it "allows the request" do
|
|
expect(response).to have_http_status(:ok)
|
|
end
|
|
end
|
|
|
|
context "when the user is the wrong single resource admin" do
|
|
let(:single_resource_admin) { create(:user, :single_resource_admin, resource: Article) }
|
|
|
|
before do
|
|
sign_in single_resource_admin
|
|
end
|
|
|
|
it "blocks the request" do
|
|
expect do
|
|
get feed_playground_admin_tools_path
|
|
end.to raise_error(Pundit::NotAuthorizedError)
|
|
end
|
|
end
|
|
end
|
|
|
|
describe "POST /admin/advanced/tools/feed_playground" do
|
|
context "when the user is a super admin" do
|
|
let(:super_admin) { create(:user, :super_admin) }
|
|
|
|
before do
|
|
sign_in super_admin
|
|
post feed_playground_admin_tools_path, params: { config: "sddsdsdsdsds" }
|
|
end
|
|
|
|
it "allows the request" do
|
|
expect(response).to have_http_status(:ok)
|
|
end
|
|
|
|
it "shows proper error" do
|
|
expect(response.body).to include("unexpected token at")
|
|
end
|
|
end
|
|
end
|
|
end
|