* Remove Connect
* Remove more Connect specs
* Remove a lot more Connect code
* 🚮
* It all has to go
* Explicitly add httpclient
* Update application layout
* Remove messages association from User
* Start fixing specs
* reintroduce util function and refactor references
* Remove Connect Cypress test
* Fix more specs
* Remove Connect from listings
* Ignore contact_via_connect column on listings
* Remove contact_via_connect usages
* Ignore mod_chat_channel_id on tags
* Drop Connect tables
* Remove email_connect_messages from user notification settings
* Re-add httpclient 2.8.3
This was mistakenly removed as a merge conflict
* Don't need to exclude removed chat channel file
* Remove unneeded style for chat channels
* Remove unneeded channel list prop type
* Remove chat channels index/connect-link from getPageEntries
* Re-add comment from httpclient in Gemfile
* Remove connect references from mailers
Tag Moderators no longer have a chat channel
No longer will users be notified about new messages (there won't be
any)
No longer will users be notified about channel invites (you can't
invite anyone anymore)
* Don't configure Pusher and remove PUSHER_* from .env_sample
since it's removed from gemfile, the Pusher constant will not resolve, if this is
configured in the environment variables we'll fail to boot.
Co-authored-by: Suzanne Aitchison <suzanne@forem.com>
Co-authored-by: Dan Uber <dan@forem.com>
90 lines
3.3 KiB
Ruby
90 lines
3.3 KiB
Ruby
require "rails_helper"
|
|
|
|
RSpec.describe "UserBlock", type: :request do
|
|
let(:blocker) { create(:user) }
|
|
let(:blocked) { create(:user) }
|
|
|
|
before { sign_in blocker }
|
|
|
|
describe "GET /user_blocks/:blocked_id or #show" do
|
|
it "rejects when not-logged-in" do
|
|
sign_out(blocker)
|
|
get "/user_blocks/#{blocked.id}"
|
|
expect(response.media_type).to eq "application/json"
|
|
expect(response.status).to eq 401
|
|
expect(response.parsed_body["result"]).to eq "not-logged-in"
|
|
end
|
|
|
|
it "returns 'not-blocking' when the user is not blocked" do
|
|
get "/user_blocks/#{blocked.id}"
|
|
expect(response.media_type).to eq "application/json"
|
|
expect(response.parsed_body["result"]).to eq "not-blocking"
|
|
end
|
|
|
|
it "returns 'blocking' when blocking" do
|
|
create(:user_block, blocker: blocker, blocked: blocked)
|
|
get "/user_blocks/#{blocked.id}"
|
|
expect(response.media_type).to eq "application/json"
|
|
expect(response.parsed_body["result"]).to eq "blocking"
|
|
end
|
|
end
|
|
|
|
describe "POST /user_blocks or #create" do
|
|
it "renders 'not-logged-in' when not logged in" do
|
|
sign_out blocker
|
|
post "/user_blocks", params: { user_block: { blocked_id: blocked.id } }
|
|
expect(response.media_type).to eq "application/json"
|
|
expect(response.status).to eq 401
|
|
expect(response.parsed_body["result"]).to eq "not-logged-in"
|
|
end
|
|
|
|
it "creates the correct user_block" do
|
|
post "/user_blocks", params: { user_block: { blocked_id: blocked.id } }
|
|
expect(UserBlock.count).to eq 1
|
|
expect(UserBlock.first.blocker_id).to eq blocker.id
|
|
expect(UserBlock.first.blocked_id).to eq blocked.id
|
|
end
|
|
|
|
it "returns a JSON response with blocked" do
|
|
post "/user_blocks", params: { user_block: { blocked_id: blocked.id } }
|
|
expect(response.media_type).to eq "application/json"
|
|
expect(response.parsed_body["result"]).to eq "blocked"
|
|
end
|
|
end
|
|
|
|
describe "DELETE /user_blocks/:blocked_id or #delete" do
|
|
before do
|
|
create(:user_block, blocker: blocker, blocked: blocked)
|
|
blocker.update(blocking_others_count: 1)
|
|
end
|
|
|
|
it "renders 'not-logged-in' when not logged in" do
|
|
sign_out blocker
|
|
delete "/user_blocks/#{blocked.id}", params: { user_block: { blocked_id: blocked.id } }
|
|
expect(response.media_type).to eq "application/json"
|
|
expect(response.status).to eq 401
|
|
expect(response.parsed_body["result"]).to eq "not-logged-in"
|
|
end
|
|
|
|
it "renders 'not-blocking-anyone' if there is no one to unblock" do
|
|
UserBlock.delete_all
|
|
blocker.update(blocking_others_count: 0)
|
|
delete "/user_blocks/#{blocked.id}", params: { user_block: { blocked_id: blocked.id } }
|
|
expect(response.media_type).to eq "application/json"
|
|
expect(response.parsed_body["result"]).to eq "not-blocking-anyone"
|
|
end
|
|
|
|
it "raises ActiveRecord::RecordNotFound error if UserBlock not found" do
|
|
missing_id = blocked.id
|
|
blocked.destroy
|
|
expect do
|
|
delete "/user_blocks/#{missing_id}", params: { user_block: { blocked_id: missing_id } }
|
|
end.to raise_error(ActiveRecord::RecordNotFound)
|
|
end
|
|
|
|
it "removes the correct user_block" do
|
|
delete "/user_blocks/#{blocked.id}", params: { user_block: { blocked_id: blocked.id } }
|
|
expect(blocker.blocking?(blocked)).to eq false
|
|
end
|
|
end
|
|
end
|