|
|
@ -70,23 +70,23 @@ RSpec.describe Api::V1::NotificationsController, type: :controller do
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
it 'includes reblog' do
|
|
|
|
it 'includes reblog' do
|
|
|
|
expect(assigns(:notifications).map(&:activity)).to include(@reblog_of_first_status)
|
|
|
|
expect(body_as_json.map { |x| x[:type] }).to include 'reblog'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
it 'includes mention' do
|
|
|
|
it 'includes mention' do
|
|
|
|
expect(assigns(:notifications).map(&:activity)).to include(@mention_from_status)
|
|
|
|
expect(body_as_json.map { |x| x[:type] }).to include 'mention'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
it 'includes favourite' do
|
|
|
|
it 'includes favourite' do
|
|
|
|
expect(assigns(:notifications).map(&:activity)).to include(@favourite)
|
|
|
|
expect(body_as_json.map { |x| x[:type] }).to include 'favourite'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
it 'includes follow' do
|
|
|
|
it 'includes follow' do
|
|
|
|
expect(assigns(:notifications).map(&:activity)).to include(@follow)
|
|
|
|
expect(body_as_json.map { |x| x[:type] }).to include 'follow'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
describe 'from specified user' do
|
|
|
|
describe 'with account_id param' do
|
|
|
|
before do
|
|
|
|
before do
|
|
|
|
get :index, params: { account_id: third.account.id }
|
|
|
|
get :index, params: { account_id: third.account.id }
|
|
|
|
end
|
|
|
|
end
|
|
|
@ -95,28 +95,12 @@ RSpec.describe Api::V1::NotificationsController, type: :controller do
|
|
|
|
expect(response).to have_http_status(200)
|
|
|
|
expect(response).to have_http_status(200)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
it 'includes favourite' do
|
|
|
|
it 'returns only notifications from specified user' do
|
|
|
|
expect(assigns(:notifications).map(&:activity)).to include(@second_favourite)
|
|
|
|
expect(body_as_json.map { |x| x[:account][:id] }.uniq).to eq [third.account.id.to_s]
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it 'excludes favourite' do
|
|
|
|
|
|
|
|
expect(assigns(:notifications).map(&:activity)).to_not include(@favourite)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it 'excludes mention' do
|
|
|
|
|
|
|
|
expect(assigns(:notifications).map(&:activity)).to_not include(@mention_from_status)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it 'excludes reblog' do
|
|
|
|
|
|
|
|
expect(assigns(:notifications).map(&:activity)).to_not include(@reblog_of_first_status)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it 'excludes follow' do
|
|
|
|
|
|
|
|
expect(assigns(:notifications).map(&:activity)).to_not include(@follow)
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
describe 'from nonexistent user' do
|
|
|
|
describe 'with invalid account_id param' do
|
|
|
|
before do
|
|
|
|
before do
|
|
|
|
get :index, params: { account_id: 'foo' }
|
|
|
|
get :index, params: { account_id: 'foo' }
|
|
|
|
end
|
|
|
|
end
|
|
|
@ -125,54 +109,37 @@ RSpec.describe Api::V1::NotificationsController, type: :controller do
|
|
|
|
expect(response).to have_http_status(200)
|
|
|
|
expect(response).to have_http_status(200)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
it 'excludes favourite' do
|
|
|
|
it 'returns nothing' do
|
|
|
|
expect(assigns(:notifications).map(&:activity)).to_not include(@favourite)
|
|
|
|
expect(body_as_json.size).to eq 0
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it 'excludes second favourite' do
|
|
|
|
|
|
|
|
expect(assigns(:notifications).map(&:activity)).to_not include(@second_favourite)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it 'excludes mention' do
|
|
|
|
|
|
|
|
expect(assigns(:notifications).map(&:activity)).to_not include(@mention_from_status)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it 'excludes reblog' do
|
|
|
|
|
|
|
|
expect(assigns(:notifications).map(&:activity)).to_not include(@reblog_of_first_status)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it 'excludes follow' do
|
|
|
|
|
|
|
|
expect(assigns(:notifications).map(&:activity)).to_not include(@follow)
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
describe 'with excluded mentions' do
|
|
|
|
describe 'with excluded_types param' do
|
|
|
|
before do
|
|
|
|
before do
|
|
|
|
get :index, params: { exclude_types: ['mention'] }
|
|
|
|
get :index, params: { exclude_types: %w(mention) }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
it 'returns http success' do
|
|
|
|
it 'returns http success' do
|
|
|
|
expect(response).to have_http_status(200)
|
|
|
|
expect(response).to have_http_status(200)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
it 'includes reblog' do
|
|
|
|
it 'returns everything but excluded type' do
|
|
|
|
expect(assigns(:notifications).map(&:activity)).to include(@reblog_of_first_status)
|
|
|
|
expect(body_as_json.size).to_not eq 0
|
|
|
|
end
|
|
|
|
expect(body_as_json.map { |x| x[:type] }.uniq).to_not include 'mention'
|
|
|
|
|
|
|
|
|
|
|
|
it 'excludes mention' do
|
|
|
|
|
|
|
|
expect(assigns(:notifications).map(&:activity)).to_not include(@mention_from_status)
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
it 'includes favourite' do
|
|
|
|
describe 'with types param' do
|
|
|
|
expect(assigns(:notifications).map(&:activity)).to include(@favourite)
|
|
|
|
before do
|
|
|
|
|
|
|
|
get :index, params: { types: %w(mention) }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
it 'includes third favourite' do
|
|
|
|
it 'returns http success' do
|
|
|
|
expect(assigns(:notifications).map(&:activity)).to include(@second_favourite)
|
|
|
|
expect(response).to have_http_status(200)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
it 'includes follow' do
|
|
|
|
it 'returns only requested type' do
|
|
|
|
expect(assigns(:notifications).map(&:activity)).to include(@follow)
|
|
|
|
expect(body_as_json.map { |x| x[:type] }.uniq).to eq ['mention']
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|