* Add comment for public controllers * Add block policy and specs * Add policy for authorizing dashboard * Add follow policy and specs * Refactor a tiny bit * Prevent banned users from following anything * Add a note for email sub controller about auth * Add image upload policies * Add policy for github repos * Fix typo and use correct github repo variable * Fix image uploader and use regular params * Add authenticate_user before action back in * Rename test * Update slack bot message formatting and fix reported URL
38 lines
1.3 KiB
Ruby
38 lines
1.3 KiB
Ruby
require "rails_helper"
|
|
|
|
RSpec.describe "ImageUploads", type: :request do
|
|
describe "POST/image_uploads" do
|
|
let(:user) { create(:user) }
|
|
let(:headers) { { "Content-Type": "application/json", Accept: "application/json" } }
|
|
|
|
context "when not logged-in" do
|
|
it "responds with 401" do
|
|
post "/image_uploads", headers: headers
|
|
expect(response).to have_http_status(401)
|
|
end
|
|
end
|
|
|
|
context "when logged-in" do
|
|
it "returns json" do
|
|
sign_in user
|
|
post "/image_uploads", headers: headers
|
|
expect(response.content_type).to eq("application/json")
|
|
end
|
|
|
|
it "provides a link" do
|
|
# this test is a little flimsy
|
|
sign_in user
|
|
image = Rack::Test::UploadedFile.new(File.join(Rails.root, "spec", "support", "fixtures", "images", "image1.jpeg"), "image/jpeg")
|
|
post "/image_uploads", headers: headers, params: { image: image }
|
|
expect(response.body).to match("\/i\/.+\.")
|
|
end
|
|
|
|
it "prevents image with resolutions larger than 4096x4096" do
|
|
sign_in user
|
|
image = Rack::Test::UploadedFile.new(File.join(Rails.root, "spec", "support", "fixtures", "images", "bad-image.jpg"), "image/jpeg")
|
|
expect { post("/image_uploads", headers: headers, params: { image: image }) }.
|
|
to raise_error(CarrierWave::IntegrityError)
|
|
end
|
|
end
|
|
end
|
|
end
|