|
5 | 5 | user = create(:user)
|
6 | 6 | post = create(:post, user:)
|
7 | 7 | other_user = create(:user)
|
8 |
| - comment = create(:comment, post:, user: other_user) |
| 8 | + create(:comment, post:, user: other_user) |
9 | 9 |
|
10 | 10 | login_as user
|
11 | 11 | visit notifications_path
|
12 | 12 |
|
13 | 13 | expect(Notification.count).to eq 1
|
14 | 14 | expect(page).to have_current_path notifications_path
|
15 |
| - expect(page).to have_content 'comentou em sua publicação' |
16 |
| - expect(page).to have_link comment.user.profile.full_name, href: profile_path(comment.user.profile) |
| 15 | + expect(page).to have_content "#{other_user.full_name} comentou em sua publicação: #{post.title}" |
17 | 16 | end
|
18 | 17 |
|
19 | 18 | it 'e não vê notificação de seu comentário' do
|
|
43 | 42 | end
|
44 | 43 |
|
45 | 44 | expect(page).to have_current_path notifications_path
|
46 |
| - expect(page).to have_content 'curtiu seu comentário' |
47 |
| - expect(page).to have_link like.user.profile.full_name, href: profile_path(like.user.profile) |
| 45 | + expect(page).to have_content "#{like.user.full_name} curtiu seu comentário" |
| 46 | + expect(Notification.last).to be_seen |
48 | 47 | end
|
49 | 48 |
|
50 | 49 | it 'e não recebe ao curtir seu próprio comentário' do
|
|
63 | 62 | expect(page).not_to have_content 'curtiu seu comentário'
|
64 | 63 | expect(page).not_to have_link like.user.profile.full_name, href: profile_path(like.user.profile)
|
65 | 64 | end
|
| 65 | + |
| 66 | + context 'ao clicar na notificação' do |
| 67 | + it 'de comentário é redirecionado para a página do post' do |
| 68 | + user = create(:user) |
| 69 | + post = create(:post, user:) |
| 70 | + comment = create(:comment, post:) |
| 71 | + |
| 72 | + login_as user |
| 73 | + visit notifications_path |
| 74 | + click_on comment.user.full_name |
| 75 | + |
| 76 | + expect(page).to have_current_path post_path(post) |
| 77 | + expect(page).to have_content post.title |
| 78 | + expect(page).to have_content comment.message |
| 79 | + expect(Notification.last).to be_clicked |
| 80 | + end |
| 81 | + |
| 82 | + it 'de curtida é redirecionado para a página do post' do |
| 83 | + user = create(:user) |
| 84 | + post = create(:post) |
| 85 | + comment = create(:comment, post:, user:) |
| 86 | + like = create(:like, likeable: comment) |
| 87 | + |
| 88 | + login_as user |
| 89 | + visit notifications_path |
| 90 | + click_on like.user.full_name |
| 91 | + |
| 92 | + expect(page).to have_current_path post_path(post) |
| 93 | + expect(page).to have_content post.title |
| 94 | + expect(page).to have_content comment.message |
| 95 | + expect(Notification.last).to be_clicked |
| 96 | + end |
| 97 | + end |
66 | 98 | end
|
0 commit comments