catstodon/spec/models/status_spec.rb

101 lines
2.4 KiB
Ruby
Raw Normal View History

2016-02-20 22:53:20 +01:00
require 'rails_helper'
RSpec.describe Status, type: :model do
2016-02-26 15:28:08 +01:00
let(:alice) { Fabricate(:account, username: 'alice') }
let(:bob) { Fabricate(:account, username: 'bob') }
let(:other) { Fabricate(:status, account: bob, text: 'Skulls for the skull god! The enemy\'s gates are sideways!')}
subject { Fabricate(:status, account: alice) }
2016-02-25 00:17:01 +01:00
describe '#local?' do
2016-02-26 15:28:08 +01:00
it 'returns true when no remote URI is set' do
expect(subject.local?).to be true
end
it 'returns false if a remote URI is set' do
subject.uri = 'a'
expect(subject.local?).to be false
end
2016-02-25 00:17:01 +01:00
end
describe '#reblog?' do
2016-02-26 15:28:08 +01:00
it 'returns true when the status reblogs another status' do
subject.reblog = other
expect(subject.reblog?).to be true
end
it 'returns false if the status is self-contained' do
expect(subject.reblog?).to be false
end
2016-02-25 00:17:01 +01:00
end
describe '#reply?' do
2016-02-26 15:28:08 +01:00
it 'returns true if the status references another' do
subject.thread = other
expect(subject.reply?).to be true
end
it 'returns false if the status is self-contained' do
expect(subject.reply?).to be false
end
2016-02-25 00:17:01 +01:00
end
describe '#verb' do
2016-02-26 15:28:08 +01:00
it 'is always post' do
expect(subject.verb).to be :post
end
2016-02-25 00:17:01 +01:00
end
describe '#object_type' do
2016-02-26 15:28:08 +01:00
it 'is note when the status is self-contained' do
expect(subject.object_type).to be :note
end
it 'is comment when the status replies to another' do
subject.thread = other
expect(subject.object_type).to be :comment
end
2016-02-25 00:17:01 +01:00
end
describe '#title' do
2016-02-26 15:28:08 +01:00
it 'is a shorter version of the content' do
expect(subject.title).to be_a String
end
end
describe '#content' do
it 'returns the text of the status if it is not a reblog' do
expect(subject.content).to eql subject.text
end
it 'returns the text of the reblogged status' do
subject.reblog = other
expect(subject.content).to eql other.text
end
2016-02-25 00:17:01 +01:00
end
describe '#target' do
2016-02-26 15:28:08 +01:00
it 'returns nil if the status is self-contained' do
expect(subject.target).to be_nil
end
it 'returns nil if the status is a reply' do
subject.thread = other
expect(subject.target).to be_nil
end
it 'returns the reblogged status' do
subject.reblog = other
expect(subject.target).to eq other
end
2016-02-25 00:17:01 +01:00
end
2016-03-19 12:13:47 +01:00
describe '#reblogs_count' do
pending
end
describe '#favourites_count' do
pending
end
2016-02-20 22:53:20 +01:00
end