|
2 | 2 |
|
3 | 3 | require 'rails_helper' |
4 | 4 |
|
5 | | -RSpec.describe 'Conversation message protection', type: :request do |
| 5 | +RSpec.describe 'Conversation message protection' do |
6 | 6 | include RequestSpecHelper |
7 | 7 |
|
| 8 | + # rubocop:todo RSpec/ExampleLength |
| 9 | + # rubocop:todo RSpec/MultipleExpectations |
8 | 10 | 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 | + |
12 | 15 | # 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') |
15 | 18 |
|
16 | 19 | # Create a conversation as the manager with a nested message |
17 | | - login(manager_user.email, 'password12345') |
| 20 | + login(manager_user.email, 'password12345') |
18 | 21 |
|
19 | 22 | post better_together.conversations_path(locale: I18n.default_locale), params: { |
20 | 23 | conversation: { |
|
32 | 35 | expect(message.content.to_plain_text).to include('Original message') |
33 | 36 |
|
34 | 37 | # 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') |
37 | 40 |
|
38 | 41 | patch better_together.conversation_path(conversation, locale: I18n.default_locale), params: { |
39 | 42 | conversation: { |
|
48 | 51 | message.reload |
49 | 52 | expect(message.content.to_plain_text).to include('Original message') |
50 | 53 | end |
| 54 | + # rubocop:enable RSpec/ExampleLength |
51 | 55 | end |
0 commit comments