|
6 | 6 | let(:user) { Fabricate(:user, account: Fabricate(:account, username: 'alice')) } |
7 | 7 | let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: scopes) } |
8 | 8 | let(:other) { Fabricate(:user, account: Fabricate(:account, username: 'bob')) } |
| 9 | + let(:third) { Fabricate(:user, account: Fabricate(:account, username: 'carol')) } |
9 | 10 |
|
10 | 11 | before do |
11 | 12 | allow(controller).to receive(:doorkeeper_token) { token } |
|
55 | 56 | mentioning_status = PostStatusService.new.call(other.account, text: 'Hello @alice') |
56 | 57 | @mention_from_status = mentioning_status.mentions.first |
57 | 58 | @favourite = FavouriteService.new.call(other.account, first_status) |
| 59 | + @second_favourite = FavouriteService.new.call(third.account, first_status) |
58 | 60 | @follow = FollowService.new.call(other.account, 'alice') |
59 | 61 | end |
60 | 62 |
|
|
84 | 86 | end |
85 | 87 | end |
86 | 88 |
|
| 89 | + describe 'from specified user' do |
| 90 | + before do |
| 91 | + get :index, params: { account_id: third.account.id } |
| 92 | + end |
| 93 | + |
| 94 | + it 'returns http success' do |
| 95 | + expect(response).to have_http_status(200) |
| 96 | + end |
| 97 | + |
| 98 | + it 'includes favourite' do |
| 99 | + expect(assigns(:notifications).map(&:activity)).to include(@second_favourite) |
| 100 | + end |
| 101 | + |
| 102 | + it 'excludes favourite' do |
| 103 | + expect(assigns(:notifications).map(&:activity)).to_not include(@favourite) |
| 104 | + end |
| 105 | + |
| 106 | + it 'excludes mention' do |
| 107 | + expect(assigns(:notifications).map(&:activity)).to_not include(@mention_from_status) |
| 108 | + end |
| 109 | + |
| 110 | + it 'excludes reblog' do |
| 111 | + expect(assigns(:notifications).map(&:activity)).to_not include(@reblog_of_first_status) |
| 112 | + end |
| 113 | + |
| 114 | + it 'excludes follow' do |
| 115 | + expect(assigns(:notifications).map(&:activity)).to_not include(@follow) |
| 116 | + end |
| 117 | + end |
| 118 | + |
| 119 | + describe 'from nonexistent user' do |
| 120 | + before do |
| 121 | + get :index, params: { account_id: 'foo' } |
| 122 | + end |
| 123 | + |
| 124 | + it 'returns http success' do |
| 125 | + expect(response).to have_http_status(200) |
| 126 | + end |
| 127 | + |
| 128 | + it 'excludes favourite' do |
| 129 | + expect(assigns(:notifications).map(&:activity)).to_not include(@favourite) |
| 130 | + end |
| 131 | + |
| 132 | + it 'excludes second favourite' do |
| 133 | + expect(assigns(:notifications).map(&:activity)).to_not include(@second_favourite) |
| 134 | + end |
| 135 | + |
| 136 | + it 'excludes mention' do |
| 137 | + expect(assigns(:notifications).map(&:activity)).to_not include(@mention_from_status) |
| 138 | + end |
| 139 | + |
| 140 | + it 'excludes reblog' do |
| 141 | + expect(assigns(:notifications).map(&:activity)).to_not include(@reblog_of_first_status) |
| 142 | + end |
| 143 | + |
| 144 | + it 'excludes follow' do |
| 145 | + expect(assigns(:notifications).map(&:activity)).to_not include(@follow) |
| 146 | + end |
| 147 | + end |
| 148 | + |
87 | 149 | describe 'with excluded mentions' do |
88 | 150 | before do |
89 | 151 | get :index, params: { exclude_types: ['mention'] } |
|
105 | 167 | expect(assigns(:notifications).map(&:activity)).to include(@favourite) |
106 | 168 | end |
107 | 169 |
|
| 170 | + it 'includes third favourite' do |
| 171 | + expect(assigns(:notifications).map(&:activity)).to include(@second_favourite) |
| 172 | + end |
| 173 | + |
108 | 174 | it 'includes follow' do |
109 | 175 | expect(assigns(:notifications).map(&:activity)).to include(@follow) |
110 | 176 | end |
|
0 commit comments