mirror of
https://github.com/manyfold3d/manyfold.git
synced 2026-10-22 03:32:18 -05:00
test printer request permissions
This commit is contained in:
2 files changed
+35
No files matched your search
@@ -18,6 +18,10 @@ RSpec.describe "PrintHosts", :after_first_run do
|
||||
expect(response).to have_http_status(:forbidden)
|
||||
end
|
||||
|
||||
it "denies permission to people with print-only permissions", :as_printer do
|
||||
expect(response).to have_http_status(:forbidden)
|
||||
end
|
||||
|
||||
it "shows list to admins", :as_administrator do
|
||||
expect(response).to have_http_status(:success)
|
||||
end
|
||||
@@ -33,6 +37,10 @@ RSpec.describe "PrintHosts", :after_first_run do
|
||||
it "is denied to non-admins", :as_moderator do
|
||||
expect(response).to have_http_status(:forbidden)
|
||||
end
|
||||
|
||||
it "denies permission to people with print-only permissions", :as_printer do
|
||||
expect(response).to have_http_status(:forbidden)
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET /print_hosts/new" do
|
||||
@@ -45,6 +53,10 @@ RSpec.describe "PrintHosts", :after_first_run do
|
||||
it "is denied to non-admins", :as_moderator do
|
||||
expect(response).to have_http_status(:forbidden)
|
||||
end
|
||||
|
||||
it "denies permission to people with print-only permissions", :as_printer do
|
||||
expect(response).to have_http_status(:forbidden)
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET /print_hosts/:id/edit" do
|
||||
@@ -57,6 +69,10 @@ RSpec.describe "PrintHosts", :after_first_run do
|
||||
it "is denied to non-administrators", :as_moderator do
|
||||
expect(response).to have_http_status(:forbidden)
|
||||
end
|
||||
|
||||
it "denies permission to people with print-only permissions", :as_printer do
|
||||
expect(response).to have_http_status(:forbidden)
|
||||
end
|
||||
end
|
||||
|
||||
describe "PATCH /print_hosts/:id" do
|
||||
@@ -77,6 +93,10 @@ RSpec.describe "PrintHosts", :after_first_run do
|
||||
it "is denied to non-administrators", :as_moderator do
|
||||
expect(response).to have_http_status(:forbidden)
|
||||
end
|
||||
|
||||
it "denies permission to people with print-only permissions", :as_printer do
|
||||
expect(response).to have_http_status(:forbidden)
|
||||
end
|
||||
end
|
||||
|
||||
describe "DELETE /print_hosts/:id" do
|
||||
@@ -91,6 +111,10 @@ RSpec.describe "PrintHosts", :after_first_run do
|
||||
it "is denied to non-administrators", :as_moderator do
|
||||
expect(response).to have_http_status(:forbidden)
|
||||
end
|
||||
|
||||
it "denies permission to people with print-only permissions", :as_printer do
|
||||
expect(response).to have_http_status(:forbidden)
|
||||
end
|
||||
end
|
||||
|
||||
describe "POST /print_hosts/:id/print" do
|
||||
@@ -113,6 +137,12 @@ RSpec.describe "PrintHosts", :after_first_run do
|
||||
post "/print_hosts/#{print_host.to_param}/print", params: {file_id: file.public_id}
|
||||
expect(response).to have_http_status(:forbidden)
|
||||
end
|
||||
|
||||
it "accepts print requests from people with print-only permissions", :as_printer do
|
||||
expect {
|
||||
post "/print_hosts/#{print_host.to_param}/print", params: {file_id: file.public_id}
|
||||
}.to have_enqueued_job(SendFileToPrintHostJob).with(print_host: print_host, file: file)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -26,4 +26,9 @@ RSpec.configure do |config|
|
||||
@current_user = create(:user)
|
||||
sign_in @current_user
|
||||
end
|
||||
|
||||
config.before(:each, :as_printer) do
|
||||
@current_user = create(:printer)
|
||||
sign_in @current_user
|
||||
end
|
||||
end
|
||||
Reference in new issue
Block a user