diff options
Diffstat (limited to 'spec')
155 files changed, 1342 insertions, 360 deletions
diff --git a/spec/controllers/about_controller_spec.rb b/spec/controllers/about_controller_spec.rb index c2c34d34a..2089b3b16 100644 --- a/spec/controllers/about_controller_spec.rb +++ b/spec/controllers/about_controller_spec.rb @@ -17,7 +17,7 @@ RSpec.describe AboutController, type: :controller do end it 'returns http success' do - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end end @@ -35,7 +35,7 @@ RSpec.describe AboutController, type: :controller do end it 'returns http success' do - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end end @@ -49,7 +49,7 @@ RSpec.describe AboutController, type: :controller do end it 'returns http success' do - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end end diff --git a/spec/controllers/accounts_controller_spec.rb b/spec/controllers/accounts_controller_spec.rb index a8ade790c..18c249c07 100644 --- a/spec/controllers/accounts_controller_spec.rb +++ b/spec/controllers/accounts_controller_spec.rb @@ -40,7 +40,7 @@ RSpec.describe AccountsController, type: :controller do end it 'returns http success' do - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end it 'returns correct format' do diff --git a/spec/controllers/activitypub/outboxes_controller_spec.rb b/spec/controllers/activitypub/outboxes_controller_spec.rb index a25998021..47460b22c 100644 --- a/spec/controllers/activitypub/outboxes_controller_spec.rb +++ b/spec/controllers/activitypub/outboxes_controller_spec.rb @@ -13,7 +13,7 @@ RSpec.describe ActivityPub::OutboxesController, type: :controller do end it 'returns http success' do - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end it 'returns application/activity+json' do diff --git a/spec/controllers/admin/accounts_controller_spec.rb b/spec/controllers/admin/accounts_controller_spec.rb index 8be27d866..ff9dbbfb8 100644 --- a/spec/controllers/admin/accounts_controller_spec.rb +++ b/spec/controllers/admin/accounts_controller_spec.rb @@ -63,7 +63,7 @@ RSpec.describe Admin::AccountsController, type: :controller do it 'returns http success' do get :index - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end end @@ -72,7 +72,7 @@ RSpec.describe Admin::AccountsController, type: :controller do it 'returns http success' do get :show, params: { id: account.id } - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end end end diff --git a/spec/controllers/admin/change_email_controller_spec.rb b/spec/controllers/admin/change_email_controller_spec.rb index 50f94f835..31df0f0fc 100644 --- a/spec/controllers/admin/change_email_controller_spec.rb +++ b/spec/controllers/admin/change_email_controller_spec.rb @@ -16,7 +16,7 @@ RSpec.describe Admin::ChangeEmailsController, type: :controller do get :show, params: { account_id: account.id } - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end end diff --git a/spec/controllers/admin/confirmations_controller_spec.rb b/spec/controllers/admin/confirmations_controller_spec.rb index 3f2b28c0e..7c8034964 100644 --- a/spec/controllers/admin/confirmations_controller_spec.rb +++ b/spec/controllers/admin/confirmations_controller_spec.rb @@ -20,14 +20,14 @@ RSpec.describe Admin::ConfirmationsController, type: :controller do it 'raises an error when there is no account' do post :create, params: { account_id: 'fake' } - expect(response).to have_http_status(:missing) + expect(response).to have_http_status(404) end it 'raises an error when there is no user' do account = Fabricate(:account, user: nil) post :create, params: { account_id: account.id } - expect(response).to have_http_status(:missing) + expect(response).to have_http_status(404) end end end diff --git a/spec/controllers/admin/domain_blocks_controller_spec.rb b/spec/controllers/admin/domain_blocks_controller_spec.rb index b9e73c04b..79e7fea42 100644 --- a/spec/controllers/admin/domain_blocks_controller_spec.rb +++ b/spec/controllers/admin/domain_blocks_controller_spec.rb @@ -23,7 +23,7 @@ RSpec.describe Admin::DomainBlocksController, type: :controller do assigned = assigns(:domain_blocks) expect(assigned.count).to eq 1 expect(assigned.klass).to be DomainBlock - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end end @@ -32,7 +32,7 @@ RSpec.describe Admin::DomainBlocksController, type: :controller do get :new expect(assigns(:domain_block)).to be_instance_of(DomainBlock) - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end end @@ -41,7 +41,7 @@ RSpec.describe Admin::DomainBlocksController, type: :controller do domain_block = Fabricate(:domain_block) get :show, params: { id: domain_block.id } - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end end diff --git a/spec/controllers/admin/email_domain_blocks_controller_spec.rb b/spec/controllers/admin/email_domain_blocks_controller_spec.rb index 295de9073..133d38ff1 100644 --- a/spec/controllers/admin/email_domain_blocks_controller_spec.rb +++ b/spec/controllers/admin/email_domain_blocks_controller_spec.rb @@ -25,7 +25,7 @@ RSpec.describe Admin::EmailDomainBlocksController, type: :controller do assigned = assigns(:email_domain_blocks) expect(assigned.count).to eq 1 expect(assigned.klass).to be EmailDomainBlock - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end end @@ -34,7 +34,7 @@ RSpec.describe Admin::EmailDomainBlocksController, type: :controller do get :new expect(assigns(:email_domain_block)).to be_instance_of(EmailDomainBlock) - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end end diff --git a/spec/controllers/admin/instances_controller_spec.rb b/spec/controllers/admin/instances_controller_spec.rb index f57e3fa97..412b81443 100644 --- a/spec/controllers/admin/instances_controller_spec.rb +++ b/spec/controllers/admin/instances_controller_spec.rb @@ -26,7 +26,7 @@ RSpec.describe Admin::InstancesController, type: :controller do expect(instances.size).to eq 1 expect(instances[0].domain).to eq 'less.popular' - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end end end diff --git a/spec/controllers/admin/reported_statuses_controller_spec.rb b/spec/controllers/admin/reported_statuses_controller_spec.rb index 297807d41..29957ed37 100644 --- a/spec/controllers/admin/reported_statuses_controller_spec.rb +++ b/spec/controllers/admin/reported_statuses_controller_spec.rb @@ -13,7 +13,7 @@ describe Admin::ReportedStatusesController do describe 'POST #create' do subject do - -> { post :create, params: { report_id: report, form_status_batch: { action: action, status_ids: status_ids } } } + -> { post :create, params: { :report_id => report, action => '', :form_status_batch => { status_ids: status_ids } } } end let(:action) { 'nsfw_on' } @@ -84,7 +84,7 @@ describe Admin::ReportedStatusesController do allow(RemovalWorker).to receive(:perform_async) delete :destroy, params: { report_id: report, id: status } - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) expect(RemovalWorker). to have_received(:perform_async).with(status.id) end diff --git a/spec/controllers/admin/reports_controller_spec.rb b/spec/controllers/admin/reports_controller_spec.rb index 9be298df6..e50c02a72 100644 --- a/spec/controllers/admin/reports_controller_spec.rb +++ b/spec/controllers/admin/reports_controller_spec.rb @@ -18,7 +18,7 @@ describe Admin::ReportsController do reports = assigns(:reports).to_a expect(reports.size).to eq 1 expect(reports[0]).to eq specified - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end it 'returns http success with resolved filter' do @@ -31,7 +31,7 @@ describe Admin::ReportsController do expect(reports.size).to eq 1 expect(reports[0]).to eq specified - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end end @@ -42,7 +42,7 @@ describe Admin::ReportsController do get :show, params: { id: report } expect(assigns(:report)).to eq report - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end end @@ -52,7 +52,7 @@ describe Admin::ReportsController do report = Fabricate(:report) put :update, params: { id: report, outcome: 'unknown' } - expect(response).to have_http_status(:missing) + expect(response).to have_http_status(404) end end diff --git a/spec/controllers/admin/settings_controller_spec.rb b/spec/controllers/admin/settings_controller_spec.rb index 609bc762b..eaf99679a 100644 --- a/spec/controllers/admin/settings_controller_spec.rb +++ b/spec/controllers/admin/settings_controller_spec.rb @@ -14,7 +14,7 @@ RSpec.describe Admin::SettingsController, type: :controller do it 'returns http success' do get :edit - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end end diff --git a/spec/controllers/admin/statuses_controller_spec.rb b/spec/controllers/admin/statuses_controller_spec.rb index 1515e299b..cbaf39786 100644 --- a/spec/controllers/admin/statuses_controller_spec.rb +++ b/spec/controllers/admin/statuses_controller_spec.rb @@ -20,7 +20,7 @@ describe Admin::StatusesController do statuses = assigns(:statuses).to_a expect(statuses.size).to eq 2 - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end it 'returns http success with media' do @@ -28,7 +28,7 @@ describe Admin::StatusesController do statuses = assigns(:statuses).to_a expect(statuses.size).to eq 1 - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end end @@ -99,7 +99,7 @@ describe Admin::StatusesController do allow(RemovalWorker).to receive(:perform_async) delete :destroy, params: { account_id: account.id, id: status } - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) expect(RemovalWorker). to have_received(:perform_async).with(status.id) end diff --git a/spec/controllers/admin/subscriptions_controller_spec.rb b/spec/controllers/admin/subscriptions_controller_spec.rb index eb6f12b16..967152abe 100644 --- a/spec/controllers/admin/subscriptions_controller_spec.rb +++ b/spec/controllers/admin/subscriptions_controller_spec.rb @@ -26,7 +26,7 @@ RSpec.describe Admin::SubscriptionsController, type: :controller do expect(subscriptions.count).to eq 1 expect(subscriptions[0]).to eq specified - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end end end diff --git a/spec/controllers/api/base_controller_spec.rb b/spec/controllers/api/base_controller_spec.rb index 0c7ca8990..750ccc8cf 100644 --- a/spec/controllers/api/base_controller_spec.rb +++ b/spec/controllers/api/base_controller_spec.rb @@ -23,7 +23,7 @@ describe Api::BaseController do it 'does not protect from forgery' do ActionController::Base.allow_forgery_protection = true post 'success' - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end end diff --git a/spec/controllers/api/oembed_controller_spec.rb b/spec/controllers/api/oembed_controller_spec.rb index 7af4a6a5b..7fee15a35 100644 --- a/spec/controllers/api/oembed_controller_spec.rb +++ b/spec/controllers/api/oembed_controller_spec.rb @@ -13,7 +13,7 @@ RSpec.describe Api::OEmbedController, type: :controller do end it 'returns http success' do - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end end end diff --git a/spec/controllers/api/push_controller_spec.rb b/spec/controllers/api/push_controller_spec.rb index 647698bd1..d769d8554 100644 --- a/spec/controllers/api/push_controller_spec.rb +++ b/spec/controllers/api/push_controller_spec.rb @@ -23,7 +23,7 @@ RSpec.describe Api::PushController, type: :controller do '3600', nil ) - expect(response).to have_http_status(:success) + expect(response).to have_http_status(202) end end @@ -43,7 +43,7 @@ RSpec.describe Api::PushController, type: :controller do account, 'https://callback.host/api', ) - expect(response).to have_http_status(:success) + expect(response).to have_http_status(202) end end diff --git a/spec/controllers/api/salmon_controller_spec.rb b/spec/controllers/api/salmon_controller_spec.rb index 8af8b83a8..5f01f8073 100644 --- a/spec/controllers/api/salmon_controller_spec.rb +++ b/spec/controllers/api/salmon_controller_spec.rb @@ -24,7 +24,7 @@ RSpec.describe Api::SalmonController, type: :controller do end it 'returns http success' do - expect(response).to have_http_status(:success) + expect(response).to have_http_status(202) end it 'creates remote account' do diff --git a/spec/controllers/api/subscriptions_controller_spec.rb b/spec/controllers/api/subscriptions_controller_spec.rb index d90da9e32..48eb1fc64 100644 --- a/spec/controllers/api/subscriptions_controller_spec.rb +++ b/spec/controllers/api/subscriptions_controller_spec.rb @@ -12,7 +12,7 @@ RSpec.describe Api::SubscriptionsController, type: :controller do end it 'returns http success' do - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end it 'echoes back the challenge' do @@ -27,7 +27,7 @@ RSpec.describe Api::SubscriptionsController, type: :controller do end it 'returns http success' do - expect(response).to have_http_status(:missing) + expect(response).to have_http_status(404) end end end @@ -59,7 +59,7 @@ RSpec.describe Api::SubscriptionsController, type: :controller do end it 'returns http success' do - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end it 'creates statuses for feed' do diff --git a/spec/controllers/api/v1/accounts/credentials_controller_spec.rb b/spec/controllers/api/v1/accounts/credentials_controller_spec.rb index efbef439a..08010bcc1 100644 --- a/spec/controllers/api/v1/accounts/credentials_controller_spec.rb +++ b/spec/controllers/api/v1/accounts/credentials_controller_spec.rb @@ -14,7 +14,7 @@ describe Api::V1::Accounts::CredentialsController do describe 'GET #show' do it 'returns http success' do get :show - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end end @@ -36,7 +36,7 @@ describe Api::V1::Accounts::CredentialsController do end it 'returns http success' do - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end it 'updates account info' do diff --git a/spec/controllers/api/v1/accounts/follower_accounts_controller_spec.rb b/spec/controllers/api/v1/accounts/follower_accounts_controller_spec.rb index 33982cb8f..b47af4963 100644 --- a/spec/controllers/api/v1/accounts/follower_accounts_controller_spec.rb +++ b/spec/controllers/api/v1/accounts/follower_accounts_controller_spec.rb @@ -15,7 +15,7 @@ describe Api::V1::Accounts::FollowerAccountsController do it 'returns http success' do get :index, params: { account_id: user.account.id, limit: 1 } - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end end end diff --git a/spec/controllers/api/v1/accounts/following_accounts_controller_spec.rb b/spec/controllers/api/v1/accounts/following_accounts_controller_spec.rb index e22f54a31..29fd7cd5b 100644 --- a/spec/controllers/api/v1/accounts/following_accounts_controller_spec.rb +++ b/spec/controllers/api/v1/accounts/following_accounts_controller_spec.rb @@ -15,7 +15,7 @@ describe Api::V1::Accounts::FollowingAccountsController do it 'returns http success' do get :index, params: { account_id: user.account.id, limit: 1 } - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end end end diff --git a/spec/controllers/api/v1/accounts/lists_controller_spec.rb b/spec/controllers/api/v1/accounts/lists_controller_spec.rb index 0a372f65b..df9fe0e34 100644 --- a/spec/controllers/api/v1/accounts/lists_controller_spec.rb +++ b/spec/controllers/api/v1/accounts/lists_controller_spec.rb @@ -17,7 +17,7 @@ describe Api::V1::Accounts::ListsController do describe 'GET #index' do it 'returns http success' do get :index, params: { account_id: account.id } - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end end end diff --git a/spec/controllers/api/v1/accounts/relationships_controller_spec.rb b/spec/controllers/api/v1/accounts/relationships_controller_spec.rb index e0de790c8..7e350da7e 100644 --- a/spec/controllers/api/v1/accounts/relationships_controller_spec.rb +++ b/spec/controllers/api/v1/accounts/relationships_controller_spec.rb @@ -25,7 +25,7 @@ describe Api::V1::Accounts::RelationshipsController do end it 'returns http success' do - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end it 'returns JSON with correct data' do @@ -43,7 +43,7 @@ describe Api::V1::Accounts::RelationshipsController do end it 'returns http success' do - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end it 'returns JSON with correct data' do diff --git a/spec/controllers/api/v1/accounts/search_controller_spec.rb b/spec/controllers/api/v1/accounts/search_controller_spec.rb index 42cc3f64d..dbc4b9f3e 100644 --- a/spec/controllers/api/v1/accounts/search_controller_spec.rb +++ b/spec/controllers/api/v1/accounts/search_controller_spec.rb @@ -14,7 +14,7 @@ RSpec.describe Api::V1::Accounts::SearchController, type: :controller do it 'returns http success' do get :show, params: { q: 'query' } - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end end end diff --git a/spec/controllers/api/v1/accounts/statuses_controller_spec.rb b/spec/controllers/api/v1/accounts/statuses_controller_spec.rb index c49a77ac3..09bb46937 100644 --- a/spec/controllers/api/v1/accounts/statuses_controller_spec.rb +++ b/spec/controllers/api/v1/accounts/statuses_controller_spec.rb @@ -15,7 +15,7 @@ describe Api::V1::Accounts::StatusesController do it 'returns http success' do get :index, params: { account_id: user.account.id, limit: 1 } - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) expect(response.headers['Link'].links.size).to eq(2) end @@ -23,7 +23,7 @@ describe Api::V1::Accounts::StatusesController do it 'returns http success' do get :index, params: { account_id: user.account.id, only_media: true } - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end end @@ -35,7 +35,7 @@ describe Api::V1::Accounts::StatusesController do it 'returns http success' do get :index, params: { account_id: user.account.id, exclude_replies: true } - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end end @@ -47,7 +47,7 @@ describe Api::V1::Accounts::StatusesController do it 'returns http success' do get :index, params: { account_id: user.account.id, pinned: true } - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end end end diff --git a/spec/controllers/api/v1/accounts_controller_spec.rb b/spec/controllers/api/v1/accounts_controller_spec.rb index 053c53e5a..7a9e0f8e4 100644 --- a/spec/controllers/api/v1/accounts_controller_spec.rb +++ b/spec/controllers/api/v1/accounts_controller_spec.rb @@ -13,7 +13,7 @@ RSpec.describe Api::V1::AccountsController, type: :controller do describe 'GET #show' do it 'returns http success' do get :show, params: { id: user.account.id } - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end end @@ -28,7 +28,7 @@ RSpec.describe Api::V1::AccountsController, type: :controller do let(:locked) { false } it 'returns http success' do - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end it 'returns JSON with following=true and requested=false' do @@ -47,7 +47,7 @@ RSpec.describe Api::V1::AccountsController, type: :controller do let(:locked) { true } it 'returns http success' do - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end it 'returns JSON with following=false and requested=true' do @@ -72,7 +72,7 @@ RSpec.describe Api::V1::AccountsController, type: :controller do end it 'returns http success' do - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end it 'removes the following relation between user and target user' do @@ -89,7 +89,7 @@ RSpec.describe Api::V1::AccountsController, type: :controller do end it 'returns http success' do - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end it 'removes the following relation between user and target user' do @@ -110,7 +110,7 @@ RSpec.describe Api::V1::AccountsController, type: :controller do end it 'returns http success' do - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end it 'removes the blocking relation between user and target user' do @@ -127,7 +127,7 @@ RSpec.describe Api::V1::AccountsController, type: :controller do end it 'returns http success' do - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end it 'does not remove the following relation between user and target user' do @@ -152,7 +152,7 @@ RSpec.describe Api::V1::AccountsController, type: :controller do end it 'returns http success' do - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end it 'does not remove the following relation between user and target user' do @@ -177,7 +177,7 @@ RSpec.describe Api::V1::AccountsController, type: :controller do end it 'returns http success' do - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end it 'removes the muting relation between user and target user' do diff --git a/spec/controllers/api/v1/apps/credentials_controller_spec.rb b/spec/controllers/api/v1/apps/credentials_controller_spec.rb index 38f2a4e10..0f811d5f3 100644 --- a/spec/controllers/api/v1/apps/credentials_controller_spec.rb +++ b/spec/controllers/api/v1/apps/credentials_controller_spec.rb @@ -16,7 +16,7 @@ describe Api::V1::Apps::CredentialsController do end it 'returns http success' do - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end it 'does not contain client credentials' do diff --git a/spec/controllers/api/v1/apps_controller_spec.rb b/spec/controllers/api/v1/apps_controller_spec.rb index 1ad9d6383..60a4c3b41 100644 --- a/spec/controllers/api/v1/apps_controller_spec.rb +++ b/spec/controllers/api/v1/apps_controller_spec.rb @@ -9,7 +9,7 @@ RSpec.describe Api::V1::AppsController, type: :controller do end it 'returns http success' do - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end it 'creates an OAuth app' do diff --git a/spec/controllers/api/v1/blocks_controller_spec.rb b/spec/controllers/api/v1/blocks_controller_spec.rb index 9b2bbdf0e..eff5fb9da 100644 --- a/spec/controllers/api/v1/blocks_controller_spec.rb +++ b/spec/controllers/api/v1/blocks_controller_spec.rb @@ -47,7 +47,7 @@ RSpec.describe Api::V1::BlocksController, type: :controller do it 'returns http success' do get :index - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end end end diff --git a/spec/controllers/api/v1/custom_emojis_controller_spec.rb b/spec/controllers/api/v1/custom_emojis_controller_spec.rb index 9f3522812..fe8daa7c5 100644 --- a/spec/controllers/api/v1/custom_emojis_controller_spec.rb +++ b/spec/controllers/api/v1/custom_emojis_controller_spec.rb @@ -12,7 +12,7 @@ RSpec.describe Api::V1::CustomEmojisController, type: :controller do end it 'returns http success' do - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end end end diff --git a/spec/controllers/api/v1/domain_blocks_controller_spec.rb b/spec/controllers/api/v1/domain_blocks_controller_spec.rb index 3713931dc..bae4612a2 100644 --- a/spec/controllers/api/v1/domain_blocks_controller_spec.rb +++ b/spec/controllers/api/v1/domain_blocks_controller_spec.rb @@ -17,7 +17,7 @@ RSpec.describe Api::V1::DomainBlocksController, type: :controller do end it 'returns http success' do - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end it 'returns blocked domains' do @@ -31,7 +31,7 @@ RSpec.describe Api::V1::DomainBlocksController, type: :controller do end it 'returns http success' do - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end it 'creates a domain block' do @@ -45,7 +45,7 @@ RSpec.describe Api::V1::DomainBlocksController, type: :controller do end it 'returns http success' do - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end it 'deletes a domain block' do diff --git a/spec/controllers/api/v1/follow_requests_controller_spec.rb b/spec/controllers/api/v1/follow_requests_controller_spec.rb index 51df006a2..3c0b84af8 100644 --- a/spec/controllers/api/v1/follow_requests_controller_spec.rb +++ b/spec/controllers/api/v1/follow_requests_controller_spec.rb @@ -18,7 +18,7 @@ RSpec.describe Api::V1::FollowRequestsController, type: :controller do end it 'returns http success' do - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end end @@ -28,7 +28,7 @@ RSpec.describe Api::V1::FollowRequestsController, type: :controller do end it 'returns http success' do - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end it 'allows follower to follow' do @@ -42,7 +42,7 @@ RSpec.describe Api::V1::FollowRequestsController, type: :controller do end it 'returns http success' do - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end it 'removes follow request' do diff --git a/spec/controllers/api/v1/follows_controller_spec.rb b/spec/controllers/api/v1/follows_controller_spec.rb index ea9e76d68..38badb80a 100644 --- a/spec/controllers/api/v1/follows_controller_spec.rb +++ b/spec/controllers/api/v1/follows_controller_spec.rb @@ -24,7 +24,7 @@ RSpec.describe Api::V1::FollowsController, type: :controller do end it 'returns http success' do - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end it 'creates account for remote user' do @@ -45,7 +45,7 @@ RSpec.describe Api::V1::FollowsController, type: :controller do it 'returns http success if already following, too' do post :create, params: { uri: 'gargron@quitter.no' } - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end end end diff --git a/spec/controllers/api/v1/instances_controller_spec.rb b/spec/controllers/api/v1/instances_controller_spec.rb index eba233b05..7397d25d6 100644 --- a/spec/controllers/api/v1/instances_controller_spec.rb +++ b/spec/controllers/api/v1/instances_controller_spec.rb @@ -16,7 +16,7 @@ RSpec.describe Api::V1::InstancesController, type: :controller do it 'returns http success' do get :show - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end end end diff --git a/spec/controllers/api/v1/lists/accounts_controller_spec.rb b/spec/controllers/api/v1/lists/accounts_controller_spec.rb index 953e5909d..c37a481d6 100644 --- a/spec/controllers/api/v1/lists/accounts_controller_spec.rb +++ b/spec/controllers/api/v1/lists/accounts_controller_spec.rb @@ -17,7 +17,7 @@ describe Api::V1::Lists::AccountsController do it 'returns http success' do get :show, params: { list_id: list.id } - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end end @@ -30,7 +30,7 @@ describe Api::V1::Lists::AccountsController do end it 'returns http success' do - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end it 'adds account to the list' do @@ -44,7 +44,7 @@ describe Api::V1::Lists::AccountsController do end it 'returns http success' do - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end it 'removes account from the list' do diff --git a/spec/controllers/api/v1/lists_controller_spec.rb b/spec/controllers/api/v1/lists_controller_spec.rb index be08c221f..213429581 100644 --- a/spec/controllers/api/v1/lists_controller_spec.rb +++ b/spec/controllers/api/v1/lists_controller_spec.rb @@ -12,14 +12,14 @@ RSpec.describe Api::V1::ListsController, type: :controller do describe 'GET #index' do it 'returns http success' do get :index - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end end describe 'GET #show' do it 'returns http success' do get :show, params: { id: list.id } - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end end @@ -29,7 +29,7 @@ RSpec.describe Api::V1::ListsController, type: :controller do end it 'returns http success' do - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end it 'creates list' do @@ -44,7 +44,7 @@ RSpec.describe Api::V1::ListsController, type: :controller do end it 'returns http success' do - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end it 'updates the list' do @@ -58,7 +58,7 @@ RSpec.describe Api::V1::ListsController, type: :controller do end it 'returns http success' do - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end it 'deletes the list' do diff --git a/spec/controllers/api/v1/media_controller_spec.rb b/spec/controllers/api/v1/media_controller_spec.rb index 0e494638f..ce260eb90 100644 --- a/spec/controllers/api/v1/media_controller_spec.rb +++ b/spec/controllers/api/v1/media_controller_spec.rb @@ -30,7 +30,7 @@ RSpec.describe Api::V1::MediaController, type: :controller do end it 'returns http 422' do - expect(response).to have_http_status(:error) + expect(response).to have_http_status(500) end end end @@ -41,7 +41,7 @@ RSpec.describe Api::V1::MediaController, type: :controller do end it 'returns http success' do - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end it 'creates a media attachment' do @@ -63,7 +63,7 @@ RSpec.describe Api::V1::MediaController, type: :controller do end it 'returns http success' do - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end it 'creates a media attachment' do @@ -85,7 +85,7 @@ RSpec.describe Api::V1::MediaController, type: :controller do end xit 'returns http success' do - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end xit 'creates a media attachment' do diff --git a/spec/controllers/api/v1/mutes_controller_spec.rb b/spec/controllers/api/v1/mutes_controller_spec.rb index 7387b9d2d..6804c9395 100644 --- a/spec/controllers/api/v1/mutes_controller_spec.rb +++ b/spec/controllers/api/v1/mutes_controller_spec.rb @@ -15,7 +15,7 @@ RSpec.describe Api::V1::MutesController, type: :controller do it 'returns http success' do get :index, params: { limit: 1 } - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end end diff --git a/spec/controllers/api/v1/notifications_controller_spec.rb b/spec/controllers/api/v1/notifications_controller_spec.rb index f493d0d38..2e6163fcd 100644 --- a/spec/controllers/api/v1/notifications_controller_spec.rb +++ b/spec/controllers/api/v1/notifications_controller_spec.rb @@ -16,7 +16,7 @@ RSpec.describe Api::V1::NotificationsController, type: :controller do notification = Fabricate(:notification, account: user.account) get :show, params: { id: notification.id } - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end end @@ -25,7 +25,7 @@ RSpec.describe Api::V1::NotificationsController, type: :controller do notification = Fabricate(:notification, account: user.account) post :dismiss, params: { id: notification.id } - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) expect { notification.reload }.to raise_error(ActiveRecord::RecordNotFound) end end @@ -36,7 +36,7 @@ RSpec.describe Api::V1::NotificationsController, type: :controller do post :clear expect(notification.account.reload.notifications).to be_empty - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end end @@ -56,7 +56,7 @@ RSpec.describe Api::V1::NotificationsController, type: :controller do end it 'returns http success' do - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end it 'includes reblog' do @@ -82,7 +82,7 @@ RSpec.describe Api::V1::NotificationsController, type: :controller do end it 'returns http success' do - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end it 'includes reblog' do diff --git a/spec/controllers/api/v1/reports_controller_spec.rb b/spec/controllers/api/v1/reports_controller_spec.rb index 1eb5a4353..1e1ef9308 100644 --- a/spec/controllers/api/v1/reports_controller_spec.rb +++ b/spec/controllers/api/v1/reports_controller_spec.rb @@ -16,7 +16,7 @@ RSpec.describe Api::V1::ReportsController, type: :controller do it 'returns http success' do get :index - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end end @@ -31,7 +31,7 @@ RSpec.describe Api::V1::ReportsController, type: :controller do it 'creates a report' do expect(status.reload.account.targeted_reports).not_to be_empty - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end it 'sends e-mails to admins' do diff --git a/spec/controllers/api/v1/search_controller_spec.rb b/spec/controllers/api/v1/search_controller_spec.rb index ff0c254b1..024703867 100644 --- a/spec/controllers/api/v1/search_controller_spec.rb +++ b/spec/controllers/api/v1/search_controller_spec.rb @@ -16,7 +16,7 @@ RSpec.describe Api::V1::SearchController, type: :controller do it 'returns http success' do get :index, params: { q: 'test' } - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end end end diff --git a/spec/controllers/api/v1/statuses/favourited_by_accounts_controller_spec.rb b/spec/controllers/api/v1/statuses/favourited_by_accounts_controller_spec.rb index 556731d57..c873e05dd 100644 --- a/spec/controllers/api/v1/statuses/favourited_by_accounts_controller_spec.rb +++ b/spec/controllers/api/v1/statuses/favourited_by_accounts_controller_spec.rb @@ -21,7 +21,7 @@ RSpec.describe Api::V1::Statuses::FavouritedByAccountsController, type: :control it 'returns http success' do get :index, params: { status_id: status.id, limit: 1 } - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) expect(response.headers['Link'].links.size).to eq(2) end end @@ -43,7 +43,7 @@ RSpec.describe Api::V1::Statuses::FavouritedByAccountsController, type: :control it 'returns http unautharized' do get :index, params: { status_id: status.id } - expect(response).to have_http_status(:missing) + expect(response).to have_http_status(404) end end end @@ -58,7 +58,7 @@ RSpec.describe Api::V1::Statuses::FavouritedByAccountsController, type: :control it 'returns http success' do get :index, params: { status_id: status.id } - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end end end diff --git a/spec/controllers/api/v1/statuses/favourites_controller_spec.rb b/spec/controllers/api/v1/statuses/favourites_controller_spec.rb index aba7cd458..53f602616 100644 --- a/spec/controllers/api/v1/statuses/favourites_controller_spec.rb +++ b/spec/controllers/api/v1/statuses/favourites_controller_spec.rb @@ -22,7 +22,7 @@ describe Api::V1::Statuses::FavouritesController do end it 'returns http success' do - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end it 'updates the favourites count' do @@ -51,7 +51,7 @@ describe Api::V1::Statuses::FavouritesController do end it 'returns http success' do - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end it 'updates the favourites count' do diff --git a/spec/controllers/api/v1/statuses/mutes_controller_spec.rb b/spec/controllers/api/v1/statuses/mutes_controller_spec.rb index 54c594e92..13b4625d1 100644 --- a/spec/controllers/api/v1/statuses/mutes_controller_spec.rb +++ b/spec/controllers/api/v1/statuses/mutes_controller_spec.rb @@ -22,7 +22,7 @@ describe Api::V1::Statuses::MutesController do end it 'returns http success' do - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end it 'creates a conversation mute' do @@ -39,7 +39,7 @@ describe Api::V1::Statuses::MutesController do end it 'returns http success' do - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end it 'destroys the conversation mute' do diff --git a/spec/controllers/api/v1/statuses/pins_controller_spec.rb b/spec/controllers/api/v1/statuses/pins_controller_spec.rb index 79005c9de..8f5b0800b 100644 --- a/spec/controllers/api/v1/statuses/pins_controller_spec.rb +++ b/spec/controllers/api/v1/statuses/pins_controller_spec.rb @@ -22,7 +22,7 @@ describe Api::V1::Statuses::PinsController do end it 'returns http success' do - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end it 'updates the pinned attribute' do @@ -46,7 +46,7 @@ describe Api::V1::Statuses::PinsController do end it 'returns http success' do - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end it 'updates the pinned attribute' do diff --git a/spec/controllers/api/v1/statuses/reblogged_by_accounts_controller_spec.rb b/spec/controllers/api/v1/statuses/reblogged_by_accounts_controller_spec.rb index ba022a96e..9c0c2b60c 100644 --- a/spec/controllers/api/v1/statuses/reblogged_by_accounts_controller_spec.rb +++ b/spec/controllers/api/v1/statuses/reblogged_by_accounts_controller_spec.rb @@ -21,7 +21,7 @@ RSpec.describe Api::V1::Statuses::RebloggedByAccountsController, type: :controll it 'returns http success' do get :index, params: { status_id: status.id, limit: 1 } - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) expect(response.headers['Link'].links.size).to eq(2) end end @@ -42,7 +42,7 @@ RSpec.describe Api::V1::Statuses::RebloggedByAccountsController, type: :controll it 'returns http unautharized' do get :index, params: { status_id: status.id } - expect(response).to have_http_status(:missing) + expect(response).to have_http_status(404) end end end @@ -57,7 +57,7 @@ RSpec.describe Api::V1::Statuses::RebloggedByAccountsController, type: :controll it 'returns http success' do get :index, params: { status_id: status.id } - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end end end diff --git a/spec/controllers/api/v1/statuses/reblogs_controller_spec.rb b/spec/controllers/api/v1/statuses/reblogs_controller_spec.rb index 7417ff672..e60f8da2a 100644 --- a/spec/controllers/api/v1/statuses/reblogs_controller_spec.rb +++ b/spec/controllers/api/v1/statuses/reblogs_controller_spec.rb @@ -22,7 +22,7 @@ describe Api::V1::Statuses::ReblogsController do end it 'returns http success' do - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end it 'updates the reblogs count' do @@ -51,7 +51,7 @@ describe Api::V1::Statuses::ReblogsController do end it 'returns http success' do - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end it 'updates the reblogs count' do diff --git a/spec/controllers/api/v1/statuses_controller_spec.rb b/spec/controllers/api/v1/statuses_controller_spec.rb index a36265395..27e4f4eb2 100644 --- a/spec/controllers/api/v1/statuses_controller_spec.rb +++ b/spec/controllers/api/v1/statuses_controller_spec.rb @@ -17,7 +17,7 @@ RSpec.describe Api::V1::StatusesController, type: :controller do it 'returns http success' do get :show, params: { id: status.id } - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end end @@ -30,7 +30,7 @@ RSpec.describe Api::V1::StatusesController, type: :controller do it 'returns http success' do get :context, params: { id: status.id } - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end end @@ -40,7 +40,7 @@ RSpec.describe Api::V1::StatusesController, type: :controller do end it 'returns http success' do - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end end @@ -52,7 +52,7 @@ RSpec.describe Api::V1::StatusesController, type: :controller do end it 'returns http success' do - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end it 'removes the status' do @@ -72,7 +72,7 @@ RSpec.describe Api::V1::StatusesController, type: :controller do describe 'GET #show' do it 'returns http unautharized' do get :show, params: { id: status.id } - expect(response).to have_http_status(:missing) + expect(response).to have_http_status(404) end end @@ -83,14 +83,14 @@ RSpec.describe Api::V1::StatusesController, type: :controller do it 'returns http unautharized' do get :context, params: { id: status.id } - expect(response).to have_http_status(:missing) + expect(response).to have_http_status(404) end end describe 'GET #card' do it 'returns http unautharized' do get :card, params: { id: status.id } - expect(response).to have_http_status(:missing) + expect(response).to have_http_status(404) end end end @@ -101,7 +101,7 @@ RSpec.describe Api::V1::StatusesController, type: :controller do describe 'GET #show' do it 'returns http success' do get :show, params: { id: status.id } - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end end @@ -112,14 +112,14 @@ RSpec.describe Api::V1::StatusesController, type: :controller do it 'returns http success' do get :context, params: { id: status.id } - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end end describe 'GET #card' do it 'returns http success' do get :card, params: { id: status.id } - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end end end diff --git a/spec/controllers/api/v1/timelines/home_controller_spec.rb b/spec/controllers/api/v1/timelines/home_controller_spec.rb index 4d4523520..85b031641 100644 --- a/spec/controllers/api/v1/timelines/home_controller_spec.rb +++ b/spec/controllers/api/v1/timelines/home_controller_spec.rb @@ -23,7 +23,7 @@ describe Api::V1::Timelines::HomeController do it 'returns http success' do get :show - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) expect(response.headers['Link'].links.size).to eq(2) end end diff --git a/spec/controllers/api/v1/timelines/list_controller_spec.rb b/spec/controllers/api/v1/timelines/list_controller_spec.rb index 07eba955a..1729217c9 100644 --- a/spec/controllers/api/v1/timelines/list_controller_spec.rb +++ b/spec/controllers/api/v1/timelines/list_controller_spec.rb @@ -24,7 +24,7 @@ describe Api::V1::Timelines::ListController do it 'returns http success' do get :show, params: { id: list.id } - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end end end diff --git a/spec/controllers/api/v1/timelines/public_controller_spec.rb b/spec/controllers/api/v1/timelines/public_controller_spec.rb index 3acf2e267..68d87bbcb 100644 --- a/spec/controllers/api/v1/timelines/public_controller_spec.rb +++ b/spec/controllers/api/v1/timelines/public_controller_spec.rb @@ -22,7 +22,7 @@ describe Api::V1::Timelines::PublicController do it 'returns http success' do get :show - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) expect(response.headers['Link'].links.size).to eq(2) end end @@ -35,7 +35,7 @@ describe Api::V1::Timelines::PublicController do it 'returns http success' do get :show, params: { local: true } - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) expect(response.headers['Link'].links.size).to eq(2) end end @@ -48,7 +48,7 @@ describe Api::V1::Timelines::PublicController do it 'returns http success' do get :show - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) expect(response.headers['Link']).to be_nil 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 6c66ee58e..472779f54 100644 --- a/spec/controllers/api/v1/timelines/tag_controller_spec.rb +++ b/spec/controllers/api/v1/timelines/tag_controller_spec.rb @@ -21,7 +21,7 @@ describe Api::V1::Timelines::TagController do it 'returns http success' do get :show, params: { id: 'test' } - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) expect(response.headers['Link'].links.size).to eq(2) end end @@ -33,7 +33,7 @@ describe Api::V1::Timelines::TagController do describe 'GET #show' do it 'returns http success' do get :show, params: { id: 'test' } - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) expect(response.headers['Link']).to be_nil end end diff --git a/spec/controllers/api/web/settings_controller_spec.rb b/spec/controllers/api/web/settings_controller_spec.rb index ff211c7b1..815da04c4 100644 --- a/spec/controllers/api/web/settings_controller_spec.rb +++ b/spec/controllers/api/web/settings_controller_spec.rb @@ -13,7 +13,7 @@ describe Api::Web::SettingsController do patch :update, format: :json, params: { data: { 'onboarded' => true } } user.reload - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) expect(user_web_setting.data['onboarded']).to eq('true') end diff --git a/spec/controllers/application_controller_spec.rb b/spec/controllers/application_controller_spec.rb index 3e4d27e05..c6c78d3f7 100644 --- a/spec/controllers/application_controller_spec.rb +++ b/spec/controllers/application_controller_spec.rb @@ -51,7 +51,7 @@ describe ApplicationController, type: :controller do routes.draw { get 'success' => 'anonymous#success' } allow(Rails.env).to receive(:production?).and_return(false) get 'success' - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end it "forces ssl if Rails.env.production? is 'true'" do @@ -145,13 +145,13 @@ describe ApplicationController, type: :controller do it 'does nothing if not signed in' do get 'success' - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end it 'does nothing if user who signed in is not suspended' do sign_in(Fabricate(:user, account: Fabricate(:account, suspended: false))) get 'success' - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end it 'returns http 403 if user who signed in is suspended' do diff --git a/spec/controllers/auth/confirmations_controller_spec.rb b/spec/controllers/auth/confirmations_controller_spec.rb index 80a06c43a..b3af5e0ec 100644 --- a/spec/controllers/auth/confirmations_controller_spec.rb +++ b/spec/controllers/auth/confirmations_controller_spec.rb @@ -7,7 +7,7 @@ describe Auth::ConfirmationsController, type: :controller do it 'returns http success' do @request.env['devise.mapping'] = Devise.mappings[:user] get :new - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end end diff --git a/spec/controllers/auth/passwords_controller_spec.rb b/spec/controllers/auth/passwords_controller_spec.rb index 992d2e29d..dcfdebb17 100644 --- a/spec/controllers/auth/passwords_controller_spec.rb +++ b/spec/controllers/auth/passwords_controller_spec.rb @@ -9,7 +9,7 @@ describe Auth::PasswordsController, type: :controller do it 'returns http success' do @request.env['devise.mapping'] = Devise.mappings[:user] get :new - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end end @@ -24,7 +24,7 @@ describe Auth::PasswordsController, type: :controller do context 'with valid reset_password_token' do it 'returns http success' do get :edit, params: { reset_password_token: @token } - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end end diff --git a/spec/controllers/auth/registrations_controller_spec.rb b/spec/controllers/auth/registrations_controller_spec.rb index 97d2c53df..eeb01d5ad 100644 --- a/spec/controllers/auth/registrations_controller_spec.rb +++ b/spec/controllers/auth/registrations_controller_spec.rb @@ -35,7 +35,7 @@ RSpec.describe Auth::RegistrationsController, type: :controller do request.env["devise.mapping"] = Devise.mappings[:user] sign_in(Fabricate(:user)) get :edit - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end end @@ -44,7 +44,7 @@ RSpec.describe Auth::RegistrationsController, type: :controller do request.env["devise.mapping"] = Devise.mappings[:user] sign_in(Fabricate(:user), scope: :user) post :update - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end end @@ -63,7 +63,7 @@ RSpec.describe Auth::RegistrationsController, type: :controller do it 'returns http success' do Setting.open_registrations = true get :new - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end end @@ -73,6 +73,12 @@ RSpec.describe Auth::RegistrationsController, type: :controller do describe 'POST #create' do let(:accept_language) { Rails.application.config.i18n.available_locales.sample.to_s } + around do |example| + current_locale = I18n.locale + example.run + I18n.locale = current_locale + end + before { request.env["devise.mapping"] = Devise.mappings[:user] } context do diff --git a/spec/controllers/auth/sessions_controller_spec.rb b/spec/controllers/auth/sessions_controller_spec.rb index d5fed17d6..97719a606 100644 --- a/spec/controllers/auth/sessions_controller_spec.rb +++ b/spec/controllers/auth/sessions_controller_spec.rb @@ -12,7 +12,7 @@ RSpec.describe Auth::SessionsController, type: :controller do it 'returns http success' do get :new - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end end diff --git a/spec/controllers/authorize_follows_controller_spec.rb b/spec/controllers/authorize_follows_controller_spec.rb index b1cbef7ea..52971c724 100644 --- a/spec/controllers/authorize_follows_controller_spec.rb +++ b/spec/controllers/authorize_follows_controller_spec.rb @@ -47,7 +47,7 @@ describe AuthorizeFollowsController do get :show, params: { acct: 'http://example.com' } - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) expect(assigns(:account)).to eq account end @@ -59,7 +59,7 @@ describe AuthorizeFollowsController do get :show, params: { acct: 'acct:found@hostname' } - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) expect(assigns(:account)).to eq account end end diff --git a/spec/controllers/concerns/account_controller_concern_spec.rb b/spec/controllers/concerns/account_controller_concern_spec.rb index ae46f9ba6..93685103f 100644 --- a/spec/controllers/concerns/account_controller_concern_spec.rb +++ b/spec/controllers/concerns/account_controller_concern_spec.rb @@ -39,7 +39,7 @@ describe ApplicationController, type: :controller do it 'returns http success' do account = Fabricate(:account) get 'success', params: { account_username: account.username } - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end end end diff --git a/spec/controllers/concerns/export_controller_concern_spec.rb b/spec/controllers/concerns/export_controller_concern_spec.rb index 9d6f782b9..6a13db69d 100644 --- a/spec/controllers/concerns/export_controller_concern_spec.rb +++ b/spec/controllers/concerns/export_controller_concern_spec.rb @@ -19,7 +19,7 @@ describe ApplicationController, type: :controller do sign_in user get :index, format: :csv - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) expect(response.content_type).to eq 'text/csv' expect(response.headers['Content-Disposition']).to eq 'attachment; filename="anonymous.csv"' expect(response.body).to eq user.account.username diff --git a/spec/controllers/concerns/localized_spec.rb b/spec/controllers/concerns/localized_spec.rb index f71c96aff..8c80b7d2a 100644 --- a/spec/controllers/concerns/localized_spec.rb +++ b/spec/controllers/concerns/localized_spec.rb @@ -11,13 +11,17 @@ describe ApplicationController, type: :controller do end end + around do |example| + current_locale = I18n.locale + example.run + I18n.locale = current_locale + end + before do routes.draw { get 'success' => 'anonymous#success' } end shared_examples 'default locale' do - after { I18n.locale = I18n.default_locale } - it 'sets available and preferred language' do request.headers['Accept-Language'] = 'ca-ES, fa' get 'success' diff --git a/spec/controllers/follower_accounts_controller_spec.rb b/spec/controllers/follower_accounts_controller_spec.rb index b9b7fef73..3a42a6e18 100644 --- a/spec/controllers/follower_accounts_controller_spec.rb +++ b/spec/controllers/follower_accounts_controller_spec.rb @@ -19,7 +19,7 @@ describe FollowerAccountsController do expect(assigned[0]).to eq follow1 expect(assigned[1]).to eq follow0 - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end end end diff --git a/spec/controllers/following_accounts_controller_spec.rb b/spec/controllers/following_accounts_controller_spec.rb index 55e7265c7..33376365d 100644 --- a/spec/controllers/following_accounts_controller_spec.rb +++ b/spec/controllers/following_accounts_controller_spec.rb @@ -19,7 +19,7 @@ describe FollowingAccountsController do expect(assigned[0]).to eq follow1 expect(assigned[1]).to eq follow0 - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end end end diff --git a/spec/controllers/manifests_controller_spec.rb b/spec/controllers/manifests_controller_spec.rb index 71967e4f0..a549adef3 100644 --- a/spec/controllers/manifests_controller_spec.rb +++ b/spec/controllers/manifests_controller_spec.rb @@ -9,7 +9,7 @@ describe ManifestsController do end it 'returns http success' do - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end end end diff --git a/spec/controllers/media_controller_spec.rb b/spec/controllers/media_controller_spec.rb index 5b03899e4..ac44a76f2 100644 --- a/spec/controllers/media_controller_spec.rb +++ b/spec/controllers/media_controller_spec.rb @@ -18,13 +18,13 @@ describe MediaController do media_attachment = Fabricate(:media_attachment, status: nil) get :show, params: { id: media_attachment.to_param } - expect(response).to have_http_status(:missing) + expect(response).to have_http_status(404) end it 'raises when shortcode cant be found' do get :show, params: { id: 'missing' } - expect(response).to have_http_status(:missing) + expect(response).to have_http_status(404) end it 'raises when not permitted to view' do @@ -33,7 +33,7 @@ describe MediaController do allow_any_instance_of(MediaController).to receive(:authorize).and_raise(ActiveRecord::RecordNotFound) get :show, params: { id: media_attachment.to_param } - expect(response).to have_http_status(:missing) + expect(response).to have_http_status(404) end end end diff --git a/spec/controllers/oauth/authorizations_controller_spec.rb b/spec/controllers/oauth/authorizations_controller_spec.rb index 5c2a62b48..91c2d03ef 100644 --- a/spec/controllers/oauth/authorizations_controller_spec.rb +++ b/spec/controllers/oauth/authorizations_controller_spec.rb @@ -26,7 +26,7 @@ RSpec.describe Oauth::AuthorizationsController, type: :controller do it 'returns http success' do subject - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end it 'gives options to authorize and deny' do diff --git a/spec/controllers/oauth/authorized_applications_controller_spec.rb b/spec/controllers/oauth/authorized_applications_controller_spec.rb index 2a2b92283..f967b507f 100644 --- a/spec/controllers/oauth/authorized_applications_controller_spec.rb +++ b/spec/controllers/oauth/authorized_applications_controller_spec.rb @@ -24,7 +24,7 @@ describe Oauth::AuthorizedApplicationsController do it 'returns http success' do subject - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end include_examples 'stores location for user' diff --git a/spec/controllers/remote_follow_controller_spec.rb b/spec/controllers/remote_follow_controller_spec.rb index 86b1eb8d0..5088c2e65 100644 --- a/spec/controllers/remote_follow_controller_spec.rb +++ b/spec/controllers/remote_follow_controller_spec.rb @@ -10,7 +10,7 @@ describe RemoteFollowController do account = Fabricate(:account) get :new, params: { account_username: account.to_param } - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) expect(response).to render_template(:new) expect(assigns(:remote_follow).acct).to be_nil end @@ -20,7 +20,7 @@ describe RemoteFollowController do account = Fabricate(:account) get :new, params: { account_username: account.to_param } - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) expect(response).to render_template(:new) expect(assigns(:remote_follow).acct).to eq 'user@example.com' end diff --git a/spec/controllers/settings/applications_controller_spec.rb b/spec/controllers/settings/applications_controller_spec.rb index 90e6a63d5..f87107695 100644 --- a/spec/controllers/settings/applications_controller_spec.rb +++ b/spec/controllers/settings/applications_controller_spec.rb @@ -15,7 +15,7 @@ describe Settings::ApplicationsController do it 'shows apps' do get :index - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) expect(assigns(:applications)).to include(app) expect(assigns(:applications)).to_not include(other_app) end @@ -25,7 +25,7 @@ describe Settings::ApplicationsController do describe 'GET #show' do it 'returns http success' do get :show, params: { id: app.id } - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) expect(assigns[:application]).to eql(app) end @@ -40,7 +40,7 @@ describe Settings::ApplicationsController do describe 'GET #new' do it 'works' do get :new - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end end @@ -102,7 +102,7 @@ describe Settings::ApplicationsController do end it 'returns http success' do - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end it 'renders form again' do @@ -151,7 +151,7 @@ describe Settings::ApplicationsController do end it 'returns http success' do - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end it 'renders form again' do diff --git a/spec/controllers/settings/deletes_controller_spec.rb b/spec/controllers/settings/deletes_controller_spec.rb index 9b55090df..35fd64e9b 100644 --- a/spec/controllers/settings/deletes_controller_spec.rb +++ b/spec/controllers/settings/deletes_controller_spec.rb @@ -13,7 +13,7 @@ describe Settings::DeletesController do it 'renders confirmation page' do get :show - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end end diff --git a/spec/controllers/settings/exports_controller_spec.rb b/spec/controllers/settings/exports_controller_spec.rb index 19cb0abda..b7cab4d8f 100644 --- a/spec/controllers/settings/exports_controller_spec.rb +++ b/spec/controllers/settings/exports_controller_spec.rb @@ -17,7 +17,7 @@ describe Settings::ExportsController do export = assigns(:export) expect(export).to be_instance_of Export expect(export.account).to eq user.account - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end end diff --git a/spec/controllers/settings/follower_domains_controller_spec.rb b/spec/controllers/settings/follower_domains_controller_spec.rb index 333223c61..6d415a654 100644 --- a/spec/controllers/settings/follower_domains_controller_spec.rb +++ b/spec/controllers/settings/follower_domains_controller_spec.rb @@ -36,7 +36,7 @@ describe Settings::FollowerDomainsController do it 'returns http success' do sign_in user, scope: :user subject - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end include_examples 'authenticate user' diff --git a/spec/controllers/settings/imports_controller_spec.rb b/spec/controllers/settings/imports_controller_spec.rb index 59b10e0da..7a9b02195 100644 --- a/spec/controllers/settings/imports_controller_spec.rb +++ b/spec/controllers/settings/imports_controller_spec.rb @@ -10,7 +10,7 @@ RSpec.describe Settings::ImportsController, type: :controller do describe "GET #show" do it "returns http success" do get :show - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end end diff --git a/spec/controllers/settings/notifications_controller_spec.rb b/spec/controllers/settings/notifications_controller_spec.rb index 0bd993448..981ef674e 100644 --- a/spec/controllers/settings/notifications_controller_spec.rb +++ b/spec/controllers/settings/notifications_controller_spec.rb @@ -12,7 +12,7 @@ describe Settings::NotificationsController do describe 'GET #show' do it 'returns http success' do get :show - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end end diff --git a/spec/controllers/settings/preferences_controller_spec.rb b/spec/controllers/settings/preferences_controller_spec.rb index 0f9431673..7877c7362 100644 --- a/spec/controllers/settings/preferences_controller_spec.rb +++ b/spec/controllers/settings/preferences_controller_spec.rb @@ -12,7 +12,7 @@ describe Settings::PreferencesController do describe 'GET #show' do it 'returns http success' do get :show - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end end diff --git a/spec/controllers/settings/profiles_controller_spec.rb b/spec/controllers/settings/profiles_controller_spec.rb index ee3315be6..a453200af 100644 --- a/spec/controllers/settings/profiles_controller_spec.rb +++ b/spec/controllers/settings/profiles_controller_spec.rb @@ -11,7 +11,7 @@ RSpec.describe Settings::ProfilesController, type: :controller do describe "GET #show" do it "returns http success" do get :show - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end end diff --git a/spec/controllers/settings/two_factor_authentication/confirmations_controller_spec.rb b/spec/controllers/settings/two_factor_authentication/confirmations_controller_spec.rb index aee82a3d8..7612bf90e 100644 --- a/spec/controllers/settings/two_factor_authentication/confirmations_controller_spec.rb +++ b/spec/controllers/settings/two_factor_authentication/confirmations_controller_spec.rb @@ -15,7 +15,7 @@ describe Settings::TwoFactorAuthentication::ConfirmationsController do expect(assigns(:confirmation)).to be_instance_of Form::TwoFactorConfirmation expect(assigns(:provision_url)).to eq 'otpauth://totp/local-part@domain?secret=thisisasecretforthespecofnewview&issuer=cb6e6126.ngrok.io' expect(assigns(:qrcode)).to be_instance_of RQRCode::QRCode - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) expect(response).to render_template(:new) end end @@ -71,7 +71,7 @@ describe Settings::TwoFactorAuthentication::ConfirmationsController do expect(assigns(:recovery_codes)).to eq otp_backup_codes expect(flash[:notice]).to eq 'Two-factor authentication successfully enabled' - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) expect(response).to render_template('settings/two_factor_authentication/recovery_codes/index') end end diff --git a/spec/controllers/settings/two_factor_authentication/recovery_codes_controller_spec.rb b/spec/controllers/settings/two_factor_authentication/recovery_codes_controller_spec.rb index aa28cdf3f..c04760e53 100644 --- a/spec/controllers/settings/two_factor_authentication/recovery_codes_controller_spec.rb +++ b/spec/controllers/settings/two_factor_authentication/recovery_codes_controller_spec.rb @@ -19,7 +19,7 @@ describe Settings::TwoFactorAuthentication::RecoveryCodesController do expect(assigns(:recovery_codes)).to eq otp_backup_codes expect(flash[:notice]).to eq 'Recovery codes successfully regenerated' - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) expect(response).to render_template(:index) end diff --git a/spec/controllers/settings/two_factor_authentications_controller_spec.rb b/spec/controllers/settings/two_factor_authentications_controller_spec.rb index 6c49f6f0d..9f27222ad 100644 --- a/spec/controllers/settings/two_factor_authentications_controller_spec.rb +++ b/spec/controllers/settings/two_factor_authentications_controller_spec.rb @@ -18,7 +18,7 @@ describe Settings::TwoFactorAuthenticationsController do user.update(otp_required_for_login: true) get :show - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end end @@ -27,7 +27,7 @@ describe Settings::TwoFactorAuthenticationsController do user.update(otp_required_for_login: false) get :show - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end end end diff --git a/spec/controllers/statuses_controller_spec.rb b/spec/controllers/statuses_controller_spec.rb index 95fb4d594..b4f3c5a08 100644 --- a/spec/controllers/statuses_controller_spec.rb +++ b/spec/controllers/statuses_controller_spec.rb @@ -82,10 +82,53 @@ describe StatusesController do expect(assigns(:ancestors)).to eq [] end + it 'assigns @descendant_threads for a thread with several statuses' do + status = Fabricate(:status) + child = Fabricate(:status, in_reply_to_id: status.id) + grandchild = Fabricate(:status, in_reply_to_id: child.id) + + get :show, params: { account_username: status.account.username, id: status.id } + + expect(assigns(:descendant_threads)[0][:statuses].pluck(:id)).to eq [child.id, grandchild.id] + end + + it 'assigns @descendant_threads for several threads sharing the same descendant' do + status = Fabricate(:status) + child = Fabricate(:status, in_reply_to_id: status.id) + grandchildren = 2.times.map { Fabricate(:status, in_reply_to_id: child.id) } + + get :show, params: { account_username: status.account.username, id: status.id } + + expect(assigns(:descendant_threads)[0][:statuses].pluck(:id)).to eq [child.id, grandchildren[0].id] + expect(assigns(:descendant_threads)[1][:statuses].pluck(:id)).to eq [grandchildren[1].id] + end + + it 'assigns @max_descendant_thread_id for the last thread if it is hitting the status limit' do + stub_const 'StatusesController::DESCENDANTS_LIMIT', 1 + status = Fabricate(:status) + child = Fabricate(:status, in_reply_to_id: status.id) + + get :show, params: { account_username: status.account.username, id: status.id } + + expect(assigns(:descendant_threads)).to eq [] + expect(assigns(:max_descendant_thread_id)).to eq child.id + end + + it 'assigns @descendant_threads for threads with :next_status key if they are hitting the depth limit' do + stub_const 'StatusesController::DESCENDANTS_DEPTH_LIMIT', 1 + status = Fabricate(:status) + child = Fabricate(:status, in_reply_to_id: status.id) + + get :show, params: { account_username: status.account.username, id: status.id } + + expect(assigns(:descendant_threads)[0][:statuses].pluck(:id)).not_to include child.id + expect(assigns(:descendant_threads)[0][:next_status].id).to eq child.id + end + it 'returns a success' do status = Fabricate(:status) get :show, params: { account_username: status.account.username, id: status.id } - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end it 'renders stream_entries/show' do diff --git a/spec/controllers/stream_entries_controller_spec.rb b/spec/controllers/stream_entries_controller_spec.rb index 665c5b747..534bc393d 100644 --- a/spec/controllers/stream_entries_controller_spec.rb +++ b/spec/controllers/stream_entries_controller_spec.rb @@ -77,7 +77,7 @@ RSpec.describe StreamEntriesController, type: :controller do it 'returns http success with Atom' do status = Fabricate(:status) get :show, params: { account_username: status.account.username, id: status.stream_entry.id }, format: 'atom' - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end end diff --git a/spec/controllers/tags_controller_spec.rb b/spec/controllers/tags_controller_spec.rb index b04666c0f..33ccaed61 100644 --- a/spec/controllers/tags_controller_spec.rb +++ b/spec/controllers/tags_controller_spec.rb @@ -12,7 +12,7 @@ RSpec.describe TagsController, type: :controller do context 'when tag exists' do it 'returns http success' do get :show, params: { id: 'test', max_id: late.id } - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) end it 'renders application layout' do @@ -25,7 +25,7 @@ RSpec.describe TagsController, type: :controller do it 'returns http missing for non-existent tag' do get :show, params: { id: 'none' } - expect(response).to have_http_status(:missing) + expect(response).to have_http_status(404) end end end diff --git a/spec/controllers/well_known/host_meta_controller_spec.rb b/spec/controllers/well_known/host_meta_controller_spec.rb index 87c1485ed..b43ae19d8 100644 --- a/spec/controllers/well_known/host_meta_controller_spec.rb +++ b/spec/controllers/well_known/host_meta_controller_spec.rb @@ -7,10 +7,10 @@ describe WellKnown::HostMetaController, type: :controller do it 'returns http success' do get :show, format: :xml - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) expect(response.content_type).to eq 'application/xrd+xml' expect(response.body).to eq <<XML -<?xml version="1.0"?> +<?xml version="1.0" encoding="UTF-8"?> <XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0"> <Link rel="lrdd" type="application/xrd+xml" template="https://cb6e6126.ngrok.io/.well-known/webfinger?resource={uri}"/> </XRD> diff --git a/spec/controllers/well_known/webfinger_controller_spec.rb b/spec/controllers/well_known/webfinger_controller_spec.rb index 466f87c45..b05745ea3 100644 --- a/spec/controllers/well_known/webfinger_controller_spec.rb +++ b/spec/controllers/well_known/webfinger_controller_spec.rb @@ -50,7 +50,7 @@ PEM json = body_as_json - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) expect(response.content_type).to eq 'application/jrd+json' expect(json[:subject]).to eq 'acct:alice@cb6e6126.ngrok.io' expect(json[:aliases]).to include('https://cb6e6126.ngrok.io/@alice', 'https://cb6e6126.ngrok.io/users/alice') @@ -61,7 +61,7 @@ PEM xml = Nokogiri::XML(response.body) - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) expect(response.content_type).to eq 'application/xrd+xml' expect(xml.at_xpath('//xmlns:Subject').content).to eq 'acct:alice@cb6e6126.ngrok.io' expect(xml.xpath('//xmlns:Alias').map(&:content)).to include('https://cb6e6126.ngrok.io/@alice', 'https://cb6e6126.ngrok.io/users/alice') @@ -81,7 +81,7 @@ PEM json = body_as_json - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) expect(response.content_type).to eq 'application/jrd+json' expect(json[:subject]).to eq 'acct:alice@cb6e6126.ngrok.io' expect(json[:aliases]).to include('https://cb6e6126.ngrok.io/@alice', 'https://cb6e6126.ngrok.io/users/alice') diff --git a/spec/fabricators/account_fabricator.rb b/spec/fabricators/account_fabricator.rb index 446f8ea27..7aa983f82 100644 --- a/spec/fabricators/account_fabricator.rb +++ b/spec/fabricators/account_fabricator.rb @@ -1,4 +1,10 @@ +keypair = OpenSSL::PKey::RSA.new(2048) +public_key = keypair.public_key.to_pem +private_key = keypair.to_pem + Fabricator(:account) do - username { sequence(:username) { |i| "#{Faker::Internet.user_name(nil, %w(_))}#{i}" } } + username { sequence(:username) { |i| "#{Faker::Internet.user_name(nil, %w(_))}#{i}" } } last_webfingered_at { Time.now.utc } + public_key { public_key } + private_key { private_key} end diff --git a/spec/fixtures/requests/activitypub-actor-individual.txt b/spec/fixtures/requests/activitypub-actor-individual.txt new file mode 100644 index 000000000..74411e544 --- /dev/null +++ b/spec/fixtures/requests/activitypub-actor-individual.txt @@ -0,0 +1,9 @@ +HTTP/1.1 200 OK +Cache-Control: max-age=0, private, must-revalidate +Content-Type: application/activity+json; charset=utf-8 +Link: <https://ap.example.com/.well-known/webfinger?resource=acct%3Afoo%40ap.example.com>; rel="lrdd"; type="application/xrd+xml", <https://ap.example.com/users/foo.atom>; rel="alternate"; type="application/atom+xml", <https://ap.example.com/users/foo>; rel="alternate"; type="application/activity+json" +Vary: Accept-Encoding +X-Content-Type-Options: nosniff +X-Xss-Protection: 1; mode=block + +{"@context":["https://www.w3.org/ns/activitystreams","https://w3id.org/security/v1",{"vcard": "http://www.w3.org/2006/vcard/ns#"},{"manuallyApprovesFollowers":"as:manuallyApprovesFollowers","sensitive":"as:sensitive","Hashtag":"as:Hashtag","ostatus":"http://ostatus.org#","atomUri":"ostatus:atomUri","inReplyToAtomUri":"ostatus:inReplyToAtomUri","conversation":"ostatus:conversation"}],"id":"https://ap.example.com/users/foo","type":["Person","vcard:individual"],"following":"https://ap.example.com/users/foo/following","followers":"https://ap.example.com/users/foo/followers","inbox":"https://ap.example.com/users/foo/inbox","outbox":"https://ap.example.com/users/foo/outbox","preferredUsername":"foo","vcard:fn":"foo","name":"","summary":"\u003cp\u003etest\u003c/p\u003e","url":"https://ap.example.com/@foo","manuallyApprovesFollowers":false,"publicKey":{"id":"https://ap.example.com/users/foo#main-key","owner":"https://ap.example.com/users/foo","publicKeyPem":"-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAu3L4vnpNLzVH31MeWI39\n4F0wKeJFsLDAsNXGeOu0QF2x+h1zLWZw/agqD2R3JPU9/kaDJGPIV2Sn5zLyUA9S\n6swCCMOtn7BBR9g9sucgXJmUFB0tACH2QSgHywMAybGfmSb3LsEMNKsGJ9VsvYoh\n8lDET6X4Pyw+ZJU0/OLo/41q9w+OrGtlsTm/PuPIeXnxa6BLqnDaxC+4IcjG/FiP\nahNCTINl/1F/TgSSDZ4Taf4U9XFEIFw8wmgploELozzIzKq+t8nhQYkgAkt64euW\npva3qL5KD1mTIZQEP+LZvh3s2WHrLi3fhbdRuwQ2c0KkJA2oSTFPDpqqbPGZ3Qvu\nHQIDAQAB\n-----END PUBLIC KEY-----\n"},"endpoints":{"sharedInbox":"https://ap.example.com/inbox"},"icon":{"type":"Image","url":"https://quitter.no/avatar/7477-300-20160211190340.png"}} \ No newline at end of file diff --git a/spec/fixtures/requests/json-ld.activitystreams.txt b/spec/fixtures/requests/json-ld.activitystreams.txt new file mode 100644 index 000000000..395797b27 --- /dev/null +++ b/spec/fixtures/requests/json-ld.activitystreams.txt @@ -0,0 +1,391 @@ +HTTP/1.1 200 OK +Date: Tue, 01 May 2018 23:25:57 GMT +Content-Location: activitystreams.jsonld +Vary: negotiate,accept +TCN: choice +Last-Modified: Mon, 16 Apr 2018 00:28:23 GMT +ETag: "1eb0-569ec4caa97c0;d3-540ee27e0eec0" +Accept-Ranges: bytes +Content-Length: 7856 +Cache-Control: max-age=21600 +Expires: Wed, 02 May 2018 05:25:57 GMT +P3P: policyref="http://www.w3.org/2014/08/p3p.xml" +Access-Control-Allow-Origin: * +Content-Type: application/ld+json +Strict-Transport-Security: max-age=15552000; includeSubdomains; preload +Content-Security-Policy: upgrade-insecure-requests + +{ + "@context": { + "@vocab": "_:", + "xsd": "http://www.w3.org/2001/XMLSchema#", + "as": "https://www.w3.org/ns/activitystreams#", + "ldp": "http://www.w3.org/ns/ldp#", + "id": "@id", + "type": "@type", + "Accept": "as:Accept", + "Activity": "as:Activity", + "IntransitiveActivity": "as:IntransitiveActivity", + "Add": "as:Add", + "Announce": "as:Announce", + "Application": "as:Application", + "Arrive": "as:Arrive", + "Article": "as:Article", + "Audio": "as:Audio", + "Block": "as:Block", + "Collection": "as:Collection", + "CollectionPage": "as:CollectionPage", + "Relationship": "as:Relationship", + "Create": "as:Create", + "Delete": "as:Delete", + "Dislike": "as:Dislike", + "Document": "as:Document", + "Event": "as:Event", + "Follow": "as:Follow", + "Flag": "as:Flag", + "Group": "as:Group", + "Ignore": "as:Ignore", + "Image": "as:Image", + "Invite": "as:Invite", + "Join": "as:Join", + "Leave": "as:Leave", + "Like": "as:Like", + "Link": "as:Link", + "Mention": "as:Mention", + "Note": "as:Note", + "Object": "as:Object", + "Offer": "as:Offer", + "OrderedCollection": "as:OrderedCollection", + "OrderedCollectionPage": "as:OrderedCollectionPage", + "Organization": "as:Organization", + "Page": "as:Page", + "Person": "as:Person", + "Place": "as:Place", + "Profile": "as:Profile", + "Question": "as:Question", + "Reject": "as:Reject", + "Remove": "as:Remove", + "Service": "as:Service", + "TentativeAccept": "as:TentativeAccept", + "TentativeReject": "as:TentativeReject", + "Tombstone": "as:Tombstone", + "Undo": "as:Undo", + "Update": "as:Update", + "Video": "as:Video", + "View": "as:View", + "Listen": "as:Listen", + "Read": "as:Read", + "Move": "as:Move", + "Travel": "as:Travel", + "IsFollowing": "as:IsFollowing", + "IsFollowedBy": "as:IsFollowedBy", + "IsContact": "as:IsContact", + "IsMember": "as:IsMember", + "subject": { + "@id": "as:subject", + "@type": "@id" + }, + "relationship": { + "@id": "as:relationship", + "@type": "@id" + }, + "actor": { + "@id": "as:actor", + "@type": "@id" + }, + "attributedTo": { + "@id": "as:attributedTo", + "@type": "@id" + }, + "attachment": { + "@id": "as:attachment", + "@type": "@id" + }, + "bcc": { + "@id": "as:bcc", + "@type": "@id" + }, + "bto": { + "@id": "as:bto", + "@type": "@id" + }, + "cc": { + "@id": "as:cc", + "@type": "@id" + }, + "context": { + "@id": "as:context", + "@type": "@id" + }, + "current": { + "@id": "as:current", + "@type": "@id" + }, + "first": { + "@id": "as:first", + "@type": "@id" + }, + "generator": { + "@id": "as:generator", + "@type": "@id" + }, + "icon": { + "@id": "as:icon", + "@type": "@id" + }, + "image": { + "@id": "as:image", + "@type": "@id" + }, + "inReplyTo": { + "@id": "as:inReplyTo", + "@type": "@id" + }, + "items": { + "@id": "as:items", + "@type": "@id" + }, + "instrument": { + "@id": "as:instrument", + "@type": "@id" + }, + "orderedItems": { + "@id": "as:items", + "@type": "@id", + "@container": "@list" + }, + "last": { + "@id": "as:last", + "@type": "@id" + }, + "location": { + "@id": "as:location", + "@type": "@id" + }, + "next": { + "@id": "as:next", + "@type": "@id" + }, + "object": { + "@id": "as:object", + "@type": "@id" + }, + "oneOf": { + "@id": "as:oneOf", + "@type": "@id" + }, + "anyOf": { + "@id": "as:anyOf", + "@type": "@id" + }, + "closed": { + "@id": "as:closed", + "@type": "xsd:dateTime" + }, + "origin": { + "@id": "as:origin", + "@type": "@id" + }, + "accuracy": { + "@id": "as:accuracy", + "@type": "xsd:float" + }, + "prev": { + "@id": "as:prev", + "@type": "@id" + }, + "preview": { + "@id": "as:preview", + "@type": "@id" + }, + "replies": { + "@id": "as:replies", + "@type": "@id" + }, + "result": { + "@id": "as:result", + "@type": "@id" + }, + "audience": { + "@id": "as:audience", + "@type": "@id" + }, + "partOf": { + "@id": "as:partOf", + "@type": "@id" + }, + "tag": { + "@id": "as:tag", + "@type": "@id" + }, + "target": { + "@id": "as:target", + "@type": "@id" + }, + "to": { + "@id": "as:to", + "@type": "@id" + }, + "url": { + "@id": "as:url", + "@type": "@id" + }, + "altitude": { + "@id": "as:altitude", + "@type": "xsd:float" + }, + "content": "as:content", + "contentMap": { + "@id": "as:content", + "@container": "@language" + }, + "name": "as:name", + "nameMap": { + "@id": "as:name", + "@container": "@language" + }, + "duration": { + "@id": "as:duration", + "@type": "xsd:duration" + }, + "endTime": { + "@id": "as:endTime", + "@type": "xsd:dateTime" + }, + "height": { + "@id": "as:height", + "@type": "xsd:nonNegativeInteger" + }, + "href": { + "@id": "as:href", + "@type": "@id" + }, + "hreflang": "as:hreflang", + "latitude": { + "@id": "as:latitude", + "@type": "xsd:float" + }, + "longitude": { + "@id": "as:longitude", + "@type": "xsd:float" + }, + "mediaType": "as:mediaType", + "published": { + "@id": "as:published", + "@type": "xsd:dateTime" + }, + "radius": { + "@id": "as:radius", + "@type": "xsd:float" + }, + "rel": "as:rel", + "startIndex": { + "@id": "as:startIndex", + "@type": "xsd:nonNegativeInteger" + }, + "startTime": { + "@id": "as:startTime", + "@type": "xsd:dateTime" + }, + "summary": "as:summary", + "summaryMap": { + "@id": "as:summary", + "@container": "@language" + }, + "totalItems": { + "@id": "as:totalItems", + "@type": "xsd:nonNegativeInteger" + }, + "units": "as:units", + "updated": { + "@id": "as:updated", + "@type": "xsd:dateTime" + }, + "width": { + "@id": "as:width", + "@type": "xsd:nonNegativeInteger" + }, + "describes": { + "@id": "as:describes", + "@type": "@id" + }, + "formerType": { + "@id": "as:formerType", + "@type": "@id" + }, + "deleted": { + "@id": "as:deleted", + "@type": "xsd:dateTime" + }, + "inbox": { + "@id": "ldp:inbox", + "@type": "@id" + }, + "outbox": { + "@id": "as:outbox", + "@type": "@id" + }, + "following": { + "@id": "as:following", + "@type": "@id" + }, + "followers": { + "@id": "as:followers", + "@type": "@id" + }, + "streams": { + "@id": "as:streams", + "@type": "@id" + }, + "preferredUsername": "as:preferredUsername", + "endpoints": { + "@id": "as:endpoints", + "@type": "@id" + }, + "uploadMedia": { + "@id": "as:uploadMedia", + "@type": "@id" + }, + "proxyUrl": { + "@id": "as:proxyUrl", + "@type": "@id" + }, + "liked": { + "@id": "as:liked", + "@type": "@id" + }, + "oauthAuthorizationEndpoint": { + "@id": "as:oauthAuthorizationEndpoint", + "@type": "@id" + }, + "oauthTokenEndpoint": { + "@id": "as:oauthTokenEndpoint", + "@type": "@id" + }, + "provideClientKey": { + "@id": "as:provideClientKey", + "@type": "@id" + }, + "signClientKey": { + "@id": "as:signClientKey", + "@type": "@id" + }, + "sharedInbox": { + "@id": "as:sharedInbox", + "@type": "@id" + }, + "Public": { + "@id": "as:Public", + "@type": "@id" + }, + "source": "as:source", + "likes": { + "@id": "as:likes", + "@type": "@id" + }, + "shares": { + "@id": "as:shares", + "@type": "@id" + } + } +} diff --git a/spec/fixtures/requests/json-ld.identity.txt b/spec/fixtures/requests/json-ld.identity.txt new file mode 100644 index 000000000..8810526cb --- /dev/null +++ b/spec/fixtures/requests/json-ld.identity.txt @@ -0,0 +1,100 @@ +HTTP/1.1 200 OK +Accept-Ranges: bytes +Access-Control-Allow-Headers: DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Accept-Encoding +Access-Control-Allow-Origin: * +Content-Type: application/ld+json +Date: Tue, 01 May 2018 23:28:21 GMT +Etag: "e26-547a6fc75b04a-gzip" +Last-Modified: Fri, 03 Feb 2017 21:30:09 GMT +Server: Apache/2.4.7 (Ubuntu) +Vary: Accept-Encoding +Transfer-Encoding: chunked + +{ + "@context": { + "id": "@id", + "type": "@type", + + "cred": "https://w3id.org/credentials#", + "dc": "http://purl.org/dc/terms/", + "identity": "https://w3id.org/identity#", + "perm": "https://w3id.org/permissions#", + "ps": "https://w3id.org/payswarm#", + "rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#", + "rdfs": "http://www.w3.org/2000/01/rdf-schema#", + "sec": "https://w3id.org/security#", + "schema": "http://schema.org/", + "xsd": "http://www.w3.org/2001/XMLSchema#", + + "Group": "https://www.w3.org/ns/activitystreams#Group", + + "claim": {"@id": "cred:claim", "@type": "@id"}, + "credential": {"@id": "cred:credential", "@type": "@id"}, + "issued": {"@id": "cred:issued", "@type": "xsd:dateTime"}, + "issuer": {"@id": "cred:issuer", "@type": "@id"}, + "recipient": {"@id": "cred:recipient", "@type": "@id"}, + "Credential": "cred:Credential", + "CryptographicKeyCredential": "cred:CryptographicKeyCredential", + + "about": {"@id": "schema:about", "@type": "@id"}, + "address": {"@id": "schema:address", "@type": "@id"}, + "addressCountry": "schema:addressCountry", + "addressLocality": "schema:addressLocality", + "addressRegion": "schema:addressRegion", + "comment": "rdfs:comment", + "created": {"@id": "dc:created", "@type": "xsd:dateTime"}, + "creator": {"@id": "dc:creator", "@type": "@id"}, + "description": "schema:description", + "email": "schema:email", + "familyName": "schema:familyName", + "givenName": "schema:givenName", + "image": {"@id": "schema:image", "@type": "@id"}, + "label": "rdfs:label", + "name": "schema:name", + "postalCode": "schema:postalCode", + "streetAddress": "schema:streetAddress", + "title": "dc:title", + "url": {"@id": "schema:url", "@type": "@id"}, + "Person": "schema:Person", + "PostalAddress": "schema:PostalAddress", + "Organization": "schema:Organization", + + "identityService": {"@id": "identity:identityService", "@type": "@id"}, + "idp": {"@id": "identity:idp", "@type": "@id"}, + "Identity": "identity:Identity", + + "paymentProcessor": "ps:processor", + "preferences": {"@id": "ps:preferences", "@type": "@vocab"}, + + "cipherAlgorithm": "sec:cipherAlgorithm", + "cipherData": "sec:cipherData", + "cipherKey": "sec:cipherKey", + "digestAlgorithm": "sec:digestAlgorithm", + "digestValue": "sec:digestValue", + "domain": "sec:domain", + "expires": {"@id": "sec:expiration", "@type": "xsd:dateTime"}, + "initializationVector": "sec:initializationVector", + "member": {"@id": "schema:member", "@type": "@id"}, + "memberOf": {"@id": "schema:memberOf", "@type": "@id"}, + "nonce": "sec:nonce", + "normalizationAlgorithm": "sec:normalizationAlgorithm", + "owner": {"@id": "sec:owner", "@type": "@id"}, + "password": "sec:password", + "privateKey": {"@id": "sec:privateKey", "@type": "@id"}, + "privateKeyPem": "sec:privateKeyPem", + "publicKey": {"@id": "sec:publicKey", "@type": "@id"}, + "publicKeyPem": "sec:publicKeyPem", + "publicKeyService": {"@id": "sec:publicKeyService", "@type": "@id"}, + "revoked": {"@id": "sec:revoked", "@type": "xsd:dateTime"}, + "signature": "sec:signature", + "signatureAlgorithm": "sec:signatureAlgorithm", + "signatureValue": "sec:signatureValue", + "CryptographicKey": "sec:Key", + "EncryptedMessage": "sec:EncryptedMessage", + "GraphSignature2012": "sec:GraphSignature2012", + "LinkedDataSignature2015": "sec:LinkedDataSignature2015", + + "accessControl": {"@id": "perm:accessControl", "@type": "@id"}, + "writePermission": {"@id": "perm:writePermission", "@type": "@id"} + } +} diff --git a/spec/fixtures/requests/json-ld.security.txt b/spec/fixtures/requests/json-ld.security.txt new file mode 100644 index 000000000..0d29903e6 --- /dev/null +++ b/spec/fixtures/requests/json-ld.security.txt @@ -0,0 +1,61 @@ +HTTP/1.1 200 OK +Accept-Ranges: bytes +Access-Control-Allow-Headers: DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Accept-Encoding +Access-Control-Allow-Origin: * +Content-Type: application/ld+json +Date: Wed, 02 May 2018 16:25:32 GMT +Etag: "7e3-5651ec0f7c5ed-gzip" +Last-Modified: Tue, 13 Feb 2018 21:34:04 GMT +Server: Apache/2.4.7 (Ubuntu) +Vary: Accept-Encoding +Content-Length: 2019 + +{ + "@context": { + "id": "@id", + "type": "@type", + + "dc": "http://purl.org/dc/terms/", + "sec": "https://w3id.org/security#", + "xsd": "http://www.w3.org/2001/XMLSchema#", + + "EcdsaKoblitzSignature2016": "sec:EcdsaKoblitzSignature2016", + "Ed25519Signature2018": "sec:Ed25519Signature2018", + "EncryptedMessage": "sec:EncryptedMessage", + "GraphSignature2012": "sec:GraphSignature2012", + "LinkedDataSignature2015": "sec:LinkedDataSignature2015", + "LinkedDataSignature2016": "sec:LinkedDataSignature2016", + "CryptographicKey": "sec:Key", + + "authenticationTag": "sec:authenticationTag", + "canonicalizationAlgorithm": "sec:canonicalizationAlgorithm", + "cipherAlgorithm": "sec:cipherAlgorithm", + "cipherData": "sec:cipherData", + "cipherKey": "sec:cipherKey", + "created": {"@id": "dc:created", "@type": "xsd:dateTime"}, + "creator": {"@id": "dc:creator", "@type": "@id"}, + "digestAlgorithm": "sec:digestAlgorithm", + "digestValue": "sec:digestValue", + "domain": "sec:domain", + "encryptionKey": "sec:encryptionKey", + "expiration": {"@id": "sec:expiration", "@type": "xsd:dateTime"}, + "expires": {"@id": "sec:expiration", "@type": "xsd:dateTime"}, + "initializationVector": "sec:initializationVector", + "iterationCount": "sec:iterationCount", + "nonce": "sec:nonce", + "normalizationAlgorithm": "sec:normalizationAlgorithm", + "owner": {"@id": "sec:owner", "@type": "@id"}, + "password": "sec:password", + "privateKey": {"@id": "sec:privateKey", "@type": "@id"}, + "privateKeyPem": "sec:privateKeyPem", + "publicKey": {"@id": "sec:publicKey", "@type": "@id"}, + "publicKeyBase58": "sec:publicKeyBase58", + "publicKeyPem": "sec:publicKeyPem", + "publicKeyService": {"@id": "sec:publicKeyService", "@type": "@id"}, + "revoked": {"@id": "sec:revoked", "@type": "xsd:dateTime"}, + "salt": "sec:salt", + "signature": "sec:signature", + "signatureAlgorithm": "sec:signingAlgorithm", + "signatureValue": "sec:signatureValue" + } +} diff --git a/spec/fixtures/requests/oembed_json.html b/spec/fixtures/requests/oembed_json.html index 773a4f92a..167085871 100644 --- a/spec/fixtures/requests/oembed_json.html +++ b/spec/fixtures/requests/oembed_json.html @@ -1,7 +1,7 @@ <!DOCTYPE html> <html> <head> - <link href='https://host/provider.json' rel='alternate' type='application/json+oembed'> + <link href='https://host.test/provider.json' rel='alternate' type='application/json+oembed'> </head> <body></body> </html> diff --git a/spec/fixtures/requests/oembed_json_xml.html b/spec/fixtures/requests/oembed_json_xml.html index 8afd8e997..9f5b9e8be 100644 --- a/spec/fixtures/requests/oembed_json_xml.html +++ b/spec/fixtures/requests/oembed_json_xml.html @@ -7,8 +7,8 @@ > The type attribute must contain either application/json+oembed for JSON > responses, or text/xml+oembed for XML. --> - <link href='https://host/provider.json' rel='alternate' type='application/json+oembed'> - <link href='https://host/provider.xml' rel='alternate' type='text/xml+oembed'> + <link href='https://host.test/provider.json' rel='alternate' type='application/json+oembed'> + <link href='https://host.test/provider.xml' rel='alternate' type='text/xml+oembed'> </head> <body></body> </html> diff --git a/spec/fixtures/requests/oembed_xml.html b/spec/fixtures/requests/oembed_xml.html index bdfcca170..788dfaabd 100644 --- a/spec/fixtures/requests/oembed_xml.html +++ b/spec/fixtures/requests/oembed_xml.html @@ -7,7 +7,7 @@ > The type attribute must contain either application/json+oembed for JSON > responses, or text/xml+oembed for XML. --> - <link href='https://host/provider.xml' rel='alternate' type='text/xml+oembed'> + <link href='https://host.test/provider.xml' rel='alternate' type='text/xml+oembed'> </head> <body></body> </html> diff --git a/spec/helpers/jsonld_helper_spec.rb b/spec/helpers/jsonld_helper_spec.rb index 48bfdc306..a5ab249c2 100644 --- a/spec/helpers/jsonld_helper_spec.rb +++ b/spec/helpers/jsonld_helper_spec.rb @@ -32,37 +32,37 @@ describe JsonLdHelper do describe '#fetch_resource' do context 'when the second argument is false' do it 'returns resource even if the retrieved ID and the given URI does not match' do - stub_request(:get, 'https://bob/').to_return body: '{"id": "https://alice/"}' - stub_request(:get, 'https://alice/').to_return body: '{"id": "https://alice/"}' + stub_request(:get, 'https://bob.test/').to_return body: '{"id": "https://alice.test/"}' + stub_request(:get, 'https://alice.test/').to_return body: '{"id": "https://alice.test/"}' - expect(fetch_resource('https://bob/', false)).to eq({ 'id' => 'https://alice/' }) + expect(fetch_resource('https://bob.test/', false)).to eq({ 'id' => 'https://alice.test/' }) end it 'returns nil if the object identified by the given URI and the object identified by the retrieved ID does not match' do - stub_request(:get, 'https://mallory/').to_return body: '{"id": "https://marvin/"}' - stub_request(:get, 'https://marvin/').to_return body: '{"id": "https://alice/"}' + 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/"}' - expect(fetch_resource('https://mallory/', false)).to eq nil + expect(fetch_resource('https://mallory.test/', false)).to eq nil end end context 'when the second argument is true' do it 'returns nil if the retrieved ID and the given URI does not match' do - stub_request(:get, 'https://mallory/').to_return body: '{"id": "https://alice/"}' - expect(fetch_resource('https://mallory/', true)).to eq nil + stub_request(:get, 'https://mallory.test/').to_return body: '{"id": "https://alice.test/"}' + expect(fetch_resource('https://mallory.test/', true)).to eq nil end end end describe '#fetch_resource_without_id_validation' do it 'returns nil if the status code is not 200' do - stub_request(:get, 'https://host/').to_return status: 400, body: '{}' - expect(fetch_resource_without_id_validation('https://host/')).to eq nil + stub_request(:get, 'https://host.test/').to_return status: 400, body: '{}' + expect(fetch_resource_without_id_validation('https://host.test/')).to eq nil end it 'returns hash' do - stub_request(:get, 'https://host/').to_return status: 200, body: '{}' - expect(fetch_resource_without_id_validation('https://host/')).to eq({}) + stub_request(:get, 'https://host.test/').to_return status: 200, body: '{}' + expect(fetch_resource_without_id_validation('https://host.test/')).to eq({}) end end end diff --git a/spec/lib/activitypub/linked_data_signature_spec.rb b/spec/lib/activitypub/linked_data_signature_spec.rb index a4d6fe8c3..1f413eec9 100644 --- a/spec/lib/activitypub/linked_data_signature_spec.rb +++ b/spec/lib/activitypub/linked_data_signature_spec.rb @@ -16,6 +16,10 @@ RSpec.describe ActivityPub::LinkedDataSignature do subject { described_class.new(json) } + before do + stub_jsonld_contexts! + end + describe '#verify_account!' do context 'when signature matches' do let(:raw_signature) do diff --git a/spec/lib/formatter_spec.rb b/spec/lib/formatter_spec.rb index 6e849f379..b8683e720 100644 --- a/spec/lib/formatter_spec.rb +++ b/spec/lib/formatter_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' RSpec.describe Formatter do let(:local_account) { Fabricate(:account, domain: nil, username: 'alice') } - let(:remote_account) { Fabricate(:account, domain: 'remote', username: 'bob', url: 'https://remote/') } + let(:remote_account) { Fabricate(:account, domain: 'remote.test', username: 'bob', url: 'https://remote.test/') } shared_examples 'encode and link URLs' do context 'matches a stand-alone medium URL' do @@ -377,12 +377,12 @@ RSpec.describe Formatter do end context 'contains linkable mentions for remote accounts' do - let(:text) { '@bob@remote' } + let(:text) { '@bob@remote.test' } before { remote_account } it 'links' do - is_expected.to eq '<p><span class="h-card"><a href="https://remote/" class="u-url mention">@<span>bob</span></a></span></p>' + is_expected.to eq '<p><span class="h-card"><a href="https://remote.test/" class="u-url mention">@<span>bob</span></a></span></p>' end end diff --git a/spec/lib/ostatus/atom_serializer_spec.rb b/spec/lib/ostatus/atom_serializer_spec.rb index 00e6f09dc..0bd22880e 100644 --- a/spec/lib/ostatus/atom_serializer_spec.rb +++ b/spec/lib/ostatus/atom_serializer_spec.rb @@ -30,13 +30,13 @@ RSpec.describe OStatus::AtomSerializer do end it 'appends activity:object with target account' do - target_account = Fabricate(:account, domain: 'domain', uri: 'https://domain/id') + target_account = Fabricate(:account, domain: 'domain.test', uri: 'https://domain.test/id') follow_request = Fabricate(:follow_request, target_account: target_account) follow_request_salmon = serialize(follow_request) object = follow_request_salmon.nodes.find { |node| node.name == 'activity:object' } - expect(object.id.text).to eq 'https://domain/id' + expect(object.id.text).to eq 'https://domain.test/id' end end @@ -386,12 +386,6 @@ RSpec.describe OStatus::AtomSerializer do expect(entry.category[:term]).to eq 'tag' end - it 'appends category element for NSFW if status is sensitive' do - status = Fabricate(:status, sensitive: true) - entry = OStatus::AtomSerializer.new.entry(status.stream_entry) - expect(entry.category[:term]).to eq 'nsfw' - end - it 'appends link elements for media attachments' do file = attachment_fixture('attachment.jpg') media_attachment = Fabricate(:media_attachment, file: file) @@ -419,20 +413,20 @@ RSpec.describe OStatus::AtomSerializer do entry = OStatus::AtomSerializer.new.entry(remote_status.stream_entry, true) entry.nodes.delete_if { |node| node[:type] == 'application/activity+json' } # Remove ActivityPub link to simplify test - xml = OStatus::AtomSerializer.render(entry).gsub('cb6e6126.ngrok.io', 'remote') + xml = OStatus::AtomSerializer.render(entry).gsub('cb6e6126.ngrok.io', 'remote.test') remote_status.destroy! remote_account.destroy! account = Account.create!( - domain: 'remote', + domain: 'remote.test', username: 'username', last_webfingered_at: Time.now.utc ) ProcessFeedService.new.call(xml, account) - expect(Status.find_by(uri: "https://remote/users/#{remote_status.account.to_param}/statuses/#{remote_status.id}")).to be_instance_of Status + expect(Status.find_by(uri: "https://remote.test/users/#{remote_status.account.to_param}/statuses/#{remote_status.id}")).to be_instance_of Status end end @@ -782,13 +776,13 @@ RSpec.describe OStatus::AtomSerializer do end it 'appends activity:object element with target account' do - target_account = Fabricate(:account, domain: 'domain', uri: 'https://domain/id') + target_account = Fabricate(:account, domain: 'domain.test', uri: 'https://domain.test/id') block = Fabricate(:block, target_account: target_account) block_salmon = OStatus::AtomSerializer.new.block_salmon(block) object = block_salmon.nodes.find { |node| node.name == 'activity:object' } - expect(object.id.text).to eq 'https://domain/id' + expect(object.id.text).to eq 'https://domain.test/id' end it 'returns element whose rendered view triggers block when processed' do @@ -869,13 +863,13 @@ RSpec.describe OStatus::AtomSerializer do end it 'appends activity:object element with target account' do - target_account = Fabricate(:account, domain: 'domain', uri: 'https://domain/id') + target_account = Fabricate(:account, domain: 'domain.test', uri: 'https://domain.test/id') block = Fabricate(:block, target_account: target_account) unblock_salmon = OStatus::AtomSerializer.new.unblock_salmon(block) object = unblock_salmon.nodes.find { |node| node.name == 'activity:object' } - expect(object.id.text).to eq 'https://domain/id' + expect(object.id.text).to eq 'https://domain.test/id' end it 'returns element whose rendered view triggers block when processed' do @@ -1130,13 +1124,13 @@ RSpec.describe OStatus::AtomSerializer do end it 'appends activity:object element with target account' do - target_account = Fabricate(:account, domain: 'domain', uri: 'https://domain/id') + target_account = Fabricate(:account, domain: 'domain.test', uri: 'https://domain.test/id') follow = Fabricate(:follow, target_account: target_account) follow_salmon = OStatus::AtomSerializer.new.follow_salmon(follow) object = follow_salmon.nodes.find { |node| node.name == 'activity:object' } - expect(object.id.text).to eq 'https://domain/id' + expect(object.id.text).to eq 'https://domain.test/id' end it 'includes description' do @@ -1248,14 +1242,14 @@ RSpec.describe OStatus::AtomSerializer do end it 'appends activity:object element with target account' do - target_account = Fabricate(:account, domain: 'domain', uri: 'https://domain/id') + target_account = Fabricate(:account, domain: 'domain.test', uri: 'https://domain.test/id') follow = Fabricate(:follow, target_account: target_account) follow.destroy! unfollow_salmon = OStatus::AtomSerializer.new.unfollow_salmon(follow) object = unfollow_salmon.nodes.find { |node| node.name == 'activity:object' } - expect(object.id.text).to eq 'https://domain/id' + expect(object.id.text).to eq 'https://domain.test/id' end it 'returns element whose rendered view triggers unfollow when processed' do diff --git a/spec/lib/tag_manager_spec.rb b/spec/lib/tag_manager_spec.rb index 5427a2929..3a804ac0f 100644 --- a/spec/lib/tag_manager_spec.rb +++ b/spec/lib/tag_manager_spec.rb @@ -6,7 +6,7 @@ RSpec.describe TagManager do around do |example| original_local_domain = Rails.configuration.x.local_domain - Rails.configuration.x.local_domain = 'domain' + Rails.configuration.x.local_domain = 'domain.test' example.run @@ -18,11 +18,11 @@ RSpec.describe TagManager do end it 'returns true if the slash-stripped string equals to local domain' do - expect(TagManager.instance.local_domain?('DoMaIn/')).to eq true + expect(TagManager.instance.local_domain?('DoMaIn.Test/')).to eq true end it 'returns false for irrelevant string' do - expect(TagManager.instance.local_domain?('DoMaIn!')).to eq false + expect(TagManager.instance.local_domain?('DoMaIn.Test!')).to eq false end end @@ -31,7 +31,7 @@ RSpec.describe TagManager do around do |example| original_web_domain = Rails.configuration.x.web_domain - Rails.configuration.x.web_domain = 'domain' + Rails.configuration.x.web_domain = 'domain.test' example.run @@ -43,11 +43,11 @@ RSpec.describe TagManager do end it 'returns true if the slash-stripped string equals to web domain' do - expect(TagManager.instance.web_domain?('DoMaIn/')).to eq true + expect(TagManager.instance.web_domain?('DoMaIn.Test/')).to eq true end it 'returns false for string with irrelevant characters' do - expect(TagManager.instance.web_domain?('DoMaIn!')).to eq false + expect(TagManager.instance.web_domain?('DoMaIn.Test!')).to eq false end end @@ -57,7 +57,7 @@ RSpec.describe TagManager do end it 'returns normalized domain' do - expect(TagManager.instance.normalize_domain('DoMaIn/')).to eq 'domain' + expect(TagManager.instance.normalize_domain('DoMaIn.Test/')).to eq 'domain.test' end end @@ -69,18 +69,18 @@ RSpec.describe TagManager do end it 'returns true if the normalized string with port is local URL' do - Rails.configuration.x.web_domain = 'domain:42' - expect(TagManager.instance.local_url?('https://DoMaIn:42/')).to eq true + Rails.configuration.x.web_domain = 'domain.test:42' + expect(TagManager.instance.local_url?('https://DoMaIn.Test:42/')).to eq true end it 'returns true if the normalized string without port is local URL' do - Rails.configuration.x.web_domain = 'domain' - expect(TagManager.instance.local_url?('https://DoMaIn/')).to eq true + Rails.configuration.x.web_domain = 'domain.test' + expect(TagManager.instance.local_url?('https://DoMaIn.Test/')).to eq true end it 'returns false for string with irrelevant characters' do - Rails.configuration.x.web_domain = 'domain' - expect(TagManager.instance.local_url?('https://domainn/')).to eq false + Rails.configuration.x.web_domain = 'domain.test' + expect(TagManager.instance.local_url?('https://domainn.test/')).to eq false end end @@ -88,19 +88,19 @@ RSpec.describe TagManager do # The following comparisons MUST be case-insensitive. it 'returns true if the needle has a correct username and domain for remote user' do - expect(TagManager.instance.same_acct?('username@domain', 'UsErNaMe@DoMaIn')).to eq true + expect(TagManager.instance.same_acct?('username@domain.test', 'UsErNaMe@DoMaIn.Test')).to eq true end it 'returns false if the needle is missing a domain for remote user' do - expect(TagManager.instance.same_acct?('username@domain', 'UsErNaMe')).to eq false + expect(TagManager.instance.same_acct?('username@domain.test', 'UsErNaMe')).to eq false end it 'returns false if the needle has an incorrect domain for remote user' do - expect(TagManager.instance.same_acct?('username@domain', 'UsErNaMe@incorrect')).to eq false + expect(TagManager.instance.same_acct?('username@domain.test', 'UsErNaMe@incorrect.test')).to eq false end it 'returns false if the needle has an incorrect username for remote user' do - expect(TagManager.instance.same_acct?('username@domain', 'incorrect@DoMaIn')).to eq false + expect(TagManager.instance.same_acct?('username@domain.test', 'incorrect@DoMaIn.test')).to eq false end it 'returns true if the needle has a correct username and domain for local user' do diff --git a/spec/models/account_spec.rb b/spec/models/account_spec.rb index 3ac7208ed..a88b11482 100644 --- a/spec/models/account_spec.rb +++ b/spec/models/account_spec.rb @@ -94,14 +94,14 @@ RSpec.describe Account, type: :model do describe '#save_with_optional_media!' do before do - stub_request(:get, 'https://remote/valid_avatar').to_return(request_fixture('avatar.txt')) - stub_request(:get, 'https://remote/invalid_avatar').to_return(request_fixture('feed.txt')) + stub_request(:get, 'https://remote.test/valid_avatar').to_return(request_fixture('avatar.txt')) + stub_request(:get, 'https://remote.test/invalid_avatar').to_return(request_fixture('feed.txt')) end let(:account) do Fabricate(:account, - avatar_remote_url: 'https://remote/valid_avatar', - header_remote_url: 'https://remote/valid_avatar') + avatar_remote_url: 'https://remote.test/valid_avatar', + header_remote_url: 'https://remote.test/valid_avatar') end let!(:expectation) { account.dup } @@ -121,7 +121,7 @@ RSpec.describe Account, type: :model do context 'with invalid properties' do before do - account.avatar_remote_url = 'https://remote/invalid_avatar' + account.avatar_remote_url = 'https://remote.test/invalid_avatar' account.save_with_optional_media! end @@ -815,7 +815,8 @@ RSpec.describe Account, type: :model do end context 'when is local' do - it 'generates keys' do + # Test disabled because test environment omits autogenerating keys for performance + xit 'generates keys' do account = Account.create!(domain: nil, username: Faker::Internet.user_name(nil, ['_'])) expect(account.keypair.private?).to eq true end diff --git a/spec/models/concerns/account_interactions_spec.rb b/spec/models/concerns/account_interactions_spec.rb index 95bf9561d..9c9b87daf 100644 --- a/spec/models/concerns/account_interactions_spec.rb +++ b/spec/models/concerns/account_interactions_spec.rb @@ -115,13 +115,15 @@ describe AccountInteractions do end describe '#mute!' do + subject { account.mute!(target_account, notifications: arg_notifications) } + context 'Mute does not exist yet' do context 'arg :notifications is nil' do let(:arg_notifications) { nil } - it 'creates Mute, and returns nil' do + it 'creates Mute, and returns Mute' do expect do - expect(account.mute!(target_account, notifications: arg_notifications)).to be nil + expect(subject).to be_kind_of Mute end.to change { account.mute_relationships.count }.by 1 end end @@ -129,9 +131,9 @@ describe AccountInteractions do context 'arg :notifications is false' do let(:arg_notifications) { false } - it 'creates Mute, and returns nil' do + it 'creates Mute, and returns Mute' do expect do - expect(account.mute!(target_account, notifications: arg_notifications)).to be nil + expect(subject).to be_kind_of Mute end.to change { account.mute_relationships.count }.by 1 end end @@ -139,9 +141,9 @@ describe AccountInteractions do context 'arg :notifications is true' do let(:arg_notifications) { true } - it 'creates Mute, and returns nil' do + it 'creates Mute, and returns Mute' do expect do - expect(account.mute!(target_account, notifications: arg_notifications)).to be nil + expect(subject).to be_kind_of Mute end.to change { account.mute_relationships.count }.by 1 end end @@ -165,36 +167,30 @@ describe AccountInteractions do context 'arg :notifications is nil' do let(:arg_notifications) { nil } - it 'returns nil without updating mute.hide_notifications' do + it 'returns Mute without updating mute.hide_notifications' do expect do - expect(account.mute!(target_account, notifications: arg_notifications)).to be nil - mute = account.mute_relationships.find_by(target_account: target_account) - expect(mute.hide_notifications?).to be true - end + expect(subject).to be_kind_of Mute + end.not_to change { mute.reload.hide_notifications? }.from(true) end end context 'arg :notifications is false' do let(:arg_notifications) { false } - it 'returns true, and updates mute.hide_notifications false' do + it 'returns Mute, and updates mute.hide_notifications false' do expect do - expect(account.mute!(target_account, notifications: arg_notifications)).to be true - mute = account.mute_relationships.find_by(target_account: target_account) - expect(mute.hide_notifications?).to be false - end + expect(subject).to be_kind_of Mute + end.to change { mute.reload.hide_notifications? }.from(true).to(false) end end context 'arg :notifications is true' do let(:arg_notifications) { true } - it 'returns nil without updating mute.hide_notifications' do + it 'returns Mute without updating mute.hide_notifications' do expect do - expect(account.mute!(target_account, notifications: arg_notifications)).to be nil - mute = account.mute_relationships.find_by(target_account: target_account) - expect(mute.hide_notifications?).to be true - end + expect(subject).to be_kind_of Mute + end.not_to change { mute.reload.hide_notifications? }.from(true) end end end @@ -205,36 +201,30 @@ describe AccountInteractions do context 'arg :notifications is nil' do let(:arg_notifications) { nil } - it 'returns true, and updates mute.hide_notifications true' do + it 'returns Mute, and updates mute.hide_notifications true' do expect do - expect(account.mute!(target_account, notifications: arg_notifications)).to be true - mute = account.mute_relationships.find_by(target_account: target_account) - expect(mute.hide_notifications?).to be true - end + expect(subject).to be_kind_of Mute + end.to change { mute.reload.hide_notifications? }.from(false).to(true) end end context 'arg :notifications is false' do let(:arg_notifications) { false } - it 'returns nil without updating mute.hide_notifications' do + it 'returns Mute without updating mute.hide_notifications' do expect do - expect(account.mute!(target_account, notifications: arg_notifications)).to be nil - mute = account.mute_relationships.find_by(target_account: target_account) - expect(mute.hide_notifications?).to be false - end + expect(subject).to be_kind_of Mute + end.not_to change { mute.reload.hide_notifications? }.from(false) end end context 'arg :notifications is true' do let(:arg_notifications) { true } - it 'returns true, and updates mute.hide_notifications true' do + it 'returns Mute, and updates mute.hide_notifications true' do expect do - expect(account.mute!(target_account, notifications: arg_notifications)).to be true - mute = account.mute_relationships.find_by(target_account: target_account) - expect(mute.hide_notifications?).to be true - end + expect(subject).to be_kind_of Mute + end.to change { mute.reload.hide_notifications? }.from(false).to(true) end end end diff --git a/spec/models/concerns/status_threading_concern_spec.rb b/spec/models/concerns/status_threading_concern_spec.rb index b8ebdd58c..e5736a307 100644 --- a/spec/models/concerns/status_threading_concern_spec.rb +++ b/spec/models/concerns/status_threading_concern_spec.rb @@ -89,34 +89,34 @@ describe StatusThreadingConcern do let!(:viewer) { Fabricate(:account, username: 'viewer') } it 'returns replies' do - expect(status.descendants).to include(reply1, reply2, reply3) + expect(status.descendants(4)).to include(reply1, reply2, reply3) end it 'does not return replies user is not allowed to see' do reply1.update(visibility: :private) reply3.update(visibility: :direct) - expect(status.descendants(viewer)).to_not include(reply1, reply3) + expect(status.descendants(4, viewer)).to_not include(reply1, reply3) end it 'does not return replies from blocked users' do viewer.block!(jeff) - expect(status.descendants(viewer)).to_not include(reply3) + expect(status.descendants(4, viewer)).to_not include(reply3) end it 'does not return replies from muted users' do viewer.mute!(jeff) - expect(status.descendants(viewer)).to_not include(reply3) + expect(status.descendants(4, viewer)).to_not include(reply3) end it 'does not return replies from silenced and not followed users' do jeff.update(silenced: true) - expect(status.descendants(viewer)).to_not include(reply3) + expect(status.descendants(4, viewer)).to_not include(reply3) end it 'does not return replies from blocked domains' do viewer.block_domain!('example.com') - expect(status.descendants(viewer)).to_not include(reply2) + expect(status.descendants(4, viewer)).to_not include(reply2) end end end diff --git a/spec/models/report_spec.rb b/spec/models/report_spec.rb index d40ebf6dc..a0cd0800d 100644 --- a/spec/models/report_spec.rb +++ b/spec/models/report_spec.rb @@ -22,6 +22,101 @@ describe Report do end end + describe 'assign_to_self!' do + subject { report.assigned_account_id } + + let(:report) { Fabricate(:report, assigned_account_id: original_account) } + let(:original_account) { Fabricate(:account) } + let(:current_account) { Fabricate(:account) } + + before do + report.assign_to_self!(current_account) + end + + it 'assigns to a given account' do + is_expected.to eq current_account.id + end + end + + describe 'unassign!' do + subject { report.assigned_account_id } + + let(:report) { Fabricate(:report, assigned_account_id: account.id) } + let(:account) { Fabricate(:account) } + + before do + report.unassign! + end + + it 'unassigns' do + is_expected.to be_nil + end + end + + describe 'resolve!' do + subject(:report) { Fabricate(:report, action_taken: false, action_taken_by_account_id: nil) } + + let(:acting_account) { Fabricate(:account) } + + before do + report.resolve!(acting_account) + end + + it 'records action taken' do + expect(report).to have_attributes(action_taken: true, action_taken_by_account_id: acting_account.id) + end + end + + describe 'unresolve!' do + subject(:report) { Fabricate(:report, action_taken: true, action_taken_by_account_id: acting_account.id) } + + let(:acting_account) { Fabricate(:account) } + + before do + report.unresolve! + end + + it 'unresolves' do + expect(report).to have_attributes(action_taken: false, action_taken_by_account_id: nil) + end + end + + describe 'unresolved?' do + subject { report.unresolved? } + + let(:report) { Fabricate(:report, action_taken: action_taken) } + + context 'if action is taken' do + let(:action_taken) { true } + + it { is_expected.to be false } + end + + context 'if action not is taken' do + let(:action_taken) { false } + + it { is_expected.to be true } + end + end + + describe 'history' do + subject(:action_logs) { report.history } + + let(:report) { Fabricate(:report, target_account_id: target_account.id, status_ids: [status.id], created_at: 3.days.ago, updated_at: 1.day.ago) } + let(:target_account) { Fabricate(:account) } + let(:status) { Fabricate(:status) } + + before do + Fabricate('Admin::ActionLog', target_type: 'Report', account_id: target_account.id, target_id: report.id, created_at: 2.days.ago) + Fabricate('Admin::ActionLog', target_type: 'Account', account_id: target_account.id, target_id: report.target_account_id, created_at: 2.days.ago) + Fabricate('Admin::ActionLog', target_type: 'Status', account_id: target_account.id, target_id: status.id, created_at: 2.days.ago) + end + + it 'returns right logs' do + expect(action_logs.count).to eq 3 + end + end + describe 'validatiions' do it 'has a valid fabricator' do report = Fabricate(:report) diff --git a/spec/models/status_pin_spec.rb b/spec/models/status_pin_spec.rb index 944baf639..6f0b2feb8 100644 --- a/spec/models/status_pin_spec.rb +++ b/spec/models/status_pin_spec.rb @@ -55,7 +55,7 @@ RSpec.describe StatusPin, type: :model do end it 'allows pins above the max for remote accounts' do - account = Fabricate(:account, domain: 'remote', username: 'bob', url: 'https://remote/') + account = Fabricate(:account, domain: 'remote.test', username: 'bob', url: 'https://remote.test/') status = [] (max_pins + 1).times do |i| diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 8171c939a..760214ded 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -324,4 +324,218 @@ RSpec.describe User, type: :model do expect(admin.role?('moderator')).to be true end end + + describe '#disable!' do + subject(:user) { Fabricate(:user, disabled: false, current_sign_in_at: current_sign_in_at, last_sign_in_at: nil) } + let(:current_sign_in_at) { Time.zone.now } + + before do + user.disable! + end + + it 'disables user' do + expect(user).to have_attributes(disabled: true, current_sign_in_at: nil, last_sign_in_at: current_sign_in_at) + end + end + + describe '#disable!' do + subject(:user) { Fabricate(:user, disabled: false, current_sign_in_at: current_sign_in_at, last_sign_in_at: nil) } + let(:current_sign_in_at) { Time.zone.now } + + before do + user.disable! + end + + it 'disables user' do + expect(user).to have_attributes(disabled: true, current_sign_in_at: nil, last_sign_in_at: current_sign_in_at) + end + end + + describe '#enable!' do + subject(:user) { Fabricate(:user, disabled: true) } + + before do + user.enable! + end + + it 'enables user' do + expect(user).to have_attributes(disabled: false) + end + end + + describe '#confirm!' do + subject(:user) { Fabricate(:user, confirmed_at: confirmed_at) } + + before do + ActionMailer::Base.deliveries.clear + user.confirm! + end + + after { ActionMailer::Base.deliveries.clear } + + context 'when user is new' do + let(:confirmed_at) { nil } + + it 'confirms user' do + expect(user.confirmed_at).to be_present + end + + it 'delivers mails' do + expect(ActionMailer::Base.deliveries.count).to eq 2 + end + end + + context 'when user is not new' do + let(:confirmed_at) { Time.zone.now } + + it 'confirms user' do + expect(user.confirmed_at).to be_present + end + + it 'does not deliver mail' do + expect(ActionMailer::Base.deliveries.count).to eq 0 + end + end + end + + describe '#promote!' do + subject(:user) { Fabricate(:user, admin: is_admin, moderator: is_moderator) } + + before do + user.promote! + end + + context 'when user is an admin' do + let(:is_admin) { true } + + context 'when user is a moderator' do + let(:is_moderator) { true } + + it 'changes moderator filed false' do + expect(user).to be_admin + expect(user).not_to be_moderator + end + end + + context 'when user is not a moderator' do + let(:is_moderator) { false } + + it 'does not change status' do + expect(user).to be_admin + expect(user).not_to be_moderator + end + end + end + + context 'when user is not admin' do + let(:is_admin) { false } + + context 'when user is a moderator' do + let(:is_moderator) { true } + + it 'changes user into an admin' do + expect(user).to be_admin + expect(user).not_to be_moderator + end + end + + context 'when user is not a moderator' do + let(:is_moderator) { false } + + it 'changes user into a moderator' do + expect(user).not_to be_admin + expect(user).to be_moderator + end + end + end + end + + describe '#demote!' do + subject(:user) { Fabricate(:user, admin: admin, moderator: moderator) } + + before do + user.demote! + end + + context 'when user is an admin' do + let(:admin) { true } + + context 'when user is a moderator' do + let(:moderator) { true } + + it 'changes user into a moderator' do + expect(user).not_to be_admin + expect(user).to be_moderator + end + end + + context 'when user is not a moderator' do + let(:moderator) { false } + + it 'changes user into a moderator' do + expect(user).not_to be_admin + expect(user).to be_moderator + end + end + end + + context 'when user is not an admin' do + let(:admin) { false } + + context 'when user is a moderator' do + let(:moderator) { true } + + it 'changes user into a plain user' do + expect(user).not_to be_admin + expect(user).not_to be_moderator + end + end + + context 'when user is not a moderator' do + let(:moderator) { false } + + it 'does not change any fields' do + expect(user).not_to be_admin + expect(user).not_to be_moderator + end + end + end + end + + describe '#active_for_authentication?' do + subject { user.active_for_authentication? } + let(:user) { Fabricate(:user, disabled: disabled, confirmed_at: confirmed_at) } + + context 'when user is disabled' do + let(:disabled) { true } + + context 'when user is confirmed' do + let(:confirmed_at) { Time.zone.now } + + it { is_expected.to be false } + end + + context 'when user is not confirmed' do + let(:confirmed_at) { nil } + + it { is_expected.to be false } + end + end + + context 'when user is not disabled' do + let(:disabled) { false } + + context 'when user is confirmed' do + let(:confirmed_at) { Time.zone.now } + + it { is_expected.to be true } + end + + context 'when user is not confirmed' do + let(:confirmed_at) { nil } + + it { is_expected.to be false } + end + end + end end diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index dc1f32e08..c575128e4 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -50,6 +50,14 @@ RSpec.configure do |config| Capybara.app_host = "http#{https ? 's' : ''}://#{ENV.fetch('LOCAL_DOMAIN')}" end + config.before :each, type: :controller do + stub_jsonld_contexts! + end + + config.before :each, type: :service do + stub_jsonld_contexts! + end + config.after :each do Rails.cache.clear @@ -69,3 +77,9 @@ end def attachment_fixture(name) File.open(File.join(Rails.root, 'spec', 'fixtures', 'files', name)) end + +def stub_jsonld_contexts! + stub_request(:get, 'https://www.w3.org/ns/activitystreams').to_return(request_fixture('json-ld.activitystreams.txt')) + stub_request(:get, 'https://w3id.org/identity/v1').to_return(request_fixture('json-ld.identity.txt')) + stub_request(:get, 'https://w3id.org/security/v1').to_return(request_fixture('json-ld.security.txt')) +end diff --git a/spec/requests/host_meta_request_spec.rb b/spec/requests/host_meta_request_spec.rb index 0c51b5f48..beb33a859 100644 --- a/spec/requests/host_meta_request_spec.rb +++ b/spec/requests/host_meta_request_spec.rb @@ -5,7 +5,7 @@ describe "The host_meta route" do it "returns an xml response" do get host_meta_url - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) expect(response.content_type).to eq "application/xrd+xml" end end diff --git a/spec/requests/webfinger_request_spec.rb b/spec/requests/webfinger_request_spec.rb index a17d6cc22..7f9e1162e 100644 --- a/spec/requests/webfinger_request_spec.rb +++ b/spec/requests/webfinger_request_spec.rb @@ -7,7 +7,7 @@ describe 'The webfinger route' do it 'returns a json response' do get webfinger_url(resource: alice.to_webfinger_s) - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) expect(response.content_type).to eq 'application/jrd+json' end end @@ -16,7 +16,7 @@ describe 'The webfinger route' do it 'returns an xml response for xml format' do get webfinger_url(resource: alice.to_webfinger_s, format: :xml) - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) expect(response.content_type).to eq 'application/xrd+xml' end @@ -24,7 +24,7 @@ describe 'The webfinger route' do headers = { 'HTTP_ACCEPT' => 'application/xrd+xml' } get webfinger_url(resource: alice.to_webfinger_s), headers: headers - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) expect(response.content_type).to eq 'application/xrd+xml' end end @@ -33,7 +33,7 @@ describe 'The webfinger route' do it 'returns a json response for json format' do get webfinger_url(resource: alice.to_webfinger_s, format: :json) - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) expect(response.content_type).to eq 'application/jrd+json' end @@ -41,7 +41,7 @@ describe 'The webfinger route' do headers = { 'HTTP_ACCEPT' => 'application/jrd+json' } get webfinger_url(resource: alice.to_webfinger_s), headers: headers - expect(response).to have_http_status(:success) + expect(response).to have_http_status(200) expect(response.content_type).to eq 'application/jrd+json' end end diff --git a/spec/services/account_search_service_spec.rb b/spec/services/account_search_service_spec.rb index 9bb27edad..c6cbdcce1 100644 --- a/spec/services/account_search_service_spec.rb +++ b/spec/services/account_search_service_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe AccountSearchService do +describe AccountSearchService, type: :service do describe '.call' do describe 'with a query to ignore' do it 'returns empty array for missing query' do @@ -137,5 +137,24 @@ describe AccountSearchService do expect(service).not_to have_received(:call) end end + + describe 'should not include suspended accounts' do + it 'returns the fuzzy match first, and does not return suspended exacts' do + partial = Fabricate(:account, username: 'exactness') + exact = Fabricate(:account, username: 'exact', suspended: true) + + results = subject.call('exact', 10) + expect(results.size).to eq 1 + expect(results).to eq [partial] + end + + it "does not return suspended remote accounts" do + remote = Fabricate(:account, username: 'a', domain: 'remote', display_name: 'e', suspended: true) + + results = subject.call('a@example.com', 2) + expect(results.size).to eq 0 + expect(results).to eq [] + end + end end end diff --git a/spec/services/activitypub/fetch_remote_account_service_spec.rb b/spec/services/activitypub/fetch_remote_account_service_spec.rb index c50d3fb97..dba55c034 100644 --- a/spec/services/activitypub/fetch_remote_account_service_spec.rb +++ b/spec/services/activitypub/fetch_remote_account_service_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -RSpec.describe ActivityPub::FetchRemoteAccountService do +RSpec.describe ActivityPub::FetchRemoteAccountService, type: :service do subject { ActivityPub::FetchRemoteAccountService.new } let!(:actor) do diff --git a/spec/services/activitypub/fetch_remote_status_service_spec.rb b/spec/services/activitypub/fetch_remote_status_service_spec.rb index a533e8413..549eb80fa 100644 --- a/spec/services/activitypub/fetch_remote_status_service_spec.rb +++ b/spec/services/activitypub/fetch_remote_status_service_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -RSpec.describe ActivityPub::FetchRemoteStatusService do +RSpec.describe ActivityPub::FetchRemoteStatusService, type: :service do include ActionView::Helpers::TextHelper let(:sender) { Fabricate(:account) } diff --git a/spec/services/activitypub/process_account_service_spec.rb b/spec/services/activitypub/process_account_service_spec.rb index 15e1f4bb2..d3318b2ed 100644 --- a/spec/services/activitypub/process_account_service_spec.rb +++ b/spec/services/activitypub/process_account_service_spec.rb @@ -1,14 +1,14 @@ require 'rails_helper' -RSpec.describe ActivityPub::ProcessAccountService do +RSpec.describe ActivityPub::ProcessAccountService, type: :service do subject { described_class.new } context 'property values' do let(:payload) do { - id: 'https://foo', + id: 'https://foo.test', type: 'Actor', - inbox: 'https://foo/inbox', + inbox: 'https://foo.test/inbox', attachment: [ { type: 'PropertyValue', name: 'Pronouns', value: 'They/them' }, { type: 'PropertyValue', name: 'Occupation', value: 'Unit test' }, diff --git a/spec/services/activitypub/process_collection_service_spec.rb b/spec/services/activitypub/process_collection_service_spec.rb index 3cea970cf..e46f0ae45 100644 --- a/spec/services/activitypub/process_collection_service_spec.rb +++ b/spec/services/activitypub/process_collection_service_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -RSpec.describe ActivityPub::ProcessCollectionService do +RSpec.describe ActivityPub::ProcessCollectionService, type: :service do let(:actor) { Fabricate(:account, domain: 'example.com', uri: 'http://example.com/account') } let(:payload) do diff --git a/spec/services/after_block_service_spec.rb b/spec/services/after_block_service_spec.rb index 1b115c938..f63b2045a 100644 --- a/spec/services/after_block_service_spec.rb +++ b/spec/services/after_block_service_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -RSpec.describe AfterBlockService do +RSpec.describe AfterBlockService, type: :service do subject do -> { described_class.new.call(account, target_account) } end diff --git a/spec/services/authorize_follow_service_spec.rb b/spec/services/authorize_follow_service_spec.rb index 6ea4d83da..562ef0041 100644 --- a/spec/services/authorize_follow_service_spec.rb +++ b/spec/services/authorize_follow_service_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -RSpec.describe AuthorizeFollowService do +RSpec.describe AuthorizeFollowService, type: :service do let(:sender) { Fabricate(:account, username: 'alice') } subject { AuthorizeFollowService.new } diff --git a/spec/services/batched_remove_status_service_spec.rb b/spec/services/batched_remove_status_service_spec.rb index 437da2a9d..23c122e59 100644 --- a/spec/services/batched_remove_status_service_spec.rb +++ b/spec/services/batched_remove_status_service_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -RSpec.describe BatchedRemoveStatusService do +RSpec.describe BatchedRemoveStatusService, type: :service do subject { BatchedRemoveStatusService.new } let!(:alice) { Fabricate(:account) } diff --git a/spec/services/block_domain_from_account_service_spec.rb b/spec/services/block_domain_from_account_service_spec.rb index e7ee34372..365c0a4ad 100644 --- a/spec/services/block_domain_from_account_service_spec.rb +++ b/spec/services/block_domain_from_account_service_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -RSpec.describe BlockDomainFromAccountService do +RSpec.describe BlockDomainFromAccountService, type: :service do let!(:wolf) { Fabricate(:account, username: 'wolf', domain: 'evil.org') } let!(:alice) { Fabricate(:account, username: 'alice') } diff --git a/spec/services/block_domain_service_spec.rb b/spec/services/block_domain_service_spec.rb index 5c2cfc8c7..7ef9e2770 100644 --- a/spec/services/block_domain_service_spec.rb +++ b/spec/services/block_domain_service_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -RSpec.describe BlockDomainService do +RSpec.describe BlockDomainService, type: :service do let(:bad_account) { Fabricate(:account, username: 'badguy666', domain: 'evil.org') } let(:bad_status1) { Fabricate(:status, account: bad_account, text: 'You suck') } let(:bad_status2) { Fabricate(:status, account: bad_account, text: 'Hahaha') } diff --git a/spec/services/block_service_spec.rb b/spec/services/block_service_spec.rb index c69ff7804..6584bb90e 100644 --- a/spec/services/block_service_spec.rb +++ b/spec/services/block_service_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -RSpec.describe BlockService do +RSpec.describe BlockService, type: :service do let(:sender) { Fabricate(:account, username: 'alice') } subject { BlockService.new } diff --git a/spec/services/bootstrap_timeline_service_spec.rb b/spec/services/bootstrap_timeline_service_spec.rb index 5189b1de8..a765de791 100644 --- a/spec/services/bootstrap_timeline_service_spec.rb +++ b/spec/services/bootstrap_timeline_service_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -RSpec.describe BootstrapTimelineService do +RSpec.describe BootstrapTimelineService, type: :service do subject { described_class.new } describe '#call' do diff --git a/spec/services/fan_out_on_write_service_spec.rb b/spec/services/fan_out_on_write_service_spec.rb index 764318e34..b7fc7f7ed 100644 --- a/spec/services/fan_out_on_write_service_spec.rb +++ b/spec/services/fan_out_on_write_service_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -RSpec.describe FanOutOnWriteService do +RSpec.describe FanOutOnWriteService, type: :service do let(:author) { Fabricate(:account, username: 'tom') } let(:status) { Fabricate(:status, text: 'Hello @alice #test', account: author) } let(:alice) { Fabricate(:user, account: Fabricate(:account, username: 'alice')).account } diff --git a/spec/services/favourite_service_spec.rb b/spec/services/favourite_service_spec.rb index 5bf2c74a9..0a20ccf6e 100644 --- a/spec/services/favourite_service_spec.rb +++ b/spec/services/favourite_service_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -RSpec.describe FavouriteService do +RSpec.describe FavouriteService, type: :service do let(:sender) { Fabricate(:account, username: 'alice') } subject { FavouriteService.new } diff --git a/spec/services/fetch_atom_service_spec.rb b/spec/services/fetch_atom_service_spec.rb index 2bd127e92..bb233c12d 100644 --- a/spec/services/fetch_atom_service_spec.rb +++ b/spec/services/fetch_atom_service_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -RSpec.describe FetchAtomService do +RSpec.describe FetchAtomService, type: :service do describe '#call' do let(:url) { 'http://example.com' } subject { FetchAtomService.new.call(url) } diff --git a/spec/services/fetch_link_card_service_spec.rb b/spec/services/fetch_link_card_service_spec.rb index edacc4425..88c5339db 100644 --- a/spec/services/fetch_link_card_service_spec.rb +++ b/spec/services/fetch_link_card_service_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -RSpec.describe FetchLinkCardService do +RSpec.describe FetchLinkCardService, type: :service do subject { FetchLinkCardService.new } before do diff --git a/spec/lib/provider_discovery_spec.rb b/spec/services/fetch_oembed_service_spec.rb index 12e2616c9..706eb3f2a 100644 --- a/spec/lib/provider_discovery_spec.rb +++ b/spec/services/fetch_oembed_service_spec.rb @@ -2,12 +2,19 @@ require 'rails_helper' -describe ProviderDiscovery do +describe FetchOEmbedService, type: :service do + subject { described_class.new } + + before do + stub_request(:get, "https://host.test/provider.json").to_return(status: 404) + stub_request(:get, "https://host.test/provider.xml").to_return(status: 404) + end + describe 'discover_provider' do context 'when status code is 200 and MIME type is text/html' do context 'Both of JSON and XML provider are discoverable' do before do - stub_request(:get, 'https://host/oembed.html').to_return( + stub_request(:get, 'https://host.test/oembed.html').to_return( status: 200, headers: { 'Content-Type': 'text/html' }, body: request_fixture('oembed_json_xml.html') @@ -15,21 +22,21 @@ describe ProviderDiscovery do end it 'returns new OEmbed::Provider for JSON provider if :format option is set to :json' do - provider = ProviderDiscovery.discover_provider('https://host/oembed.html', format: :json) - expect(provider.endpoint).to eq 'https://host/provider.json' - expect(provider.format).to eq :json + subject.call('https://host.test/oembed.html', format: :json) + expect(subject.endpoint_url).to eq 'https://host.test/provider.json' + expect(subject.format).to eq :json end it 'returns new OEmbed::Provider for XML provider if :format option is set to :xml' do - provider = ProviderDiscovery.discover_provider('https://host/oembed.html', format: :xml) - expect(provider.endpoint).to eq 'https://host/provider.xml' - expect(provider.format).to eq :xml + subject.call('https://host.test/oembed.html', format: :xml) + expect(subject.endpoint_url).to eq 'https://host.test/provider.xml' + expect(subject.format).to eq :xml end end context 'JSON provider is discoverable while XML provider is not' do before do - stub_request(:get, 'https://host/oembed.html').to_return( + stub_request(:get, 'https://host.test/oembed.html').to_return( status: 200, headers: { 'Content-Type': 'text/html' }, body: request_fixture('oembed_json.html') @@ -37,15 +44,15 @@ describe ProviderDiscovery do end it 'returns new OEmbed::Provider for JSON provider' do - provider = ProviderDiscovery.discover_provider('https://host/oembed.html') - expect(provider.endpoint).to eq 'https://host/provider.json' - expect(provider.format).to eq :json + subject.call('https://host.test/oembed.html') + expect(subject.endpoint_url).to eq 'https://host.test/provider.json' + expect(subject.format).to eq :json end end context 'XML provider is discoverable while JSON provider is not' do before do - stub_request(:get, 'https://host/oembed.html').to_return( + stub_request(:get, 'https://host.test/oembed.html').to_return( status: 200, headers: { 'Content-Type': 'text/html' }, body: request_fixture('oembed_xml.html') @@ -53,65 +60,65 @@ describe ProviderDiscovery do end it 'returns new OEmbed::Provider for XML provider' do - provider = ProviderDiscovery.discover_provider('https://host/oembed.html') - expect(provider.endpoint).to eq 'https://host/provider.xml' - expect(provider.format).to eq :xml + subject.call('https://host.test/oembed.html') + expect(subject.endpoint_url).to eq 'https://host.test/provider.xml' + expect(subject.format).to eq :xml end end context 'Invalid XML provider is discoverable while JSON provider is not' do before do - stub_request(:get, 'https://host/oembed.html').to_return( + stub_request(:get, 'https://host.test/oembed.html').to_return( status: 200, headers: { 'Content-Type': 'text/html' }, body: request_fixture('oembed_invalid_xml.html') ) end - it 'raises OEmbed::NotFound' do - expect { ProviderDiscovery.discover_provider('https://host/oembed.html') }.to raise_error OEmbed::NotFound + it 'returns nil' do + expect(subject.call('https://host.test/oembed.html')).to be_nil end end context 'Neither of JSON and XML provider is discoverable' do before do - stub_request(:get, 'https://host/oembed.html').to_return( + stub_request(:get, 'https://host.test/oembed.html').to_return( status: 200, headers: { 'Content-Type': 'text/html' }, body: request_fixture('oembed_undiscoverable.html') ) end - it 'raises OEmbed::NotFound' do - expect { ProviderDiscovery.discover_provider('https://host/oembed.html') }.to raise_error OEmbed::NotFound + it 'returns nil' do + expect(subject.call('https://host.test/oembed.html')).to be_nil end end end context 'when status code is not 200' do before do - stub_request(:get, 'https://host/oembed.html').to_return( + stub_request(:get, 'https://host.test/oembed.html').to_return( status: 400, headers: { 'Content-Type': 'text/html' }, body: request_fixture('oembed_xml.html') ) end - it 'raises OEmbed::NotFound' do - expect { ProviderDiscovery.discover_provider('https://host/oembed.html') }.to raise_error OEmbed::NotFound + it 'returns nil' do + expect(subject.call('https://host.test/oembed.html')).to be_nil end end context 'when MIME type is not text/html' do before do - stub_request(:get, 'https://host/oembed.html').to_return( + stub_request(:get, 'https://host.test/oembed.html').to_return( status: 200, body: request_fixture('oembed_xml.html') ) end - it 'raises OEmbed::NotFound' do - expect { ProviderDiscovery.discover_provider('https://host/oembed.html') }.to raise_error OEmbed::NotFound + it 'returns nil' do + expect(subject.call('https://host.test/oembed.html')).to be_nil end end end diff --git a/spec/services/fetch_remote_account_service_spec.rb b/spec/services/fetch_remote_account_service_spec.rb index 4388d4cf4..1c3abe8f3 100644 --- a/spec/services/fetch_remote_account_service_spec.rb +++ b/spec/services/fetch_remote_account_service_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -RSpec.describe FetchRemoteAccountService do +RSpec.describe FetchRemoteAccountService, type: :service do let(:url) { 'https://example.com' } let(:prefetched_body) { nil } let(:protocol) { :ostatus } diff --git a/spec/services/fetch_remote_status_service_spec.rb b/spec/services/fetch_remote_status_service_spec.rb index fa5782b94..0df9c329a 100644 --- a/spec/services/fetch_remote_status_service_spec.rb +++ b/spec/services/fetch_remote_status_service_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -RSpec.describe FetchRemoteStatusService do +RSpec.describe FetchRemoteStatusService, type: :service do let(:account) { Fabricate(:account) } let(:prefetched_body) { nil } let(:valid_domain) { Rails.configuration.x.local_domain } diff --git a/spec/services/follow_service_spec.rb b/spec/services/follow_service_spec.rb index e59a2f1a6..3c4ec59be 100644 --- a/spec/services/follow_service_spec.rb +++ b/spec/services/follow_service_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -RSpec.describe FollowService do +RSpec.describe FollowService, type: :service do let(:sender) { Fabricate(:account, username: 'alice') } subject { FollowService.new } diff --git a/spec/services/mute_service_spec.rb b/spec/services/mute_service_spec.rb index 2b3e3e152..4bb839b8d 100644 --- a/spec/services/mute_service_spec.rb +++ b/spec/services/mute_service_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -RSpec.describe MuteService do +RSpec.describe MuteService, type: :service do subject do -> { described_class.new.call(account, target_account) } end diff --git a/spec/services/notify_service_spec.rb b/spec/services/notify_service_spec.rb index 1435ec917..ff64eccbe 100644 --- a/spec/services/notify_service_spec.rb +++ b/spec/services/notify_service_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -RSpec.describe NotifyService do +RSpec.describe NotifyService, type: :service do subject do -> { described_class.new.call(recipient, activity) } end diff --git a/spec/services/post_status_service_spec.rb b/spec/services/post_status_service_spec.rb index 92fbc73cd..40fa8fbef 100644 --- a/spec/services/post_status_service_spec.rb +++ b/spec/services/post_status_service_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -RSpec.describe PostStatusService do +RSpec.describe PostStatusService, type: :service do subject { PostStatusService.new } it 'creates a new status' do diff --git a/spec/services/precompute_feed_service_spec.rb b/spec/services/precompute_feed_service_spec.rb index 43340bffc..1f6b6ed88 100644 --- a/spec/services/precompute_feed_service_spec.rb +++ b/spec/services/precompute_feed_service_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -RSpec.describe PrecomputeFeedService do +RSpec.describe PrecomputeFeedService, type: :service do subject { PrecomputeFeedService.new } describe 'call' do diff --git a/spec/services/process_feed_service_spec.rb b/spec/services/process_feed_service_spec.rb index aca675dc6..d8b065063 100644 --- a/spec/services/process_feed_service_spec.rb +++ b/spec/services/process_feed_service_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -RSpec.describe ProcessFeedService do +RSpec.describe ProcessFeedService, type: :service do subject { ProcessFeedService.new } describe 'processing a feed' do diff --git a/spec/services/process_interaction_service_spec.rb b/spec/services/process_interaction_service_spec.rb index 3ea7aec59..b858c19d0 100644 --- a/spec/services/process_interaction_service_spec.rb +++ b/spec/services/process_interaction_service_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -RSpec.describe ProcessInteractionService do +RSpec.describe ProcessInteractionService, type: :service do let(:receiver) { Fabricate(:user, email: 'alice@example.com', account: Fabricate(:account, username: 'alice')).account } let(:sender) { Fabricate(:user, email: 'bob@example.com', account: Fabricate(:account, username: 'bob')).account } let(:remote_sender) { Fabricate(:account, username: 'carol', domain: 'localdomain.com', uri: 'https://webdomain.com/users/carol') } diff --git a/spec/services/process_mentions_service_spec.rb b/spec/services/process_mentions_service_spec.rb index 19a8678f0..963924fa9 100644 --- a/spec/services/process_mentions_service_spec.rb +++ b/spec/services/process_mentions_service_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -RSpec.describe ProcessMentionsService do +RSpec.describe ProcessMentionsService, type: :service do let(:account) { Fabricate(:account, username: 'alice') } let(:status) { Fabricate(:status, account: account, text: "Hello @#{remote_user.acct}") } diff --git a/spec/services/pubsubhubbub/subscribe_service_spec.rb b/spec/services/pubsubhubbub/subscribe_service_spec.rb index 82094117b..01c956230 100644 --- a/spec/services/pubsubhubbub/subscribe_service_spec.rb +++ b/spec/services/pubsubhubbub/subscribe_service_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -describe Pubsubhubbub::SubscribeService do +describe Pubsubhubbub::SubscribeService, type: :service do describe '#call' do subject { described_class.new } let(:user_account) { Fabricate(:account) } diff --git a/spec/services/pubsubhubbub/unsubscribe_service_spec.rb b/spec/services/pubsubhubbub/unsubscribe_service_spec.rb index 59054ed99..7ed9fc5af 100644 --- a/spec/services/pubsubhubbub/unsubscribe_service_spec.rb +++ b/spec/services/pubsubhubbub/unsubscribe_service_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -describe Pubsubhubbub::UnsubscribeService do +describe Pubsubhubbub::UnsubscribeService, type: :service do describe '#call' do subject { described_class.new } diff --git a/spec/services/reblog_service_spec.rb b/spec/services/reblog_service_spec.rb index 19d3bb6cb..2755da772 100644 --- a/spec/services/reblog_service_spec.rb +++ b/spec/services/reblog_service_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -RSpec.describe ReblogService do +RSpec.describe ReblogService, type: :service do let(:alice) { Fabricate(:account, username: 'alice') } context 'OStatus' do diff --git a/spec/services/reject_follow_service_spec.rb b/spec/services/reject_follow_service_spec.rb index bf49dd2c9..e5ac37ed9 100644 --- a/spec/services/reject_follow_service_spec.rb +++ b/spec/services/reject_follow_service_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -RSpec.describe RejectFollowService do +RSpec.describe RejectFollowService, type: :service do let(:sender) { Fabricate(:account, username: 'alice') } subject { RejectFollowService.new } diff --git a/spec/services/remove_status_service_spec.rb b/spec/services/remove_status_service_spec.rb index 5bb75b820..2134f51fd 100644 --- a/spec/services/remove_status_service_spec.rb +++ b/spec/services/remove_status_service_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -RSpec.describe RemoveStatusService do +RSpec.describe RemoveStatusService, type: :service do subject { RemoveStatusService.new } let!(:alice) { Fabricate(:account) } diff --git a/spec/services/report_service_spec.rb b/spec/services/report_service_spec.rb index 2f926ef00..2c392d376 100644 --- a/spec/services/report_service_spec.rb +++ b/spec/services/report_service_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -RSpec.describe ReportService do +RSpec.describe ReportService, type: :service do subject { described_class.new } let(:source_account) { Fabricate(:account) } diff --git a/spec/services/resolve_account_service_spec.rb b/spec/services/resolve_account_service_spec.rb index 5f1b4467b..f4c810f75 100644 --- a/spec/services/resolve_account_service_spec.rb +++ b/spec/services/resolve_account_service_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -RSpec.describe ResolveAccountService do +RSpec.describe ResolveAccountService, type: :service do subject { described_class.new } before do @@ -105,6 +105,20 @@ RSpec.describe ResolveAccountService do expect(account.inbox_url).to eq 'https://ap.example.com/users/foo/inbox' end + context 'with multiple types' do + before do + stub_request(:get, "https://ap.example.com/users/foo").to_return(request_fixture('activitypub-actor-individual.txt')) + end + + it 'returns new remote account' do + account = subject.call('foo@ap.example.com') + + expect(account.activitypub?).to eq true + expect(account.domain).to eq 'ap.example.com' + expect(account.inbox_url).to eq 'https://ap.example.com/users/foo/inbox' + end + end + pending end diff --git a/spec/services/resolve_url_service_spec.rb b/spec/services/resolve_url_service_spec.rb index 1e9be4c07..7bb5d1940 100644 --- a/spec/services/resolve_url_service_spec.rb +++ b/spec/services/resolve_url_service_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -describe ResolveURLService do +describe ResolveURLService, type: :service do subject { described_class.new } describe '#call' do diff --git a/spec/services/search_service_spec.rb b/spec/services/search_service_spec.rb index 957b60c7d..673de5233 100644 --- a/spec/services/search_service_spec.rb +++ b/spec/services/search_service_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -describe SearchService do +describe SearchService, type: :service do subject { described_class.new } describe '#call' do diff --git a/spec/services/send_interaction_service_spec.rb b/spec/services/send_interaction_service_spec.rb index ff08394b0..710d8184c 100644 --- a/spec/services/send_interaction_service_spec.rb +++ b/spec/services/send_interaction_service_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -RSpec.describe SendInteractionService do +RSpec.describe SendInteractionService, type: :service do subject { SendInteractionService.new } it 'sends an XML envelope to the Salmon end point of remote user' diff --git a/spec/services/subscribe_service_spec.rb b/spec/services/subscribe_service_spec.rb index 835be5ec5..10bdb1ba8 100644 --- a/spec/services/subscribe_service_spec.rb +++ b/spec/services/subscribe_service_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -RSpec.describe SubscribeService do +RSpec.describe SubscribeService, type: :service do let(:account) { Fabricate(:account, username: 'bob', domain: 'example.com', hub_url: 'http://hub.example.com') } subject { SubscribeService.new } diff --git a/spec/services/suspend_account_service_spec.rb b/spec/services/suspend_account_service_spec.rb index 1cb647e8d..fd303a9d5 100644 --- a/spec/services/suspend_account_service_spec.rb +++ b/spec/services/suspend_account_service_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -RSpec.describe SuspendAccountService do +RSpec.describe SuspendAccountService, type: :service do describe '#call' do subject do -> { described_class.new.call(account) } diff --git a/spec/services/unblock_domain_service_spec.rb b/spec/services/unblock_domain_service_spec.rb index c32e5d655..8e8893d63 100644 --- a/spec/services/unblock_domain_service_spec.rb +++ b/spec/services/unblock_domain_service_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -describe UnblockDomainService do +describe UnblockDomainService, type: :service do subject { described_class.new } describe 'call' do diff --git a/spec/services/unblock_service_spec.rb b/spec/services/unblock_service_spec.rb index ca7a6b77e..5835b912b 100644 --- a/spec/services/unblock_service_spec.rb +++ b/spec/services/unblock_service_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -RSpec.describe UnblockService do +RSpec.describe UnblockService, type: :service do let(:sender) { Fabricate(:account, username: 'alice') } subject { UnblockService.new } diff --git a/spec/services/unfollow_service_spec.rb b/spec/services/unfollow_service_spec.rb index 021e76782..c5914c818 100644 --- a/spec/services/unfollow_service_spec.rb +++ b/spec/services/unfollow_service_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -RSpec.describe UnfollowService do +RSpec.describe UnfollowService, type: :service do let(:sender) { Fabricate(:account, username: 'alice') } subject { UnfollowService.new } diff --git a/spec/services/unmute_service_spec.rb b/spec/services/unmute_service_spec.rb index 5dc971fb1..8463eb283 100644 --- a/spec/services/unmute_service_spec.rb +++ b/spec/services/unmute_service_spec.rb @@ -1,5 +1,5 @@ require 'rails_helper' -RSpec.describe UnmuteService do +RSpec.describe UnmuteService, type: :service do subject { UnmuteService.new } end diff --git a/spec/services/unsubscribe_service_spec.rb b/spec/services/unsubscribe_service_spec.rb index 2a02f4c75..54d4b1b53 100644 --- a/spec/services/unsubscribe_service_spec.rb +++ b/spec/services/unsubscribe_service_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -RSpec.describe UnsubscribeService do +RSpec.describe UnsubscribeService, type: :service do let(:account) { Fabricate(:account, username: 'bob', domain: 'example.com', hub_url: 'http://hub.example.com') } subject { UnsubscribeService.new } diff --git a/spec/services/update_remote_profile_service_spec.rb b/spec/services/update_remote_profile_service_spec.rb index 64ec2dbbb..7ac3a809a 100644 --- a/spec/services/update_remote_profile_service_spec.rb +++ b/spec/services/update_remote_profile_service_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -RSpec.describe UpdateRemoteProfileService do +RSpec.describe UpdateRemoteProfileService, type: :service do let(:xml) { File.read(File.join(Rails.root, 'spec', 'fixtures', 'push', 'feed.atom')) } subject { UpdateRemoteProfileService.new } diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index a0466dd4b..903032937 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,3 +1,4 @@ +#require 'rspec/retry' require 'simplecov' GC.disable @@ -11,6 +12,9 @@ end gc_counter = -1 RSpec.configure do |config| + #config.verbose_retry = true + #config.display_try_failure_messages = true + config.expect_with :rspec do |expectations| expectations.include_chain_clauses_in_custom_matcher_descriptions = true end @@ -25,6 +29,10 @@ RSpec.configure do |config| end end + #config.around :each do |ex| + # ex.run_with_retry retry: 3 + #end + config.before :suite do Chewy.strategy(:bypass) end diff --git a/spec/views/stream_entries/show.html.haml_spec.rb b/spec/views/stream_entries/show.html.haml_spec.rb index 6074bbc2e..560039ffa 100644 --- a/spec/views/stream_entries/show.html.haml_spec.rb +++ b/spec/views/stream_entries/show.html.haml_spec.rb @@ -24,6 +24,7 @@ describe 'stream_entries/show.html.haml', without_verify_partial_doubles: true d assign(:stream_entry, status.stream_entry) assign(:account, alice) assign(:type, status.stream_entry.activity_type.downcase) + assign(:descendant_threads, []) render @@ -49,7 +50,7 @@ describe 'stream_entries/show.html.haml', without_verify_partial_doubles: true d assign(:account, alice) assign(:type, reply.stream_entry.activity_type.downcase) assign(:ancestors, reply.stream_entry.activity.ancestors(1, bob) ) - assign(:descendants, reply.stream_entry.activity.descendants(bob)) + assign(:descendant_threads, [{ statuses: reply.stream_entry.activity.descendants(1)}]) render @@ -75,6 +76,7 @@ describe 'stream_entries/show.html.haml', without_verify_partial_doubles: true d assign(:stream_entry, status.stream_entry) assign(:account, alice) assign(:type, status.stream_entry.activity_type.downcase) + assign(:descendant_threads, []) render |