diff options
author | Starfall <us@starfall.systems> | 2022-11-28 16:41:29 -0600 |
---|---|---|
committer | Starfall <us@starfall.systems> | 2022-11-28 16:41:29 -0600 |
commit | cb9dad90b01c9f53d1910cf128eb22200bdb9884 (patch) | |
tree | 1935d74f49853ed371e36cfac2d44ac33d2e8a2e /spec | |
parent | c3c3b6953f37462f26f011b6c6cbd1655d5dcbea (diff) | |
parent | 1a7aa37b60769a10077c585fa76ec848b6866d9a (diff) |
Merge remote-tracking branch 'glitch/main'
Diffstat (limited to 'spec')
-rw-r--r-- | spec/controllers/admin/statuses_controller_spec.rb | 2 | ||||
-rw-r--r-- | spec/controllers/api/v1/tags_controller_spec.rb | 4 | ||||
-rw-r--r-- | spec/models/account/field_spec.rb | 10 | ||||
-rw-r--r-- | spec/services/activitypub/process_status_update_service_spec.rb | 6 | ||||
-rw-r--r-- | spec/services/favourite_service_spec.rb | 2 | ||||
-rw-r--r-- | spec/services/follow_service_spec.rb | 2 | ||||
-rw-r--r-- | spec/services/verify_link_service_spec.rb | 20 | ||||
-rw-r--r-- | spec/views/statuses/show.html.haml_spec.rb | 2 |
8 files changed, 39 insertions, 9 deletions
diff --git a/spec/controllers/admin/statuses_controller_spec.rb b/spec/controllers/admin/statuses_controller_spec.rb index 227688e23..7f912c1c0 100644 --- a/spec/controllers/admin/statuses_controller_spec.rb +++ b/spec/controllers/admin/statuses_controller_spec.rb @@ -41,7 +41,7 @@ describe Admin::StatusesController do describe 'POST #batch' do before do - post :batch, params: { :account_id => account.id, action => '', :admin_status_batch_action => { status_ids: status_ids } } + post :batch, params: { account_id: account.id, action => '', admin_status_batch_action: { status_ids: status_ids } } end let(:status_ids) { [media_attached_status.id] } diff --git a/spec/controllers/api/v1/tags_controller_spec.rb b/spec/controllers/api/v1/tags_controller_spec.rb index ac42660df..216faad87 100644 --- a/spec/controllers/api/v1/tags_controller_spec.rb +++ b/spec/controllers/api/v1/tags_controller_spec.rb @@ -33,7 +33,11 @@ RSpec.describe Api::V1::TagsController, type: :controller do end describe 'POST #follow' do + let!(:unrelated_tag) { Fabricate(:tag) } + before do + TagFollow.create!(account: user.account, tag: unrelated_tag) + post :follow, params: { id: name } end diff --git a/spec/models/account/field_spec.rb b/spec/models/account/field_spec.rb index b4beec048..0ac9769bc 100644 --- a/spec/models/account/field_spec.rb +++ b/spec/models/account/field_spec.rb @@ -67,7 +67,15 @@ RSpec.describe Account::Field, type: :model do end context 'for an IDN URL' do - let(:value) { 'http://twitter.com∕dougallj∕status∕1590357240443437057.ê.cc/twitter.html' } + let(:value) { 'https://twitter.com∕dougallj∕status∕1590357240443437057.ê.cc/twitter.html' } + + it 'returns false' do + expect(subject.verifiable?).to be false + end + end + + context 'for a URL with a non-normalized path' do + let(:value) { 'https://github.com/octocatxxxxxxxx/../mastodon' } it 'returns false' do expect(subject.verifiable?).to be false diff --git a/spec/services/activitypub/process_status_update_service_spec.rb b/spec/services/activitypub/process_status_update_service_spec.rb index 481572742..750369d57 100644 --- a/spec/services/activitypub/process_status_update_service_spec.rb +++ b/spec/services/activitypub/process_status_update_service_spec.rb @@ -331,7 +331,7 @@ RSpec.describe ActivityPub::ProcessStatusUpdateService, type: :service do context 'originally without media attachments' do before do - allow(RedownloadMediaWorker).to receive(:perform_async) + stub_request(:get, 'https://example.com/foo.png').to_return(body: attachment_fixture('emojo.png')) subject.call(status, json) end @@ -355,8 +355,8 @@ RSpec.describe ActivityPub::ProcessStatusUpdateService, type: :service do expect(media_attachment.remote_url).to eq 'https://example.com/foo.png' end - it 'queues download of media attachments' do - expect(RedownloadMediaWorker).to have_received(:perform_async) + it 'fetches the attachment' do + expect(a_request(:get, 'https://example.com/foo.png')).to have_been_made end it 'records media change in edit' do diff --git a/spec/services/favourite_service_spec.rb b/spec/services/favourite_service_spec.rb index 94a8111dd..9781f0d78 100644 --- a/spec/services/favourite_service_spec.rb +++ b/spec/services/favourite_service_spec.rb @@ -23,7 +23,7 @@ RSpec.describe FavouriteService, type: :service do let(:status) { Fabricate(:status, account: bob) } before do - stub_request(:post, "http://example.com/inbox").to_return(:status => 200, :body => "", :headers => {}) + stub_request(:post, "http://example.com/inbox").to_return(status: 200, body: "", headers: {}) subject.call(sender, status) end diff --git a/spec/services/follow_service_spec.rb b/spec/services/follow_service_spec.rb index 88346ec54..412c04d76 100644 --- a/spec/services/follow_service_spec.rb +++ b/spec/services/follow_service_spec.rb @@ -140,7 +140,7 @@ RSpec.describe FollowService, type: :service do let(:bob) { Fabricate(:account, username: 'bob', domain: 'example.com', protocol: :activitypub, inbox_url: 'http://example.com/inbox') } before do - stub_request(:post, "http://example.com/inbox").to_return(:status => 200, :body => "", :headers => {}) + stub_request(:post, "http://example.com/inbox").to_return(status: 200, body: "", headers: {}) subject.call(sender, bob) end diff --git a/spec/services/verify_link_service_spec.rb b/spec/services/verify_link_service_spec.rb index 3fc88e60e..52ba454cc 100644 --- a/spec/services/verify_link_service_spec.rb +++ b/spec/services/verify_link_service_spec.rb @@ -76,7 +76,25 @@ RSpec.describe VerifyLinkService, type: :service do context 'when a link does not contain a link back' do let(:html) { '' } - it 'marks the field as verified' do + it 'does not mark the field as verified' do + expect(field.verified?).to be false + end + end + + context 'when link has no `href` attribute' do + let(:html) do + <<-HTML + <!doctype html> + <head> + <link type="text/html" rel="me" /> + </head> + <body> + <a rel="me" target="_blank">Follow me on Mastodon</a> + </body> + HTML + end + + it 'does not mark the field as verified' do expect(field.verified?).to be false end end diff --git a/spec/views/statuses/show.html.haml_spec.rb b/spec/views/statuses/show.html.haml_spec.rb index eeea2f698..ca5bb2ae8 100644 --- a/spec/views/statuses/show.html.haml_spec.rb +++ b/spec/views/statuses/show.html.haml_spec.rb @@ -4,7 +4,7 @@ require 'rails_helper' describe 'statuses/show.html.haml', without_verify_partial_doubles: true do before do - double(:api_oembed_url => '') + double(api_oembed_url: '') allow(view).to receive(:show_landing_strip?).and_return(true) allow(view).to receive(:site_title).and_return('example site') allow(view).to receive(:site_hostname).and_return('example.com') |