* Feature 🚀 : Ability to delete messages in chat channels - Sending message ID to frontend - Deleting Message - Use pusher to delete message realtime * Minor Bug 🐞: Show message action only for current user - User can delete or edit their own messages * Test cases added * Bug 🐞: Update message id for receiver Message id was not sent to receiver by pusher * Refactoring🛠: Message controller refactoring * Test Cases📝 : Specs for Delete message added * Feature 🚀 : Ability to edit messages * Test Cases📝 : Specs for Edit message added * Move channel settings to sidecar * added spec for chat_channels_memberships_controller.rb (#6539) * added spec for chat_channels_memberships_controller.rb * simplified record not found error for membership * error message formatting updated * added error key in flash message Co-authored-by: jitendra <jitendrarajpurohit@skynox.tech> * Refining "Move sidecar to iframe" branch (#6634) * added spec for chat_channels_memberships_controller.rb * simplified record not found error for membership * error message formatting updated * added error key in flash message * 🐞 Bug Fix: Open sidecar of clicking @all * 🐞 Bug Fix: adding space after selecting the username from suggestion box * added remove channel member functionality for moderators * 🔩 Small Tweaks: Hover issue fixed * 🐞 Bug Fix: Remove sidecar toggle on @all tag (for now) * updated manually constructed urls with rails path helpers * mod users cannot remove members of other channel Co-authored-by: jitendra <jitendrarajpurohit@skynox.tech> * 🚀 Finalising the connect group/channel feature. (#6829) * added spec for chat_channels_memberships_controller.rb * simplified record not found error for membership * error message formatting updated * added error key in flash message * 🐞 Bug Fix: Open sidecar of clicking @all * 🐞 Bug Fix: adding space after selecting the username from suggestion box * added remove channel member functionality for moderators * 🔩 Small Tweaks: Hover issue fixed * 🐞 Bug Fix: Remove sidecar toggle on @all tag (for now) * updated manually constructed urls with rails path helpers * mod users cannot remove members of other channel * mod members can now invite user who have left the channel * 🐞 Bug Fix: Ability to open sidecar on mention all properly * Eslint Changes * send email notification on inviting user feature added * 🛠 Email design enhancements for channel invitation * send invitation to mod user added from internal * 🛠 Gif changes for Mod * spec fixed * inviter name issue fixed * 🚀 Open sidecar when automatically if you use link from email Co-authored-by: jitendra <jitendrarajpurohit@skynox.tech> * review changes * added spec for channel_invite_email * Bug🐞: Design problem with sidecar after merge * Bug🐞: Design problem with invitation alert box * replaced instance variables with local variable * Bug🐞: Wrong css classes fixed * Bug🐞: Edit option bug * yarn.lock file updated * code review changes * updated manually constructed urls with rails path helpers in spec * user name url issue fix in invite email * user url corrected Co-authored-by: Sarthak Sharma <7lovesharma7@gmail.com> Co-authored-by: benhalpern <bendhalpern@gmail.com>
59 lines
2.2 KiB
Ruby
59 lines
2.2 KiB
Ruby
require "rails_helper"
|
|
|
|
RSpec.describe ChatChannel, type: :model do
|
|
let(:chat_channel) { create(:chat_channel) }
|
|
|
|
let_it_be(:users) { create_list(:user, 2) }
|
|
|
|
it { is_expected.to have_many(:messages).dependent(:destroy) }
|
|
it { is_expected.to have_many(:chat_channel_memberships).dependent(:destroy) }
|
|
it { is_expected.to have_many(:users) }
|
|
it { is_expected.to validate_presence_of(:channel_type) }
|
|
|
|
describe "#clear_channel" do
|
|
before { allow(Pusher).to receive(:trigger) }
|
|
|
|
it "clears chat" do
|
|
create(:message, chat_channel: chat_channel, user: create(:user))
|
|
chat_channel.reload
|
|
expect(chat_channel.messages.size).to be_positive
|
|
chat_channel.clear_channel
|
|
expect(chat_channel.messages.size).to eq(0)
|
|
end
|
|
end
|
|
|
|
describe "#create_with_users" do
|
|
it "creates channel with users" do
|
|
chat_channel = described_class.create_with_users(users: users)
|
|
expect(chat_channel.users.size).to eq(users.size)
|
|
expect(chat_channel.has_member?(users.first)).to be(true)
|
|
expect(chat_channel.has_member?(users.last)).to be(true)
|
|
end
|
|
|
|
it "lists active memberships" do
|
|
chat_channel = described_class.create_with_users(users: users)
|
|
expect(chat_channel.active_users.size).to eq(users.size)
|
|
expect(chat_channel.channel_users.size).to eq(users.size)
|
|
end
|
|
end
|
|
|
|
describe "#active_users" do
|
|
it "decreases active users if one leaves" do
|
|
chat_channel = described_class.create_with_users(users: users)
|
|
expect(chat_channel.active_users.size).to eq(users.size)
|
|
expect(chat_channel.channel_users.size).to eq(users.size)
|
|
ChatChannelMembership.last.update(status: "left_channel")
|
|
expect(chat_channel.active_users.size).to eq(users.size - 1)
|
|
expect(chat_channel.channel_users.size).to eq(users.size - 1)
|
|
end
|
|
end
|
|
|
|
describe "#remove_user" do
|
|
it "removes a user from a channel" do
|
|
chat_channel.add_users(users.first)
|
|
expect(chat_channel.chat_channel_memberships.exists?(user_id: users.first.id)).to be(true)
|
|
chat_channel.remove_user(users.first)
|
|
expect(chat_channel.chat_channel_memberships.exists?(user_id: users.first.id)).to be(false)
|
|
end
|
|
end
|
|
end
|