Skip to content

Commit ce8aa22

Browse files
committed
Rubocop fixes
1 parent 5a18c03 commit ce8aa22

File tree

3 files changed

+15
-11
lines changed

3 files changed

+15
-11
lines changed

app/controllers/better_together/conversations_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ def conversation_params
228228

229229
# Ensure participant_ids only include people the agent is allowed to message.
230230
# If none remain, keep it empty; creator is always added after create.
231-
def conversation_params_filtered # rubocop:todo Metrics/AbcSize
231+
def conversation_params_filtered # rubocop:todo Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity
232232
permitted = ConversationPolicy.new(helpers.current_user, Conversation.new).permitted_participants
233233
permitted_ids = permitted.pluck(:id)
234234
# Always allow the current person (creator/participant) to appear in the list

app/models/better_together/message.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class Message < ApplicationRecord
1515
# Attributes permitted for strong parameters
1616
def self.permitted_attributes
1717
# include id and _destroy for nested attributes handling
18-
%i[id content _destroy]
18+
%i[id content _destroy]
1919
end
2020
# def content
2121
# super || self[:content]

spec/requests/better_together/conversation_message_protection_spec.rb

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,22 @@
22

33
require 'rails_helper'
44

5-
RSpec.describe 'Conversation message protection', type: :request do
5+
RSpec.describe 'Conversation message protection' do
66
include RequestSpecHelper
77

8+
# rubocop:todo RSpec/ExampleLength
9+
# rubocop:todo RSpec/MultipleExpectations
810
it "prevents a user from altering another user's message via conversation update" do
9-
# Setup: ensure host platform exists and create users with known passwords
10-
configure_host_platform
11-
11+
# rubocop:enable RSpec/MultipleExpectations
12+
# Setup: ensure host platform exists and create users with known passwords
13+
configure_host_platform
14+
1215
# Setup: create a manager user (owner of the conversation) and another user
13-
manager_user = create(:user, :confirmed, :platform_manager, email: '[email protected]', password: 'password12345')
14-
other_user = create(:user, :confirmed, email: '[email protected]', password: 'password12345')
16+
manager_user = create(:user, :confirmed, :platform_manager, email: '[email protected]', password: 'password12345')
17+
other_user = create(:user, :confirmed, email: '[email protected]', password: 'password12345')
1518

1619
# Create a conversation as the manager with a nested message
17-
login(manager_user.email, 'password12345')
20+
login(manager_user.email, 'password12345')
1821

1922
post better_together.conversations_path(locale: I18n.default_locale), params: {
2023
conversation: {
@@ -32,8 +35,8 @@
3235
expect(message.content.to_plain_text).to include('Original message')
3336

3437
# Now sign in as other_user and attempt to change manager's message via PATCH
35-
logout
36-
login(other_user.email, 'password12345')
38+
logout
39+
login(other_user.email, 'password12345')
3740

3841
patch better_together.conversation_path(conversation, locale: I18n.default_locale), params: {
3942
conversation: {
@@ -48,4 +51,5 @@
4851
message.reload
4952
expect(message.content.to_plain_text).to include('Original message')
5053
end
54+
# rubocop:enable RSpec/ExampleLength
5155
end

0 commit comments

Comments
 (0)