|
|
@ -6,23 +6,18 @@ RSpec.describe Notification, type: :model do |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
describe '#target_status' do |
|
|
|
describe '#target_status' do |
|
|
|
before do |
|
|
|
let(:notification) { Fabricate(:notification, activity_type: type, activity: activity) } |
|
|
|
allow(notification).to receive(:type).and_return(type) |
|
|
|
let(:status) { Fabricate(:status) } |
|
|
|
allow(notification).to receive(:activity).and_return(activity) |
|
|
|
let(:reblog) { Fabricate(:status, reblog: status) } |
|
|
|
end |
|
|
|
let(:favourite) { Fabricate(:favourite, status: status) } |
|
|
|
|
|
|
|
let(:mention) { Fabricate(:mention, status: status) } |
|
|
|
let(:notification) { Fabricate(:notification) } |
|
|
|
|
|
|
|
let(:status) { instance_double('Status') } |
|
|
|
|
|
|
|
let(:favourite) { instance_double('Favourite') } |
|
|
|
|
|
|
|
let(:mention) { instance_double('Mention') } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
context 'type is :reblog' do |
|
|
|
context 'type is :reblog' do |
|
|
|
let(:type) { :reblog } |
|
|
|
let(:type) { :reblog } |
|
|
|
let(:activity) { status } |
|
|
|
let(:activity) { reblog } |
|
|
|
|
|
|
|
|
|
|
|
it 'calls activity.reblog' do |
|
|
|
it 'returns status' do |
|
|
|
expect(activity).to receive(:reblog) |
|
|
|
expect(notification.target_status).to eq status |
|
|
|
notification.target_status |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
@ -30,9 +25,8 @@ RSpec.describe Notification, type: :model do |
|
|
|
let(:type) { :favourite } |
|
|
|
let(:type) { :favourite } |
|
|
|
let(:activity) { favourite } |
|
|
|
let(:activity) { favourite } |
|
|
|
|
|
|
|
|
|
|
|
it 'calls activity.status' do |
|
|
|
it 'returns status' do |
|
|
|
expect(activity).to receive(:status) |
|
|
|
expect(notification.target_status).to eq status |
|
|
|
notification.target_status |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
@ -40,9 +34,8 @@ RSpec.describe Notification, type: :model do |
|
|
|
let(:type) { :mention } |
|
|
|
let(:type) { :mention } |
|
|
|
let(:activity) { mention } |
|
|
|
let(:activity) { mention } |
|
|
|
|
|
|
|
|
|
|
|
it 'calls activity.status' do |
|
|
|
it 'returns status' do |
|
|
|
expect(activity).to receive(:status) |
|
|
|
expect(notification.target_status).to eq status |
|
|
|
notification.target_status |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|