Merge upstream (#81)
This commit is contained in:
@ -1,6 +1,24 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Tag, type: :model do
|
||||
describe 'validations' do
|
||||
it 'invalid with #' do
|
||||
expect(Tag.new(name: '#hello_world')).to_not be_valid
|
||||
end
|
||||
|
||||
it 'invalid with .' do
|
||||
expect(Tag.new(name: '.abcdef123')).to_not be_valid
|
||||
end
|
||||
|
||||
it 'invalid with spaces' do
|
||||
expect(Tag.new(name: 'hello world')).to_not be_valid
|
||||
end
|
||||
|
||||
it 'valid with aesthetic' do
|
||||
expect(Tag.new(name: 'aesthetic')).to be_valid
|
||||
end
|
||||
end
|
||||
|
||||
describe 'HASHTAG_RE' do
|
||||
subject { Tag::HASHTAG_RE }
|
||||
|
||||
@ -27,6 +45,15 @@ RSpec.describe Tag, type: :model do
|
||||
expect(results).to eq [tag]
|
||||
end
|
||||
|
||||
it 'finds tag records in case insensitive' do
|
||||
tag = Fabricate(:tag, name: "MATCH")
|
||||
_miss_tag = Fabricate(:tag, name: "miss")
|
||||
|
||||
results = Tag.search_for("match")
|
||||
|
||||
expect(results).to eq [tag]
|
||||
end
|
||||
|
||||
it 'finds the exact matching tag as the first item' do
|
||||
similar_tag = Fabricate(:tag, name: "matchlater")
|
||||
tag = Fabricate(:tag, name: "match")
|
||||
|
28
spec/models/web/push_subscription_spec.rb
Normal file
28
spec/models/web/push_subscription_spec.rb
Normal file
@ -0,0 +1,28 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Web::PushSubscription, type: :model do
|
||||
let(:alerts) { { mention: true, reblog: false, follow: true, follow_request: false, favourite: true } }
|
||||
let(:payload_no_alerts) { Web::PushSubscription.new(id: 1, endpoint: 'a', key_p256dh: 'c', key_auth: 'd').as_payload }
|
||||
let(:payload_alerts) { Web::PushSubscription.new(id: 1, endpoint: 'a', key_p256dh: 'c', key_auth: 'd', data: { alerts: alerts }).as_payload }
|
||||
let(:push_subscription) { Web::PushSubscription.new(data: { alerts: alerts }) }
|
||||
|
||||
describe '#as_payload' do
|
||||
it 'only returns id and endpoint' do
|
||||
expect(payload_no_alerts.keys).to eq [:id, :endpoint]
|
||||
end
|
||||
|
||||
it 'returns alerts if set' do
|
||||
expect(payload_alerts.keys).to eq [:id, :endpoint, :alerts]
|
||||
end
|
||||
end
|
||||
|
||||
describe '#pushable?' do
|
||||
it 'obeys alert settings' do
|
||||
expect(push_subscription.send(:pushable?, Notification.new(activity_type: 'Mention'))).to eq true
|
||||
expect(push_subscription.send(:pushable?, Notification.new(activity_type: 'Status'))).to eq false
|
||||
expect(push_subscription.send(:pushable?, Notification.new(activity_type: 'Follow'))).to eq true
|
||||
expect(push_subscription.send(:pushable?, Notification.new(activity_type: 'FollowRequest'))).to eq false
|
||||
expect(push_subscription.send(:pushable?, Notification.new(activity_type: 'Favourite'))).to eq true
|
||||
end
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user