docbrown/spec/requests/image_uploads_spec.rb
Mac Siri 0f35939906 Update chat app's features (#204)
* Update chat.scss --skip-ci

* Fix height issue

* Add highlighting

* Implement bannged user handling for chat

* Add scroll obsever

* Limit initial messages load count & max messages

* Add new message alert when scrolled

* Add link to usernames in chat

* Implement channel clearing feature

* Update parserOptions

* Implement banning feature for chat app WIP

* Add policy for ChatChannelsController

* Fix arugment error

* Update user_not_authorized to handle JSON request

* Update specs for updated user_not_authorized

* Update font-weight for windows os
2018-04-16 13:20:12 -07:00

38 lines
1.4 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 "redirects to /enter" 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