Autofix Rubocop RSpec/BeEq (#23740)

This commit is contained in:
Nick Schonning 2023-02-20 00:14:50 -05:00 committed by GitHub
parent bf785df9fe
commit 5116347eb7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
39 changed files with 139 additions and 182 deletions

View File

@ -545,49 +545,6 @@ RSpec/AnyInstance:
- 'spec/workers/activitypub/delivery_worker_spec.rb' - 'spec/workers/activitypub/delivery_worker_spec.rb'
- 'spec/workers/web/push_notification_worker_spec.rb' - 'spec/workers/web/push_notification_worker_spec.rb'
# Offense count: 139
# This cop supports unsafe autocorrection (--autocorrect-all).
RSpec/BeEq:
Exclude:
- 'spec/controllers/admin/export_domain_allows_controller_spec.rb'
- 'spec/controllers/admin/reports/actions_controller_spec.rb'
- 'spec/controllers/admin/reports_controller_spec.rb'
- 'spec/controllers/admin/users/two_factor_authentications_controller_spec.rb'
- 'spec/controllers/api/v1/accounts/credentials_controller_spec.rb'
- 'spec/controllers/api/v1/bookmarks_controller_spec.rb'
- 'spec/controllers/api/v1/favourites_controller_spec.rb'
- 'spec/controllers/api/v2/filters/keywords_controller_spec.rb'
- 'spec/controllers/application_controller_spec.rb'
- 'spec/controllers/auth/registrations_controller_spec.rb'
- 'spec/controllers/statuses_cleanup_controller_spec.rb'
- 'spec/helpers/application_helper_spec.rb'
- 'spec/helpers/jsonld_helper_spec.rb'
- 'spec/lib/activitypub/activity/add_spec.rb'
- 'spec/lib/activitypub/activity/create_spec.rb'
- 'spec/lib/feed_manager_spec.rb'
- 'spec/lib/ostatus/tag_manager_spec.rb'
- 'spec/lib/tag_manager_spec.rb'
- 'spec/lib/user_settings_decorator_spec.rb'
- 'spec/models/account_domain_block_spec.rb'
- 'spec/models/account_spec.rb'
- 'spec/models/block_spec.rb'
- 'spec/models/domain_block_spec.rb'
- 'spec/models/favourite_spec.rb'
- 'spec/models/media_attachment_spec.rb'
- 'spec/models/user_spec.rb'
- 'spec/models/web/push_subscription_spec.rb'
- 'spec/services/activitypub/process_status_update_service_spec.rb'
- 'spec/services/fetch_oembed_service_spec.rb'
- 'spec/services/fetch_resource_service_spec.rb'
- 'spec/services/post_status_service_spec.rb'
- 'spec/services/precompute_feed_service_spec.rb'
- 'spec/services/resolve_account_service_spec.rb'
- 'spec/support/examples/lib/settings/scoped_settings.rb'
- 'spec/workers/domain_block_worker_spec.rb'
- 'spec/workers/domain_clear_media_worker_spec.rb'
- 'spec/workers/feed_insert_worker_spec.rb'
- 'spec/workers/regeneration_worker_spec.rb'
# Offense count: 1 # Offense count: 1
RSpec/BeforeAfterAll: RSpec/BeforeAfterAll:
Exclude: Exclude:

View File

@ -25,7 +25,7 @@ RSpec.describe Admin::ExportDomainAllowsController, type: :controller do
expect(response).to redirect_to(admin_instances_path) expect(response).to redirect_to(admin_instances_path)
# Header should not be imported # Header should not be imported
expect(DomainAllow.where(domain: '#domain').present?).to eq(false) expect(DomainAllow.where(domain: '#domain').present?).to be(false)
# Domains should now be added # Domains should now be added
get :export, params: { format: :csv } get :export, params: { format: :csv }

View File

@ -116,7 +116,7 @@ describe Admin::Reports::ActionsController do
it 'marks the non-deleted as sensitive' do it 'marks the non-deleted as sensitive' do
subject subject
expect(media_attached_status.reload.sensitive).to eq true expect(media_attached_status.reload.sensitive).to be true
end end
end end
end end

View File

@ -55,7 +55,7 @@ describe Admin::ReportsController do
expect(response).to redirect_to(admin_reports_path) expect(response).to redirect_to(admin_reports_path)
report.reload report.reload
expect(report.action_taken_by_account).to eq user.account expect(report.action_taken_by_account).to eq user.account
expect(report.action_taken?).to eq true expect(report.action_taken?).to be true
end end
end end
@ -66,8 +66,8 @@ describe Admin::ReportsController do
put :reopen, params: { id: report } put :reopen, params: { id: report }
expect(response).to redirect_to(admin_report_path(report)) expect(response).to redirect_to(admin_report_path(report))
report.reload report.reload
expect(report.action_taken_by_account).to eq nil expect(report.action_taken_by_account).to be_nil
expect(report.action_taken?).to eq false expect(report.action_taken?).to be false
end end
end end
@ -89,7 +89,7 @@ describe Admin::ReportsController do
put :unassign, params: { id: report } put :unassign, params: { id: report }
expect(response).to redirect_to(admin_report_path(report)) expect(response).to redirect_to(admin_report_path(report))
report.reload report.reload
expect(report.assigned_account).to eq nil expect(report.assigned_account).to be_nil
end end
end end
end end

View File

@ -20,7 +20,7 @@ describe Admin::Users::TwoFactorAuthenticationsController do
delete :destroy, params: { user_id: user.id } delete :destroy, params: { user_id: user.id }
user.reload user.reload
expect(user.otp_enabled?).to eq false expect(user.otp_enabled?).to be false
expect(response).to redirect_to(admin_account_path(user.account_id)) expect(response).to redirect_to(admin_account_path(user.account_id))
end end
end end
@ -43,8 +43,8 @@ describe Admin::Users::TwoFactorAuthenticationsController do
delete :destroy, params: { user_id: user.id } delete :destroy, params: { user_id: user.id }
user.reload user.reload
expect(user.otp_enabled?).to eq false expect(user.otp_enabled?).to be false
expect(user.webauthn_enabled?).to eq false expect(user.webauthn_enabled?).to be false
expect(response).to redirect_to(admin_account_path(user.account_id)) expect(response).to redirect_to(admin_account_path(user.account_id))
end end
end end

View File

@ -51,7 +51,7 @@ describe Api::V1::Accounts::CredentialsController do
expect(user.account.avatar).to exist expect(user.account.avatar).to exist
expect(user.account.header).to exist expect(user.account.header).to exist
expect(user.setting_default_privacy).to eq('unlisted') expect(user.setting_default_privacy).to eq('unlisted')
expect(user.setting_default_sensitive).to eq(true) expect(user.setting_default_sensitive).to be(true)
end end
it 'queues up an account update distribution' do it 'queues up an account update distribution' do

View File

@ -70,7 +70,7 @@ RSpec.describe Api::V1::BookmarksController, type: :controller do
it 'does not add pagination headers if not necessary' do it 'does not add pagination headers if not necessary' do
get :index get :index
expect(response.headers['Link']).to eq nil expect(response.headers['Link']).to be_nil
end end
end end
end end

View File

@ -70,7 +70,7 @@ RSpec.describe Api::V1::FavouritesController, type: :controller do
it 'does not add pagination headers if not necessary' do it 'does not add pagination headers if not necessary' do
get :index get :index
expect(response.headers['Link']).to eq nil expect(response.headers['Link']).to be_nil
end end
end end
end end

View File

@ -45,7 +45,7 @@ RSpec.describe Api::V2::Filters::KeywordsController, type: :controller do
it 'returns a keyword' do it 'returns a keyword' do
json = body_as_json json = body_as_json
expect(json[:keyword]).to eq 'magic' expect(json[:keyword]).to eq 'magic'
expect(json[:whole_word]).to eq false expect(json[:whole_word]).to be false
end end
it 'creates a keyword' do it 'creates a keyword' do
@ -78,7 +78,7 @@ RSpec.describe Api::V2::Filters::KeywordsController, type: :controller do
it 'returns expected data' do it 'returns expected data' do
json = body_as_json json = body_as_json
expect(json[:keyword]).to eq 'foo' expect(json[:keyword]).to eq 'foo'
expect(json[:whole_word]).to eq false expect(json[:whole_word]).to be false
end end
context "when trying to access another user's filter keyword" do context "when trying to access another user's filter keyword" do

View File

@ -57,19 +57,19 @@ describe ApplicationController, type: :controller do
describe 'helper_method :single_user_mode?' do describe 'helper_method :single_user_mode?' do
it 'returns false if it is in single_user_mode but there is no account' do it 'returns false if it is in single_user_mode but there is no account' do
allow(Rails.configuration.x).to receive(:single_user_mode).and_return(true) allow(Rails.configuration.x).to receive(:single_user_mode).and_return(true)
expect(controller.view_context.single_user_mode?).to eq false expect(controller.view_context.single_user_mode?).to be false
end end
it 'returns false if there is an account but it is not in single_user_mode' do it 'returns false if there is an account but it is not in single_user_mode' do
allow(Rails.configuration.x).to receive(:single_user_mode).and_return(false) allow(Rails.configuration.x).to receive(:single_user_mode).and_return(false)
Fabricate(:account) Fabricate(:account)
expect(controller.view_context.single_user_mode?).to eq false expect(controller.view_context.single_user_mode?).to be false
end end
it 'returns true if it is in single_user_mode and there is an account' do it 'returns true if it is in single_user_mode and there is an account' do
allow(Rails.configuration.x).to receive(:single_user_mode).and_return(true) allow(Rails.configuration.x).to receive(:single_user_mode).and_return(true)
Fabricate(:account) Fabricate(:account)
expect(controller.view_context.single_user_mode?).to eq true expect(controller.view_context.single_user_mode?).to be true
end end
end end

View File

@ -163,7 +163,7 @@ RSpec.describe Auth::RegistrationsController, type: :controller do
user = User.find_by(email: 'test@example.com') user = User.find_by(email: 'test@example.com')
expect(user).to_not be_nil expect(user).to_not be_nil
expect(user.locale).to eq(accept_language) expect(user.locale).to eq(accept_language)
expect(user.approved).to eq(false) expect(user.approved).to be(false)
end end
end end
@ -191,7 +191,7 @@ RSpec.describe Auth::RegistrationsController, type: :controller do
user = User.find_by(email: 'test@example.com') user = User.find_by(email: 'test@example.com')
expect(user).to_not be_nil expect(user).to_not be_nil
expect(user.locale).to eq(accept_language) expect(user.locale).to eq(accept_language)
expect(user.approved).to eq(false) expect(user.approved).to be(false)
end end
end end
@ -223,7 +223,7 @@ RSpec.describe Auth::RegistrationsController, type: :controller do
user = User.find_by(email: 'test@example.com') user = User.find_by(email: 'test@example.com')
expect(user).to_not be_nil expect(user).to_not be_nil
expect(user.locale).to eq(accept_language) expect(user.locale).to eq(accept_language)
expect(user.approved).to eq(true) expect(user.approved).to be(true)
end end
end end

View File

@ -19,9 +19,9 @@ RSpec.describe StatusesCleanupController, type: :controller do
it 'updates the account status cleanup policy' do it 'updates the account status cleanup policy' do
put :update, params: { account_statuses_cleanup_policy: { enabled: true, min_status_age: 2.weeks.seconds, keep_direct: false, keep_polls: true } } put :update, params: { account_statuses_cleanup_policy: { enabled: true, min_status_age: 2.weeks.seconds, keep_direct: false, keep_polls: true } }
expect(response).to redirect_to(statuses_cleanup_path) expect(response).to redirect_to(statuses_cleanup_path)
expect(@user.account.statuses_cleanup_policy.enabled).to eq true expect(@user.account.statuses_cleanup_policy.enabled).to be true
expect(@user.account.statuses_cleanup_policy.keep_direct).to eq false expect(@user.account.statuses_cleanup_policy.keep_direct).to be false
expect(@user.account.statuses_cleanup_policy.keep_polls).to eq true expect(@user.account.statuses_cleanup_policy.keep_polls).to be true
end end
end end
end end

View File

@ -65,7 +65,7 @@ describe ApplicationHelper do
expect(Setting).to receive(:registrations_mode).and_return('open') expect(Setting).to receive(:registrations_mode).and_return('open')
end end
expect(helper.open_registrations?).to eq true expect(helper.open_registrations?).to be true
end end
it 'returns false when closed for registrations' do it 'returns false when closed for registrations' do
@ -73,7 +73,7 @@ describe ApplicationHelper do
expect(Setting).to receive(:registrations_mode).and_return('none') expect(Setting).to receive(:registrations_mode).and_return('none')
end end
expect(helper.open_registrations?).to eq false expect(helper.open_registrations?).to be false
end end
end end
@ -84,7 +84,7 @@ describe ApplicationHelper do
end end
it 'does not show landing strip' do it 'does not show landing strip' do
expect(helper.show_landing_strip?).to eq false expect(helper.show_landing_strip?).to be false
end end
end end
@ -96,13 +96,13 @@ describe ApplicationHelper do
it 'does not show landing strip on single user instance' do it 'does not show landing strip on single user instance' do
allow(helper).to receive(:single_user_mode?).and_return(true) allow(helper).to receive(:single_user_mode?).and_return(true)
expect(helper.show_landing_strip?).to eq false expect(helper.show_landing_strip?).to be false
end end
it 'shows landing strip on multi user instance' do it 'shows landing strip on multi user instance' do
allow(helper).to receive(:single_user_mode?).and_return(false) allow(helper).to receive(:single_user_mode?).and_return(false)
expect(helper.show_landing_strip?).to eq true expect(helper.show_landing_strip?).to be true
end end
end end
end end

View File

@ -66,14 +66,14 @@ describe JsonLdHelper do
stub_request(:get, 'https://mallory.test/').to_return body: '{"id": "https://marvin.test/"}' stub_request(:get, 'https://mallory.test/').to_return body: '{"id": "https://marvin.test/"}'
stub_request(:get, 'https://marvin.test/').to_return body: '{"id": "https://alice.test/"}' stub_request(:get, 'https://marvin.test/').to_return body: '{"id": "https://alice.test/"}'
expect(fetch_resource('https://mallory.test/', false)).to eq nil expect(fetch_resource('https://mallory.test/', false)).to be_nil
end end
end end
context 'when the second argument is true' do context 'when the second argument is true' do
it 'returns nil if the retrieved ID and the given URI does not match' do it 'returns nil if the retrieved ID and the given URI does not match' do
stub_request(:get, 'https://mallory.test/').to_return body: '{"id": "https://alice.test/"}' stub_request(:get, 'https://mallory.test/').to_return body: '{"id": "https://alice.test/"}'
expect(fetch_resource('https://mallory.test/', true)).to eq nil expect(fetch_resource('https://mallory.test/', true)).to be_nil
end end
end end
end end
@ -81,7 +81,7 @@ describe JsonLdHelper do
describe '#fetch_resource_without_id_validation' do describe '#fetch_resource_without_id_validation' do
it 'returns nil if the status code is not 200' do it 'returns nil if the status code is not 200' do
stub_request(:get, 'https://host.test/').to_return status: 400, body: '{}' stub_request(:get, 'https://host.test/').to_return status: 400, body: '{}'
expect(fetch_resource_without_id_validation('https://host.test/')).to eq nil expect(fetch_resource_without_id_validation('https://host.test/')).to be_nil
end end
it 'returns hash' do it 'returns hash' do
@ -150,7 +150,7 @@ describe JsonLdHelper do
patch_for_forwarding!(json, compacted) patch_for_forwarding!(json, compacted)
expect(compacted['to']).to eq ['https://www.w3.org/ns/activitystreams#Public'] expect(compacted['to']).to eq ['https://www.w3.org/ns/activitystreams#Public']
expect(compacted.dig('object', 'tag', 0, 'href')).to eq ['foo'] expect(compacted.dig('object', 'tag', 0, 'href')).to eq ['foo']
expect(safe_for_forwarding?(json, compacted)).to eq true expect(safe_for_forwarding?(json, compacted)).to be true
end end
end end
@ -160,14 +160,14 @@ describe JsonLdHelper do
compacted = compact(json) compacted = compact(json)
deemed_compatible = patch_for_forwarding!(json, compacted) deemed_compatible = patch_for_forwarding!(json, compacted)
expect(compacted['to']).to eq ['https://www.w3.org/ns/activitystreams#Public'] expect(compacted['to']).to eq ['https://www.w3.org/ns/activitystreams#Public']
expect(safe_for_forwarding?(json, compacted)).to eq true expect(safe_for_forwarding?(json, compacted)).to be true
end end
it 'deems an unsafe compacting as such' do it 'deems an unsafe compacting as such' do
compacted = compact(json) compacted = compact(json)
deemed_compatible = patch_for_forwarding!(json, compacted) deemed_compatible = patch_for_forwarding!(json, compacted)
expect(compacted['to']).to eq ['https://www.w3.org/ns/activitystreams#Public'] expect(compacted['to']).to eq ['https://www.w3.org/ns/activitystreams#Public']
expect(safe_for_forwarding?(json, compacted)).to eq false expect(safe_for_forwarding?(json, compacted)).to be false
end end
end end
end end

View File

@ -50,8 +50,8 @@ RSpec.describe ActivityPub::Activity::Add do
it 'fetches the status and pins it' do it 'fetches the status and pins it' do
allow(service_stub).to receive(:call) do |uri, id: true, on_behalf_of: nil, request_id: nil| # rubocop:disable Lint/UnusedBlockArgument allow(service_stub).to receive(:call) do |uri, id: true, on_behalf_of: nil, request_id: nil| # rubocop:disable Lint/UnusedBlockArgument
expect(uri).to eq 'https://example.com/unknown' expect(uri).to eq 'https://example.com/unknown'
expect(id).to eq true expect(id).to be true
expect(on_behalf_of&.following?(sender)).to eq true expect(on_behalf_of&.following?(sender)).to be true
status status
end end
subject.perform subject.perform
@ -64,8 +64,8 @@ RSpec.describe ActivityPub::Activity::Add do
it 'tries to fetch the status' do it 'tries to fetch the status' do
allow(service_stub).to receive(:call) do |uri, id: true, on_behalf_of: nil, request_id: nil| # rubocop:disable Lint/UnusedBlockArgument allow(service_stub).to receive(:call) do |uri, id: true, on_behalf_of: nil, request_id: nil| # rubocop:disable Lint/UnusedBlockArgument
expect(uri).to eq 'https://example.com/unknown' expect(uri).to eq 'https://example.com/unknown'
expect(id).to eq true expect(id).to be true
expect(on_behalf_of).to eq nil expect(on_behalf_of).to be_nil
nil nil
end end
subject.perform subject.perform

View File

@ -51,7 +51,7 @@ RSpec.describe ActivityPub::Activity::Create do
status = sender.statuses.first status = sender.statuses.first
expect(status).to_not be_nil expect(status).to_not be_nil
expect(status.edited?).to eq true expect(status.edited?).to be true
end end
end end
@ -77,7 +77,7 @@ RSpec.describe ActivityPub::Activity::Create do
status = sender.statuses.first status = sender.statuses.first
expect(status).to_not be_nil expect(status).to_not be_nil
expect(status.edited?).to eq false expect(status.edited?).to be false
end end
end end

View File

@ -297,7 +297,7 @@ RSpec.describe FeedManager do
status = Fabricate(:status, reblog: reblog) status = Fabricate(:status, reblog: reblog)
FeedManager.instance.push_to_home(account, status) FeedManager.instance.push_to_home(account, status)
expect(FeedManager.instance.push_to_home(account, reblog)).to eq false expect(FeedManager.instance.push_to_home(account, reblog)).to be false
end end
end end
@ -322,7 +322,7 @@ RSpec.describe FeedManager do
status = Fabricate(:status, reblog: reblog) status = Fabricate(:status, reblog: reblog)
FeedManager.instance.push_to_list(list, status) FeedManager.instance.push_to_list(list, status)
expect(FeedManager.instance.push_to_list(list, reblog)).to eq false expect(FeedManager.instance.push_to_list(list, reblog)).to be false
end end
context 'when replies policy is set to no replies' do context 'when replies policy is set to no replies' do
@ -332,19 +332,19 @@ RSpec.describe FeedManager do
it 'pushes statuses that are not replies' do it 'pushes statuses that are not replies' do
status = Fabricate(:status, text: 'Hello world', account: bob) status = Fabricate(:status, text: 'Hello world', account: bob)
expect(FeedManager.instance.push_to_list(list, status)).to eq true expect(FeedManager.instance.push_to_list(list, status)).to be true
end end
it 'pushes statuses that are replies to list owner' do it 'pushes statuses that are replies to list owner' do
status = Fabricate(:status, text: 'Hello world', account: owner) status = Fabricate(:status, text: 'Hello world', account: owner)
reply = Fabricate(:status, text: 'Nay', thread: status, account: bob) reply = Fabricate(:status, text: 'Nay', thread: status, account: bob)
expect(FeedManager.instance.push_to_list(list, reply)).to eq true expect(FeedManager.instance.push_to_list(list, reply)).to be true
end end
it 'does not push replies to another member of the list' do it 'does not push replies to another member of the list' do
status = Fabricate(:status, text: 'Hello world', account: alice) status = Fabricate(:status, text: 'Hello world', account: alice)
reply = Fabricate(:status, text: 'Nay', thread: status, account: bob) reply = Fabricate(:status, text: 'Nay', thread: status, account: bob)
expect(FeedManager.instance.push_to_list(list, reply)).to eq false expect(FeedManager.instance.push_to_list(list, reply)).to be false
end end
end end
@ -355,25 +355,25 @@ RSpec.describe FeedManager do
it 'pushes statuses that are not replies' do it 'pushes statuses that are not replies' do
status = Fabricate(:status, text: 'Hello world', account: bob) status = Fabricate(:status, text: 'Hello world', account: bob)
expect(FeedManager.instance.push_to_list(list, status)).to eq true expect(FeedManager.instance.push_to_list(list, status)).to be true
end end
it 'pushes statuses that are replies to list owner' do it 'pushes statuses that are replies to list owner' do
status = Fabricate(:status, text: 'Hello world', account: owner) status = Fabricate(:status, text: 'Hello world', account: owner)
reply = Fabricate(:status, text: 'Nay', thread: status, account: bob) reply = Fabricate(:status, text: 'Nay', thread: status, account: bob)
expect(FeedManager.instance.push_to_list(list, reply)).to eq true expect(FeedManager.instance.push_to_list(list, reply)).to be true
end end
it 'pushes replies to another member of the list' do it 'pushes replies to another member of the list' do
status = Fabricate(:status, text: 'Hello world', account: alice) status = Fabricate(:status, text: 'Hello world', account: alice)
reply = Fabricate(:status, text: 'Nay', thread: status, account: bob) reply = Fabricate(:status, text: 'Nay', thread: status, account: bob)
expect(FeedManager.instance.push_to_list(list, reply)).to eq true expect(FeedManager.instance.push_to_list(list, reply)).to be true
end end
it 'does not push replies to someone not a member of the list' do it 'does not push replies to someone not a member of the list' do
status = Fabricate(:status, text: 'Hello world', account: eve) status = Fabricate(:status, text: 'Hello world', account: eve)
reply = Fabricate(:status, text: 'Nay', thread: status, account: bob) reply = Fabricate(:status, text: 'Nay', thread: status, account: bob)
expect(FeedManager.instance.push_to_list(list, reply)).to eq false expect(FeedManager.instance.push_to_list(list, reply)).to be false
end end
end end
@ -384,25 +384,25 @@ RSpec.describe FeedManager do
it 'pushes statuses that are not replies' do it 'pushes statuses that are not replies' do
status = Fabricate(:status, text: 'Hello world', account: bob) status = Fabricate(:status, text: 'Hello world', account: bob)
expect(FeedManager.instance.push_to_list(list, status)).to eq true expect(FeedManager.instance.push_to_list(list, status)).to be true
end end
it 'pushes statuses that are replies to list owner' do it 'pushes statuses that are replies to list owner' do
status = Fabricate(:status, text: 'Hello world', account: owner) status = Fabricate(:status, text: 'Hello world', account: owner)
reply = Fabricate(:status, text: 'Nay', thread: status, account: bob) reply = Fabricate(:status, text: 'Nay', thread: status, account: bob)
expect(FeedManager.instance.push_to_list(list, reply)).to eq true expect(FeedManager.instance.push_to_list(list, reply)).to be true
end end
it 'pushes replies to another member of the list' do it 'pushes replies to another member of the list' do
status = Fabricate(:status, text: 'Hello world', account: alice) status = Fabricate(:status, text: 'Hello world', account: alice)
reply = Fabricate(:status, text: 'Nay', thread: status, account: bob) reply = Fabricate(:status, text: 'Nay', thread: status, account: bob)
expect(FeedManager.instance.push_to_list(list, reply)).to eq true expect(FeedManager.instance.push_to_list(list, reply)).to be true
end end
it 'pushes replies to someone not a member of the list' do it 'pushes replies to someone not a member of the list' do
status = Fabricate(:status, text: 'Hello world', account: eve) status = Fabricate(:status, text: 'Hello world', account: eve)
reply = Fabricate(:status, text: 'Nay', thread: status, account: bob) reply = Fabricate(:status, text: 'Nay', thread: status, account: bob)
expect(FeedManager.instance.push_to_list(list, reply)).to eq true expect(FeedManager.instance.push_to_list(list, reply)).to be true
end end
end end
end end
@ -416,7 +416,7 @@ RSpec.describe FeedManager do
FeedManager.instance.merge_into_home(account, reblog.account) FeedManager.instance.merge_into_home(account, reblog.account)
expect(redis.zscore('feed:home:0', reblog.id)).to eq nil expect(redis.zscore('feed:home:0', reblog.id)).to be_nil
end end
end end

View File

@ -15,15 +15,15 @@ describe OStatus::TagManager do
end end
it 'returns nil if it is not local id' do it 'returns nil if it is not local id' do
expect(OStatus::TagManager.instance.unique_tag_to_local_id('tag:remote,2000-01-01:objectId=12:objectType=Status', 'Status')).to eq nil expect(OStatus::TagManager.instance.unique_tag_to_local_id('tag:remote,2000-01-01:objectId=12:objectType=Status', 'Status')).to be_nil
end end
it 'returns nil if it is not expected type' do it 'returns nil if it is not expected type' do
expect(OStatus::TagManager.instance.unique_tag_to_local_id('tag:cb6e6126.ngrok.io,2000-01-01:objectId=12:objectType=Block', 'Status')).to eq nil expect(OStatus::TagManager.instance.unique_tag_to_local_id('tag:cb6e6126.ngrok.io,2000-01-01:objectId=12:objectType=Block', 'Status')).to be_nil
end end
it 'returns nil if it does not have object ID' do it 'returns nil if it does not have object ID' do
expect(OStatus::TagManager.instance.unique_tag_to_local_id('tag:cb6e6126.ngrok.io,2000-01-01:objectType=Status', 'Status')).to eq nil expect(OStatus::TagManager.instance.unique_tag_to_local_id('tag:cb6e6126.ngrok.io,2000-01-01:objectType=Status', 'Status')).to be_nil
end end
end end

View File

@ -14,15 +14,15 @@ RSpec.describe TagManager do
end end
it 'returns true for nil' do it 'returns true for nil' do
expect(TagManager.instance.local_domain?(nil)).to eq true expect(TagManager.instance.local_domain?(nil)).to be true
end end
it 'returns true if the slash-stripped string equals to local domain' do it 'returns true if the slash-stripped string equals to local domain' do
expect(TagManager.instance.local_domain?('DoMaIn.Example.com/')).to eq true expect(TagManager.instance.local_domain?('DoMaIn.Example.com/')).to be true
end end
it 'returns false for irrelevant string' do it 'returns false for irrelevant string' do
expect(TagManager.instance.local_domain?('DoMaIn.Example.com!')).to eq false expect(TagManager.instance.local_domain?('DoMaIn.Example.com!')).to be false
end end
end end
@ -39,21 +39,21 @@ RSpec.describe TagManager do
end end
it 'returns true for nil' do it 'returns true for nil' do
expect(TagManager.instance.web_domain?(nil)).to eq true expect(TagManager.instance.web_domain?(nil)).to be true
end end
it 'returns true if the slash-stripped string equals to web domain' do it 'returns true if the slash-stripped string equals to web domain' do
expect(TagManager.instance.web_domain?('DoMaIn.Example.com/')).to eq true expect(TagManager.instance.web_domain?('DoMaIn.Example.com/')).to be true
end end
it 'returns false for string with irrelevant characters' do it 'returns false for string with irrelevant characters' do
expect(TagManager.instance.web_domain?('DoMaIn.Example.com!')).to eq false expect(TagManager.instance.web_domain?('DoMaIn.Example.com!')).to be false
end end
end end
describe '#normalize_domain' do describe '#normalize_domain' do
it 'returns nil if the given parameter is nil' do it 'returns nil if the given parameter is nil' do
expect(TagManager.instance.normalize_domain(nil)).to eq nil expect(TagManager.instance.normalize_domain(nil)).to be_nil
end end
it 'returns normalized domain' do it 'returns normalized domain' do
@ -70,17 +70,17 @@ RSpec.describe TagManager do
it 'returns true if the normalized string with port is local URL' do it 'returns true if the normalized string with port is local URL' do
Rails.configuration.x.web_domain = 'domain.example.com:42' Rails.configuration.x.web_domain = 'domain.example.com:42'
expect(TagManager.instance.local_url?('https://DoMaIn.Example.com:42/')).to eq true expect(TagManager.instance.local_url?('https://DoMaIn.Example.com:42/')).to be true
end end
it 'returns true if the normalized string without port is local URL' do it 'returns true if the normalized string without port is local URL' do
Rails.configuration.x.web_domain = 'domain.example.com' Rails.configuration.x.web_domain = 'domain.example.com'
expect(TagManager.instance.local_url?('https://DoMaIn.Example.com/')).to eq true expect(TagManager.instance.local_url?('https://DoMaIn.Example.com/')).to be true
end end
it 'returns false for string with irrelevant characters' do it 'returns false for string with irrelevant characters' do
Rails.configuration.x.web_domain = 'domain.example.com' Rails.configuration.x.web_domain = 'domain.example.com'
expect(TagManager.instance.local_url?('https://domain.example.net/')).to eq false expect(TagManager.instance.local_url?('https://domain.example.net/')).to be false
end end
end end
end end

View File

@ -11,14 +11,14 @@ describe UserSettingsDecorator do
values = { 'notification_emails' => { 'follow' => '1' } } values = { 'notification_emails' => { 'follow' => '1' } }
settings.update(values) settings.update(values)
expect(user.settings['notification_emails']['follow']).to eq true expect(user.settings['notification_emails']['follow']).to be true
end end
it 'updates the user settings value for interactions' do it 'updates the user settings value for interactions' do
values = { 'interactions' => { 'must_be_follower' => '0' } } values = { 'interactions' => { 'must_be_follower' => '0' } }
settings.update(values) settings.update(values)
expect(user.settings['interactions']['must_be_follower']).to eq false expect(user.settings['interactions']['must_be_follower']).to be false
end end
it 'updates the user settings value for privacy' do it 'updates the user settings value for privacy' do
@ -32,42 +32,42 @@ describe UserSettingsDecorator do
values = { 'setting_default_sensitive' => '1' } values = { 'setting_default_sensitive' => '1' }
settings.update(values) settings.update(values)
expect(user.settings['default_sensitive']).to eq true expect(user.settings['default_sensitive']).to be true
end end
it 'updates the user settings value for unfollow modal' do it 'updates the user settings value for unfollow modal' do
values = { 'setting_unfollow_modal' => '0' } values = { 'setting_unfollow_modal' => '0' }
settings.update(values) settings.update(values)
expect(user.settings['unfollow_modal']).to eq false expect(user.settings['unfollow_modal']).to be false
end end
it 'updates the user settings value for boost modal' do it 'updates the user settings value for boost modal' do
values = { 'setting_boost_modal' => '1' } values = { 'setting_boost_modal' => '1' }
settings.update(values) settings.update(values)
expect(user.settings['boost_modal']).to eq true expect(user.settings['boost_modal']).to be true
end end
it 'updates the user settings value for delete toot modal' do it 'updates the user settings value for delete toot modal' do
values = { 'setting_delete_modal' => '0' } values = { 'setting_delete_modal' => '0' }
settings.update(values) settings.update(values)
expect(user.settings['delete_modal']).to eq false expect(user.settings['delete_modal']).to be false
end end
it 'updates the user settings value for gif auto play' do it 'updates the user settings value for gif auto play' do
values = { 'setting_auto_play_gif' => '0' } values = { 'setting_auto_play_gif' => '0' }
settings.update(values) settings.update(values)
expect(user.settings['auto_play_gif']).to eq false expect(user.settings['auto_play_gif']).to be false
end end
it 'updates the user settings value for system font in UI' do it 'updates the user settings value for system font in UI' do
values = { 'setting_system_font_ui' => '0' } values = { 'setting_system_font_ui' => '0' }
settings.update(values) settings.update(values)
expect(user.settings['system_font_ui']).to eq false expect(user.settings['system_font_ui']).to be false
end end
it 'decoerces setting values before applying' do it 'decoerces setting values before applying' do
@ -77,8 +77,8 @@ describe UserSettingsDecorator do
} }
settings.update(values) settings.update(values)
expect(user.settings['delete_modal']).to eq false expect(user.settings['delete_modal']).to be false
expect(user.settings['boost_modal']).to eq true expect(user.settings['boost_modal']).to be true
end end
end end
end end

View File

@ -7,7 +7,7 @@ RSpec.describe AccountDomainBlock, type: :model do
AccountDomainBlock.create!(account: account, domain: 'a.domain.blocked.later') AccountDomainBlock.create!(account: account, domain: 'a.domain.blocked.later')
expect(Rails.cache.exist?("exclude_domains_for:#{account.id}")).to eq false expect(Rails.cache.exist?("exclude_domains_for:#{account.id}")).to be false
end end
it 'removes blocking cache after destruction' do it 'removes blocking cache after destruction' do
@ -17,6 +17,6 @@ RSpec.describe AccountDomainBlock, type: :model do
block.destroy! block.destroy!
expect(Rails.cache.exist?("exclude_domains_for:#{account.id}")).to eq false expect(Rails.cache.exist?("exclude_domains_for:#{account.id}")).to be false
end end
end end

View File

@ -160,7 +160,7 @@ RSpec.describe Account, type: :model do
it 'sets default avatar, header, avatar_remote_url, and header_remote_url' do it 'sets default avatar, header, avatar_remote_url, and header_remote_url' do
expect(account.avatar_remote_url).to eq 'https://remote.test/invalid_avatar' expect(account.avatar_remote_url).to eq 'https://remote.test/invalid_avatar'
expect(account.header_remote_url).to eq expectation.header_remote_url expect(account.header_remote_url).to eq expectation.header_remote_url
expect(account.avatar_file_name).to eq nil expect(account.avatar_file_name).to be_nil
expect(account.header_file_name).to eq expectation.header_file_name expect(account.header_file_name).to eq expectation.header_file_name
end end
end end
@ -259,11 +259,11 @@ RSpec.describe Account, type: :model do
it 'is true when this account has favourited it' do it 'is true when this account has favourited it' do
Fabricate(:favourite, status: original_reblog, account: subject) Fabricate(:favourite, status: original_reblog, account: subject)
expect(subject.favourited?(original_status)).to eq true expect(subject.favourited?(original_status)).to be true
end end
it 'is false when this account has not favourited it' do it 'is false when this account has not favourited it' do
expect(subject.favourited?(original_status)).to eq false expect(subject.favourited?(original_status)).to be false
end end
end end
@ -271,11 +271,11 @@ RSpec.describe Account, type: :model do
it 'is true when this account has favourited it' do it 'is true when this account has favourited it' do
Fabricate(:favourite, status: original_status, account: subject) Fabricate(:favourite, status: original_status, account: subject)
expect(subject.favourited?(original_status)).to eq true expect(subject.favourited?(original_status)).to be true
end end
it 'is false when this account has not favourited it' do it 'is false when this account has not favourited it' do
expect(subject.favourited?(original_status)).to eq false expect(subject.favourited?(original_status)).to be false
end end
end end
end end
@ -297,11 +297,11 @@ RSpec.describe Account, type: :model do
it 'is true when this account has reblogged it' do it 'is true when this account has reblogged it' do
Fabricate(:status, reblog: original_reblog, account: subject) Fabricate(:status, reblog: original_reblog, account: subject)
expect(subject.reblogged?(original_reblog)).to eq true expect(subject.reblogged?(original_reblog)).to be true
end end
it 'is false when this account has not reblogged it' do it 'is false when this account has not reblogged it' do
expect(subject.reblogged?(original_reblog)).to eq false expect(subject.reblogged?(original_reblog)).to be false
end end
end end
@ -309,11 +309,11 @@ RSpec.describe Account, type: :model do
it 'is true when this account has reblogged it' do it 'is true when this account has reblogged it' do
Fabricate(:status, reblog: original_status, account: subject) Fabricate(:status, reblog: original_status, account: subject)
expect(subject.reblogged?(original_status)).to eq true expect(subject.reblogged?(original_status)).to be true
end end
it 'is false when this account has not reblogged it' do it 'is false when this account has not reblogged it' do
expect(subject.reblogged?(original_status)).to eq false expect(subject.reblogged?(original_status)).to be false
end end
end end
end end
@ -958,7 +958,7 @@ RSpec.describe Account, type: :model do
# Test disabled because test environment omits autogenerating keys for performance # Test disabled because test environment omits autogenerating keys for performance
xit 'generates keys' do xit 'generates keys' do
account = Account.create!(domain: nil, username: Faker::Internet.user_name(separators: ['_'])) account = Account.create!(domain: nil, username: Faker::Internet.user_name(separators: ['_']))
expect(account.keypair.private?).to eq true expect(account.keypair.private?).to be true
end end
end end

View File

@ -28,8 +28,8 @@ RSpec.describe Block, type: :model do
Block.create!(account: account, target_account: target_account) Block.create!(account: account, target_account: target_account)
expect(Rails.cache.exist?("exclude_account_ids_for:#{account.id}")).to eq false expect(Rails.cache.exist?("exclude_account_ids_for:#{account.id}")).to be false
expect(Rails.cache.exist?("exclude_account_ids_for:#{target_account.id}")).to eq false expect(Rails.cache.exist?("exclude_account_ids_for:#{target_account.id}")).to be false
end end
it 'removes blocking cache after destruction' do it 'removes blocking cache after destruction' do
@ -41,7 +41,7 @@ RSpec.describe Block, type: :model do
block.destroy! block.destroy!
expect(Rails.cache.exist?("exclude_account_ids_for:#{account.id}")).to eq false expect(Rails.cache.exist?("exclude_account_ids_for:#{account.id}")).to be false
expect(Rails.cache.exist?("exclude_account_ids_for:#{target_account.id}")).to eq false expect(Rails.cache.exist?("exclude_account_ids_for:#{target_account.id}")).to be false
end end
end end

View File

@ -24,16 +24,16 @@ RSpec.describe DomainBlock, type: :model do
describe '.blocked?' do describe '.blocked?' do
it 'returns true if the domain is suspended' do it 'returns true if the domain is suspended' do
Fabricate(:domain_block, domain: 'example.com', severity: :suspend) Fabricate(:domain_block, domain: 'example.com', severity: :suspend)
expect(DomainBlock.blocked?('example.com')).to eq true expect(DomainBlock.blocked?('example.com')).to be true
end end
it 'returns false even if the domain is silenced' do it 'returns false even if the domain is silenced' do
Fabricate(:domain_block, domain: 'example.com', severity: :silence) Fabricate(:domain_block, domain: 'example.com', severity: :silence)
expect(DomainBlock.blocked?('example.com')).to eq false expect(DomainBlock.blocked?('example.com')).to be false
end end
it 'returns false if the domain is not suspended nor silenced' do it 'returns false if the domain is not suspended nor silenced' do
expect(DomainBlock.blocked?('example.com')).to eq false expect(DomainBlock.blocked?('example.com')).to be false
end end
end end

View File

@ -9,7 +9,7 @@ RSpec.describe Favourite, type: :model do
it 'invalidates if the reblogged status is already a favourite' do it 'invalidates if the reblogged status is already a favourite' do
Favourite.create!(account: account, status: reblog) Favourite.create!(account: account, status: reblog)
expect(Favourite.new(account: account, status: status).valid?).to eq false expect(Favourite.new(account: account, status: status).valid?).to be false
end end
it 'replaces status with the reblogged one if it is a reblog' do it 'replaces status with the reblogged one if it is a reblog' do

View File

@ -138,7 +138,7 @@ RSpec.describe MediaAttachment, type: :model do
end end
it 'extracts thumbnail' do it 'extracts thumbnail' do
expect(media.thumbnail.present?).to eq true expect(media.thumbnail.present?).to be true
end end
it 'extracts colors from thumbnail' do it 'extracts colors from thumbnail' do

View File

@ -46,7 +46,7 @@ RSpec.describe User, type: :model do
it 'cleans out empty string from languages' do it 'cleans out empty string from languages' do
user = Fabricate.build(:user, chosen_languages: ['']) user = Fabricate.build(:user, chosen_languages: [''])
user.valid? user.valid?
expect(user.chosen_languages).to eq nil expect(user.chosen_languages).to be_nil
end end
end end

View File

@ -39,7 +39,7 @@ RSpec.describe Web::PushSubscription, type: :model do
let(:policy) { 'all' } let(:policy) { 'all' }
it 'returns true' do it 'returns true' do
expect(subject.pushable?(notification)).to eq true expect(subject.pushable?(notification)).to be true
end end
end end
@ -47,7 +47,7 @@ RSpec.describe Web::PushSubscription, type: :model do
let(:policy) { 'none' } let(:policy) { 'none' }
it 'returns false' do it 'returns false' do
expect(subject.pushable?(notification)).to eq false expect(subject.pushable?(notification)).to be false
end end
end end
@ -60,13 +60,13 @@ RSpec.describe Web::PushSubscription, type: :model do
end end
it 'returns true' do it 'returns true' do
expect(subject.pushable?(notification)).to eq true expect(subject.pushable?(notification)).to be true
end end
end end
context 'and notification is not from someone you follow' do context 'and notification is not from someone you follow' do
it 'returns false' do it 'returns false' do
expect(subject.pushable?(notification)).to eq false expect(subject.pushable?(notification)).to be false
end end
end end
end end
@ -80,13 +80,13 @@ RSpec.describe Web::PushSubscription, type: :model do
end end
it 'returns true' do it 'returns true' do
expect(subject.pushable?(notification)).to eq true expect(subject.pushable?(notification)).to be true
end end
end end
context 'and notification is not from someone who follows you' do context 'and notification is not from someone who follows you' do
it 'returns false' do it 'returns false' do
expect(subject.pushable?(notification)).to eq false expect(subject.pushable?(notification)).to be false
end end
end end
end end

View File

@ -410,7 +410,7 @@ RSpec.describe ActivityPub::ProcessStatusUpdateService, type: :service do
end end
it 'removes poll' do it 'removes poll' do
expect(status.reload.poll).to eq nil expect(status.reload.poll).to be_nil
end end
it 'records media change in edit' do it 'records media change in edit' do

View File

@ -62,7 +62,7 @@ describe FetchOEmbedService, type: :service do
it 'does not cache OEmbed endpoint' do it 'does not cache OEmbed endpoint' do
subject.call('https://host.test/oembed.html', format: :xml) subject.call('https://host.test/oembed.html', format: :xml)
expect(Rails.cache.exist?('oembed_endpoint:host.test')).to eq false expect(Rails.cache.exist?('oembed_endpoint:host.test')).to be false
end end
end end
@ -83,7 +83,7 @@ describe FetchOEmbedService, type: :service do
it 'does not cache OEmbed endpoint' do it 'does not cache OEmbed endpoint' do
subject.call('https://host.test/oembed.html') subject.call('https://host.test/oembed.html')
expect(Rails.cache.exist?('oembed_endpoint:host.test')).to eq false expect(Rails.cache.exist?('oembed_endpoint:host.test')).to be false
end end
end end
@ -104,7 +104,7 @@ describe FetchOEmbedService, type: :service do
it 'does not cache OEmbed endpoint' do it 'does not cache OEmbed endpoint' do
subject.call('https://host.test/oembed.html') subject.call('https://host.test/oembed.html')
expect(Rails.cache.exist?('oembed_endpoint:host.test')).to eq false expect(Rails.cache.exist?('oembed_endpoint:host.test')).to be false
end end
end end

View File

@ -74,7 +74,7 @@ RSpec.describe FetchResourceService, type: :service do
context 'when content type is application/atom+xml' do context 'when content type is application/atom+xml' do
let(:content_type) { 'application/atom+xml' } let(:content_type) { 'application/atom+xml' }
it { is_expected.to eq nil } it { is_expected.to be_nil }
end end
context 'when content type is activity+json' do context 'when content type is activity+json' do

View File

@ -216,7 +216,7 @@ RSpec.describe PostStatusService, type: :service do
media_ids: [media.id] media_ids: [media.id]
) )
expect(media.reload.status).to eq nil expect(media.reload.status).to be_nil
end end
it 'does not allow attaching more than 4 files' do it 'does not allow attaching more than 4 files' do

View File

@ -31,7 +31,7 @@ RSpec.describe PrecomputeFeedService, type: :service do
subject.call(account) subject.call(account)
expect(redis.zscore(FeedManager.instance.key(:home, account.id), reblog.id)).to eq nil expect(redis.zscore(FeedManager.instance.key(:home, account.id), reblog.id)).to be_nil
end end
end end
end end

View File

@ -108,7 +108,7 @@ RSpec.describe ResolveAccountService, type: :service do
it 'returns new remote account' do it 'returns new remote account' do
account = subject.call('Foo@redirected.example.com') account = subject.call('Foo@redirected.example.com')
expect(account.activitypub?).to eq true expect(account.activitypub?).to be true
expect(account.acct).to eq 'foo@ap.example.com' expect(account.acct).to eq 'foo@ap.example.com'
expect(account.inbox_url).to eq 'https://ap.example.com/users/foo/inbox' expect(account.inbox_url).to eq 'https://ap.example.com/users/foo/inbox'
end end
@ -123,7 +123,7 @@ RSpec.describe ResolveAccountService, type: :service do
it 'returns new remote account' do it 'returns new remote account' do
account = subject.call('Foo@redirected.example.com') account = subject.call('Foo@redirected.example.com')
expect(account.activitypub?).to eq true expect(account.activitypub?).to be true
expect(account.acct).to eq 'foo@ap.example.com' expect(account.acct).to eq 'foo@ap.example.com'
expect(account.inbox_url).to eq 'https://ap.example.com/users/foo/inbox' expect(account.inbox_url).to eq 'https://ap.example.com/users/foo/inbox'
end end
@ -146,7 +146,7 @@ RSpec.describe ResolveAccountService, type: :service do
it 'returns new remote account' do it 'returns new remote account' do
account = subject.call('foo@ap.example.com') account = subject.call('foo@ap.example.com')
expect(account.activitypub?).to eq true expect(account.activitypub?).to be true
expect(account.domain).to eq 'ap.example.com' expect(account.domain).to eq 'ap.example.com'
expect(account.inbox_url).to eq 'https://ap.example.com/users/foo/inbox' expect(account.inbox_url).to eq 'https://ap.example.com/users/foo/inbox'
end end
@ -159,7 +159,7 @@ RSpec.describe ResolveAccountService, type: :service do
it 'returns new remote account' do it 'returns new remote account' do
account = subject.call('foo@ap.example.com') account = subject.call('foo@ap.example.com')
expect(account.activitypub?).to eq true expect(account.activitypub?).to be true
expect(account.domain).to eq 'ap.example.com' expect(account.domain).to eq 'ap.example.com'
expect(account.inbox_url).to eq 'https://ap.example.com/users/foo/inbox' expect(account.inbox_url).to eq 'https://ap.example.com/users/foo/inbox'
expect(account.actor_type).to eq 'Person' expect(account.actor_type).to eq 'Person'
@ -174,7 +174,7 @@ RSpec.describe ResolveAccountService, type: :service do
it 'returns new remote account' do it 'returns new remote account' do
account = subject.call('foo@ap.example.com') account = subject.call('foo@ap.example.com')
expect(account.activitypub?).to eq true expect(account.activitypub?).to be true
expect(account.domain).to eq 'ap.example.com' expect(account.domain).to eq 'ap.example.com'
expect(account.inbox_url).to eq 'https://ap.example.com/users/foo/inbox' expect(account.inbox_url).to eq 'https://ap.example.com/users/foo/inbox'
expect(account.uri).to eq 'https://ap.example.com/users/foo' expect(account.uri).to eq 'https://ap.example.com/users/foo'
@ -195,7 +195,7 @@ RSpec.describe ResolveAccountService, type: :service do
it 'returns new remote account' do it 'returns new remote account' do
account = subject.call('foo@ap.example.com') account = subject.call('foo@ap.example.com')
expect(account.activitypub?).to eq true expect(account.activitypub?).to be true
expect(account.domain).to eq 'ap.example.com' expect(account.domain).to eq 'ap.example.com'
expect(account.inbox_url).to eq 'https://ap.example.com/users/foo/inbox' expect(account.inbox_url).to eq 'https://ap.example.com/users/foo/inbox'
expect(account.uri).to eq 'https://ap.example.com/users/foo' expect(account.uri).to eq 'https://ap.example.com/users/foo'

View File

@ -3,13 +3,13 @@
shared_examples 'ScopedSettings' do shared_examples 'ScopedSettings' do
describe '[]' do describe '[]' do
it 'inherits default settings' do it 'inherits default settings' do
expect(Setting.boost_modal).to eq false expect(Setting.boost_modal).to be false
expect(Setting.interactions['must_be_follower']).to eq false expect(Setting.interactions['must_be_follower']).to be false
settings = create! settings = create!
expect(settings['boost_modal']).to eq false expect(settings['boost_modal']).to be false
expect(settings['interactions']['must_be_follower']).to eq false expect(settings['interactions']['must_be_follower']).to be false
end end
end end
@ -17,16 +17,16 @@ shared_examples 'ScopedSettings' do
# expecting [] and []= works # expecting [] and []= works
it 'returns records merged with default values except hashes' do it 'returns records merged with default values except hashes' do
expect(Setting.boost_modal).to eq false expect(Setting.boost_modal).to be false
expect(Setting.delete_modal).to eq true expect(Setting.delete_modal).to be true
settings = create! settings = create!
settings['boost_modal'] = true settings['boost_modal'] = true
records = settings.all_as_records records = settings.all_as_records
expect(records['boost_modal'].value).to eq true expect(records['boost_modal'].value).to be true
expect(records['delete_modal'].value).to eq true expect(records['delete_modal'].value).to be true
end end
end end
@ -34,15 +34,15 @@ shared_examples 'ScopedSettings' do
# expecting [] and []= works. # expecting [] and []= works.
it 'reads settings' do it 'reads settings' do
expect(Setting.boost_modal).to eq false expect(Setting.boost_modal).to be false
settings = create! settings = create!
expect(settings.boost_modal).to eq false expect(settings.boost_modal).to be false
end end
it 'updates settings' do it 'updates settings' do
settings = fabricate settings = fabricate
settings.boost_modal = true settings.boost_modal = true
expect(settings['boost_modal']).to eq true expect(settings['boost_modal']).to be true
end end
end end
@ -54,13 +54,13 @@ shared_examples 'ScopedSettings' do
Setting.save! Setting.save!
expect(settings['boost_modal']).to eq true expect(settings['boost_modal']).to be true
expect(settings['interactions']['must_be_follower']).to eq true expect(settings['interactions']['must_be_follower']).to be true
Rails.cache.clear Rails.cache.clear
expect(settings['boost_modal']).to eq true expect(settings['boost_modal']).to be true
expect(settings['interactions']['must_be_follower']).to eq true expect(settings['interactions']['must_be_follower']).to be true
end end
xit 'does not mutate defaults via the cache' do xit 'does not mutate defaults via the cache' do
@ -69,6 +69,6 @@ shared_examples 'ScopedSettings' do
# This mutates the global settings default such that future # This mutates the global settings default such that future
# instances will inherit the incorrect starting values # instances will inherit the incorrect starting values
expect(fabricate.settings['interactions']['must_be_follower']).to eq false expect(fabricate.settings['interactions']['must_be_follower']).to be false
end end
end end

View File

@ -20,7 +20,7 @@ describe DomainBlockWorker do
it 'returns true for non-existent domain block' do it 'returns true for non-existent domain block' do
result = subject.perform('aaa') result = subject.perform('aaa')
expect(result).to eq(true) expect(result).to be(true)
end end
end end
end end

View File

@ -20,7 +20,7 @@ describe DomainClearMediaWorker do
it 'returns true for non-existent domain block' do it 'returns true for non-existent domain block' do
result = subject.perform('aaa') result = subject.perform('aaa')
expect(result).to eq(true) expect(result).to be(true)
end end
end end
end end

View File

@ -15,7 +15,7 @@ describe FeedInsertWorker do
allow(FeedManager).to receive(:instance).and_return(instance) allow(FeedManager).to receive(:instance).and_return(instance)
result = subject.perform(nil, follower.id) result = subject.perform(nil, follower.id)
expect(result).to eq true expect(result).to be true
expect(instance).to_not have_received(:push_to_home) expect(instance).to_not have_received(:push_to_home)
end end
@ -24,7 +24,7 @@ describe FeedInsertWorker do
allow(FeedManager).to receive(:instance).and_return(instance) allow(FeedManager).to receive(:instance).and_return(instance)
result = subject.perform(status.id, nil) result = subject.perform(status.id, nil)
expect(result).to eq true expect(result).to be true
expect(instance).to_not have_received(:push_to_home) expect(instance).to_not have_received(:push_to_home)
end end
end end

View File

@ -20,7 +20,7 @@ describe RegenerationWorker do
it 'fails when account does not exist' do it 'fails when account does not exist' do
result = subject.perform('aaa') result = subject.perform('aaa')
expect(result).to eq(true) expect(result).to be(true)
end end
end end
end end