From 65a60a88498373c527c1b08b9245fc873b2bb53e Mon Sep 17 00:00:00 2001 From: kibigo! Date: Sun, 8 May 2022 21:52:06 -0700 Subject: [PATCH] Fix tests which expected public visibility We changed the default to unlisted, and it broke these. --- .../v1/timelines/public_controller_spec.rb | 30 ++++++++--------- .../api/v1/timelines/tag_controller_spec.rb | 24 +++++++------- .../batched_remove_status_service_spec.rb | 32 +++++++++---------- 3 files changed, 43 insertions(+), 43 deletions(-) diff --git a/spec/controllers/api/v1/timelines/public_controller_spec.rb b/spec/controllers/api/v1/timelines/public_controller_spec.rb index 0892d5db6..61cb21caa 100644 --- a/spec/controllers/api/v1/timelines/public_controller_spec.rb +++ b/spec/controllers/api/v1/timelines/public_controller_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require 'rails_helper' +require "rails_helper" describe Api::V1::Timelines::PublicController do render_views @@ -11,49 +11,49 @@ describe Api::V1::Timelines::PublicController do allow(controller).to receive(:doorkeeper_token) { token } end - context 'with a user context' do + context "with a user context" do let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id) } - describe 'GET #show' do + describe "GET #show" do before do - PostStatusService.new.call(user.account, text: 'New status from user for federated public timeline.') + PostStatusService.new.call(user.account, text: "New status from user for federated public timeline.", visibility: :public) end - it 'returns http success' do + it "returns http success" do get :show expect(response).to have_http_status(200) - expect(response.headers['Link'].links.size).to eq(2) + expect(response.headers["Link"].links.size).to eq(2) end end - describe 'GET #show with local only' do + describe "GET #show with local only" do before do - PostStatusService.new.call(user.account, text: 'New status from user for local public timeline.') + PostStatusService.new.call(user.account, text: "New status from user for local public timeline.", visibility: :public) end - it 'returns http success' do - get :show, params: { local: true } + it "returns http success" do + get :show, params: {local: true} expect(response).to have_http_status(200) - expect(response.headers['Link'].links.size).to eq(2) + expect(response.headers["Link"].links.size).to eq(2) end end end - context 'without a user context' do + context "without a user context" do let(:token) { Fabricate(:accessible_access_token, resource_owner_id: nil) } before do Setting.timeline_preview = true end - describe 'GET #show' do - it 'returns http success' do + describe "GET #show" do + it "returns http success" do get :show expect(response).to have_http_status(200) - expect(response.headers['Link']).to be_nil + expect(response.headers["Link"]).to be_nil end end end diff --git a/spec/controllers/api/v1/timelines/tag_controller_spec.rb b/spec/controllers/api/v1/timelines/tag_controller_spec.rb index 718911083..61b3c870c 100644 --- a/spec/controllers/api/v1/timelines/tag_controller_spec.rb +++ b/spec/controllers/api/v1/timelines/tag_controller_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require 'rails_helper' +require "rails_helper" describe Api::V1::Timelines::TagController do render_views @@ -11,30 +11,30 @@ describe Api::V1::Timelines::TagController do allow(controller).to receive(:doorkeeper_token) { token } end - context 'with a user context' do + context "with a user context" do let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id) } - describe 'GET #show' do + describe "GET #show" do before do - PostStatusService.new.call(user.account, text: 'It is a #test') + PostStatusService.new.call(user.account, text: "It is a #test", visibility: :public) end - it 'returns http success' do - get :show, params: { id: 'test' } + it "returns http success" do + get :show, params: {id: "test"} expect(response).to have_http_status(200) - expect(response.headers['Link'].links.size).to eq(2) + expect(response.headers["Link"].links.size).to eq(2) end end end - context 'without a user context' do + context "without a user context" do let(:token) { Fabricate(:accessible_access_token, resource_owner_id: nil) } - describe 'GET #show' do - it 'returns http success' do - get :show, params: { id: 'test' } + describe "GET #show" do + it "returns http success" do + get :show, params: {id: "test"} expect(response).to have_http_status(200) - expect(response.headers['Link']).to be_nil + expect(response.headers["Link"]).to be_nil end end end diff --git a/spec/services/batched_remove_status_service_spec.rb b/spec/services/batched_remove_status_service_spec.rb index 920edeb13..c46e6bee8 100644 --- a/spec/services/batched_remove_status_service_spec.rb +++ b/spec/services/batched_remove_status_service_spec.rb @@ -1,20 +1,20 @@ -require 'rails_helper' +require "rails_helper" RSpec.describe BatchedRemoveStatusService, type: :service do subject { BatchedRemoveStatusService.new } - let!(:alice) { Fabricate(:account) } - let!(:bob) { Fabricate(:account, username: 'bob', domain: 'example.com') } - let!(:jeff) { Fabricate(:account) } - let!(:hank) { Fabricate(:account, username: 'hank', protocol: :activitypub, domain: 'example.com', inbox_url: 'http://example.com/inbox') } + let!(:alice) { Fabricate(:account) } + let!(:bob) { Fabricate(:account, username: "bob", domain: "example.com") } + let!(:jeff) { Fabricate(:account) } + let!(:hank) { Fabricate(:account, username: "hank", protocol: :activitypub, domain: "example.com", inbox_url: "http://example.com/inbox") } - let(:status1) { PostStatusService.new.call(alice, text: 'Hello @bob@example.com') } - let(:status2) { PostStatusService.new.call(alice, text: 'Another status') } + let(:status1) { PostStatusService.new.call(alice, text: "Hello @bob@example.com", visibility: :public) } + let(:status2) { PostStatusService.new.call(alice, text: "Another status", visibility: :public) } before do allow(redis).to receive_messages(publish: nil) - stub_request(:post, 'http://example.com/inbox').to_return(status: 200) + stub_request(:post, "http://example.com/inbox").to_return(status: 200) jeff.user.update(current_sign_in_at: Time.zone.now) jeff.follow!(alice) @@ -26,28 +26,28 @@ RSpec.describe BatchedRemoveStatusService, type: :service do subject.call([status1, status2]) end - it 'removes statuses' do + it "removes statuses" do expect { Status.find(status1.id) }.to raise_error ActiveRecord::RecordNotFound expect { Status.find(status2.id) }.to raise_error ActiveRecord::RecordNotFound end - it 'removes statuses from author\'s home feed' do + it "removes statuses from author's home feed" do expect(HomeFeed.new(alice).get(10)).to_not include([status1.id, status2.id]) end - it 'removes statuses from local follower\'s home feed' do + it "removes statuses from local follower's home feed" do expect(HomeFeed.new(jeff).get(10)).to_not include([status1.id, status2.id]) end - it 'notifies streaming API of followers' do + it "notifies streaming API of followers" do expect(redis).to have_received(:publish).with("timeline:#{jeff.id}", any_args).at_least(:once) end - it 'notifies streaming API of public timeline' do - expect(redis).to have_received(:publish).with('timeline:public', any_args).at_least(:once) + it "notifies streaming API of public timeline" do + expect(redis).to have_received(:publish).with("timeline:public", any_args).at_least(:once) end - it 'sends delete activity to followers' do - expect(a_request(:post, 'http://example.com/inbox')).to have_been_made.at_least_once + it "sends delete activity to followers" do + expect(a_request(:post, "http://example.com/inbox")).to have_been_made.at_least_once end end -- 2.47.3