From 671e8476ba30b78fa0478955bf2b41a03c26de9d Mon Sep 17 00:00:00 2001 From: Ntavranis Serafeim Date: Thu, 11 Mar 2021 12:38:58 +0200 Subject: [PATCH] Update factory_girl to factory_bot --- Gemfile | 2 +- Gemfile.lock | 12 +- features/step_definitions/message_steps.rb | 2 +- .../step_definitions/oidc_common_steps.rb | 6 +- features/step_definitions/posts_steps.rb | 6 +- features/step_definitions/tag_steps.rb | 2 +- features/step_definitions/user_steps.rb | 14 +- features/support/user_cuke_helpers.rb | 4 +- .../controllers/admin/pods_controller_spec.rb | 6 +- .../admin/users_controller_spec.rb | 8 +- spec/controllers/admins_controller_spec.rb | 6 +- .../authorizations_controller_spec.rb | 8 +- .../openid_connect/clients_controller_spec.rb | 2 +- .../token_endpoint_controller_spec.rb | 2 +- .../openid_connect/user_applications_spec.rb | 6 +- spec/controllers/aspects_controller_spec.rb | 2 +- spec/controllers/comments_controller_spec.rb | 2 +- spec/controllers/contacts_controller_spec.rb | 8 +- .../conversations_controller_spec.rb | 16 +- .../jasmine_fixtures/admins_spec.rb | 2 +- .../jasmine_fixtures/contacts_spec.rb | 2 +- .../jasmine_fixtures/notifications_spec.rb | 6 +- .../jasmine_fixtures/streams_spec.rb | 2 +- spec/controllers/links_controller_spec.rb | 4 +- spec/controllers/messages_controller_spec.rb | 2 +- .../notifications_controller_spec.rb | 50 ++--- .../participations_controller_spec.rb | 4 +- spec/controllers/people_controller_spec.rb | 54 +++--- spec/controllers/photos_controller_spec.rb | 10 +- .../poll_participations_controller_spec.rb | 2 +- spec/controllers/posts_controller_spec.rb | 4 +- spec/controllers/profiles_controller_spec.rb | 4 +- spec/controllers/reshares_controller_spec.rb | 6 +- spec/controllers/services_controller_spec.rb | 4 +- spec/controllers/streams_controller_spec.rb | 2 +- ..._factor_authentications_controller_spec.rb | 2 +- spec/controllers/users_controller_spec.rb | 10 +- spec/factories.rb | 174 +++++++++--------- spec/federation_callbacks_spec.rb | 82 ++++----- spec/helpers/application_helper_spec.rb | 6 +- spec/helpers/conversations_helper_spec.rb | 2 +- spec/helpers/gon_helper_spec.rb | 4 +- spec/helpers/notifications_helper_spec.rb | 24 +-- spec/helpers/notifier_helper_spec.rb | 12 +- spec/helpers/people_helper_spec.rb | 6 +- spec/helpers/posts_helper_spec.rb | 6 +- spec/integration/account_deletion_spec.rb | 2 +- spec/integration/account_migration_spec.rb | 70 +++---- .../api/aspects_controller_spec.rb | 6 +- .../api/comments_controller_spec.rb | 12 +- .../api/contacts_controller_spec.rb | 8 +- .../api/conversations_controller_spec.rb | 10 +- spec/integration/api/likes_controller_spec.rb | 12 +- .../api/messages_controller_spec.rb | 6 +- .../api/notifications_controller_spec.rb | 10 +- .../integration/api/photos_controller_spec.rb | 10 +- .../api/post_interactions_controller_spec.rb | 6 +- spec/integration/api/posts_controller_spec.rb | 24 +-- .../api/reshares_controller_spec.rb | 8 +- .../integration/api/search_controller_spec.rb | 32 ++-- .../api/streams_controller_spec.rb | 12 +- .../api/tag_followings_controller_spec.rb | 6 +- .../api/user_info_controller_spec.rb | 2 +- spec/integration/api/users_controller_spec.rb | 22 +-- spec/integration/archive_shared.rb | 2 +- spec/integration/contacts_spec.rb | 8 +- spec/integration/dispatching_spec.rb | 2 +- spec/integration/export/memory_usage_spec.rb | 10 +- spec/integration/exporter_spec.rb | 18 +- .../federation/attack_vectors_spec.rb | 6 +- .../federation/federation_helper.rb | 6 +- .../receive_federation_messages_spec.rb | 10 +- .../federation/shared_receive_stream_items.rb | 26 +-- spec/integration/mentioning_spec.rb | 30 +-- spec/integration/migration_service_spec.rb | 40 ++-- spec/integration/mobile_posts_spec.rb | 4 +- spec/integration/tag_people_spec.rb | 2 +- .../protected_resource_endpoint_spec.rb | 2 +- .../api/openid_connect/token_endpoint_spec.rb | 4 +- .../archive_importer/contact_importer_spec.rb | 6 +- .../archive_importer/entity_importer_spec.rb | 10 +- .../own_entity_importer_shared.rb | 2 +- .../own_entity_importer_spec.rb | 4 +- .../own_relayable_importer_spec.rb | 8 +- .../archive_importer/post_importer_spec.rb | 12 +- spec/lib/archive_importer_spec.rb | 4 +- .../author_private_key_validator_spec.rb | 6 +- .../contact_validator_spec.rb | 8 +- .../contacts_validator_spec.rb | 4 +- .../own_relayable_validator_spec.rb | 10 +- .../archive_validator/posts_validator_spec.rb | 2 +- .../relayable_validator_spec.rb | 2 +- .../relayables_validator_spec.rb | 2 +- spec/lib/archive_validator/shared.rb | 4 +- .../exporter/others_relayables_spec.rb | 10 +- spec/lib/diaspora/exporter_spec.rb | 2 +- .../federated/contact_retraction_spec.rb | 6 +- .../lib/diaspora/federated/retraction_spec.rb | 8 +- .../federation/dispatcher/private_spec.rb | 16 +- .../federation/dispatcher/public_spec.rb | 8 +- .../diaspora/federation/dispatcher_spec.rb | 10 +- spec/lib/diaspora/federation/entities_spec.rb | 58 +++--- spec/lib/diaspora/federation/receive_spec.rb | 22 +-- spec/lib/diaspora/fetcher/public_spec.rb | 14 +- spec/lib/diaspora/mentionable_spec.rb | 8 +- spec/lib/diaspora/message_renderer_spec.rb | 18 +- spec/lib/evil_query_spec.rb | 10 +- spec/lib/stream/base_spec.rb | 14 +- spec/lib/stream/multi_spec.rb | 2 +- spec/lib/stream/tag_spec.rb | 8 +- spec/mailers/maintenance_spec.rb | 2 +- spec/mailers/notifier_spec.rb | 26 +-- spec/mailers/report_spec.rb | 6 +- spec/models/account_deletion_spec.rb | 6 +- spec/models/account_migration_spec.rb | 62 +++---- .../api/openid_connect/id_token_spec.rb | 2 +- spec/models/aspect_visibility_spec.rb | 8 +- spec/models/comment_spec.rb | 10 +- spec/models/contact_spec.rb | 34 ++-- spec/models/invitation_code_spec.rb | 6 +- spec/models/like_spec.rb | 16 +- spec/models/location_spec.rb | 2 +- spec/models/notification_spec.rb | 6 +- .../notifications/also_commented_spec.rb | 8 +- .../notifications/mentioned_in_post_spec.rb | 6 +- spec/models/notifications/mentioned_spec.rb | 6 +- spec/models/notifications/reshared_spec.rb | 4 +- spec/models/participation_spec.rb | 2 +- spec/models/person_spec.rb | 94 +++++----- spec/models/pod_spec.rb | 26 +-- spec/models/poll_answer_spec.rb | 2 +- spec/models/poll_participation_spec.rb | 10 +- spec/models/poll_spec.rb | 2 +- spec/models/post_spec.rb | 76 ++++---- spec/models/profile_spec.rb | 46 ++--- spec/models/reference_spec.rb | 10 +- spec/models/reshare_spec.rb | 52 +++--- spec/models/share_visibility_spec.rb | 4 +- spec/models/status_message_spec.rb | 58 +++--- spec/models/tag_following_spec.rb | 2 +- spec/models/user/connecting_spec.rb | 4 +- spec/models/user/querying_spec.rb | 20 +- spec/models/user/social_actions_spec.rb | 4 +- spec/models/user_spec.rb | 74 ++++---- spec/presenters/avatar_presenter_spec.rb | 6 +- .../presenters/conversation_presenter_spec.rb | 2 +- spec/presenters/likes_presenter_spec.rb | 2 +- .../presenters/notification_presenter_spec.rb | 18 +- spec/presenters/o_embed_presenter_spec.rb | 4 +- spec/presenters/person_presenter_spec.rb | 24 +-- spec/presenters/poll_presenter_spec.rb | 2 +- .../post_interaction_presenter_spec.rb | 4 +- spec/presenters/post_presenter_spec.rb | 34 ++-- spec/presenters/profile_presenter_spec.rb | 2 +- .../presenters/social_relay_presenter_spec.rb | 28 +-- .../export/aspect_serializer_spec.rb | 2 +- .../export/contact_serializer_spec.rb | 4 +- .../export/others_data_serializer_spec.rb | 2 +- .../export/own_post_serializer_spec.rb | 8 +- .../export/own_relayables_serializer_spec.rb | 4 +- .../export/user_serializer_spec.rb | 2 +- .../notification_serializer_spec.rb | 2 +- spec/services/diaspora_link_service_spec.rb | 8 +- spec/services/notification_service_spec.rb | 6 +- .../poll_participation_service_spec.rb | 2 +- spec/services/post_service_spec.rb | 50 ++--- spec/shared_behaviors/mentions_container.rb | 2 +- spec/shared_behaviors/receiving.rb | 2 +- spec/shared_behaviors/references.rb | 30 +-- spec/shared_behaviors/relayable.rb | 6 +- spec/shared_behaviors/shareable.rb | 4 +- spec/shared_behaviors/signature.rb | 2 +- spec/spec/data_generator_spec.rb | 4 +- spec/spec/misc_spec.rb | 2 +- spec/spec_helper.rb | 3 +- spec/support/data_generator.rb | 22 +-- spec/support/fixture_builder.rb | 16 +- .../_status_message.mobile.haml_spec.rb | 2 +- spec/workers/cleanup_old_exports_spec.rb | 2 +- spec/workers/cleanup_pending_photos_spec.rb | 2 +- spec/workers/fetch_profile_photo_spec.rb | 2 +- spec/workers/fetch_webfinger_spec.rb | 2 +- spec/workers/gather_o_embed_data_spec.rb | 2 +- spec/workers/gather_open_graph_data_spec.rb | 2 +- spec/workers/mail/liked_spec.rb | 12 +- spec/workers/mail/mentioned_spec.rb | 2 +- spec/workers/mail/reshared_spec.rb | 4 +- spec/workers/process_photo_spec.rb | 2 +- spec/workers/queue_users_for_removal_spec.rb | 18 +- spec/workers/recheck_offline_pods_spec.rb | 4 +- spec/workers/recurring_pod_check_spec.rb | 2 +- 191 files changed, 1194 insertions(+), 1195 deletions(-) diff --git a/Gemfile b/Gemfile index a0b2d4f59..ac8f47a37 100644 --- a/Gemfile +++ b/Gemfile @@ -288,7 +288,7 @@ group :test do # General helpers - gem "factory_girl_rails", "4.9.0" + gem "factory_bot_rails", "6.1.0" gem "shoulda-matchers", "4.0.1" gem "timecop", "0.9.1" gem "webmock", "3.8.3", require: false diff --git a/Gemfile.lock b/Gemfile.lock index bed503654..1b00774fc 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -227,11 +227,11 @@ GEM state_machines thor fabrication (2.21.0) - factory_girl (4.9.0) - activesupport (>= 3.0.0) - factory_girl_rails (4.9.0) - factory_girl (~> 4.9.0) - railties (>= 3.0.0) + factory_bot (6.1.0) + activesupport (>= 5.0.0) + factory_bot_rails (6.1.0) + factory_bot (~> 6.1.0) + railties (>= 5.0.0) faraday (0.15.4) multipart-post (>= 1.2, < 3) faraday-cookie_jar (0.0.6) @@ -811,7 +811,7 @@ DEPENDENCIES diaspora_federation-test (= 0.2.6) entypo-rails (= 3.0.0) eye (= 0.10.0) - factory_girl_rails (= 4.9.0) + factory_bot_rails (= 6.1.0) faraday (= 0.15.4) faraday-cookie_jar (= 0.0.6) faraday_middleware (= 0.13.1) diff --git a/features/step_definitions/message_steps.rb b/features/step_definitions/message_steps.rb index 631b5437e..c617fe076 100644 --- a/features/step_definitions/message_steps.rb +++ b/features/step_definitions/message_steps.rb @@ -3,7 +3,7 @@ Then /^I should see the "(.*)" message$/ do |message| text = case message when "alice is excited" - @alice ||= FactoryGirl.create(:user, :username => "Alice") + @alice ||= FactoryBot.create(:user, :username => "Alice") I18n.translate('invitation_codes.excited', :name => @alice.name) when "welcome to diaspora" I18n.translate('users.getting_started.well_hello_there') diff --git a/features/step_definitions/oidc_common_steps.rb b/features/step_definitions/oidc_common_steps.rb index c95125374..b6d6dff55 100644 --- a/features/step_definitions/oidc_common_steps.rb +++ b/features/step_definitions/oidc_common_steps.rb @@ -1,14 +1,14 @@ # frozen_string_literal: true Given /^a client with a provided picture exists for user "([^\"]*)"$/ do |email| - app = FactoryGirl.create(:o_auth_application, logo_uri: "/assets/user/default.png") + app = FactoryBot.create(:o_auth_application, logo_uri: "/assets/user/default.png") user = User.find_by(email: email) - FactoryGirl.create(:auth_with_read_scopes, user: user, o_auth_application: app) + FactoryBot.create(:auth_with_read_scopes, user: user, o_auth_application: app) end Given /^a client exists for user "([^\"]*)"$/ do |email| user = User.find_by(email: email) - FactoryGirl.create(:auth_with_read_scopes, user: user) + FactoryBot.create(:auth_with_read_scopes, user: user) end When /^I register a new client$/ do diff --git a/features/step_definitions/posts_steps.rb b/features/step_definitions/posts_steps.rb index da3ee2924..e0597d3b9 100644 --- a/features/step_definitions/posts_steps.rb +++ b/features/step_definitions/posts_steps.rb @@ -20,19 +20,19 @@ end Given /^"([^"]*)" has a public post with text "([^"]*)" and a poll$/ do |email, text| user = User.find_by(email: email) post = user.post(:status_message, text: text, public: true, to: user.aspect_ids) - FactoryGirl.create(:poll, status_message: post) + FactoryBot.create(:poll, status_message: post) end Given /^"([^"]*)" has a public post with text "([^"]*)" and a location$/ do |email, text| user = User.find_by(email: email) post = user.post(:status_message, text: text, public: true, to: user.aspect_ids) - FactoryGirl.create(:location, status_message: post) + FactoryBot.create(:location, status_message: post) end Given /^"([^"]*)" has a public post with text "([^"]*)" and a picture/ do |email, text| user = User.find_by(email: email) post = user.post(:status_message, text: text, public: true, to: user.aspect_ids) - FactoryGirl.create(:photo, status_message: post) + FactoryBot.create(:photo, status_message: post) end Given /^there are (\d+) public posts from "([^"]*)"$/ do |n_posts, email| diff --git a/features/step_definitions/tag_steps.rb b/features/step_definitions/tag_steps.rb index 7a6dbabac..9c1854ec4 100644 --- a/features/step_definitions/tag_steps.rb +++ b/features/step_definitions/tag_steps.rb @@ -11,5 +11,5 @@ When(/^I unfollow the "(.*?)" tag$/) do |tag| end When /^I follow the "(.*?)" tag$/ do |tag| - TagFollowing.create!(tag: FactoryGirl.create(:tag, name: tag), user: @me) + TagFollowing.create!(tag: FactoryBot.create(:tag, name: tag), user: @me) end diff --git a/features/step_definitions/user_steps.rb b/features/step_definitions/user_steps.rb index 804642cae..8d0b32dac 100644 --- a/features/step_definitions/user_steps.rb +++ b/features/step_definitions/user_steps.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true Given /^a user with username "([^\"]*)" and password "([^\"]*)"$/ do |username, password| - @me ||= FactoryGirl.create(:user, :username => username, :password => password, + @me ||= FactoryBot.create(:user, :username => username, :password => password, :password_confirmation => password, :getting_started => false) @me.aspects.create(:name => "Besties") @me.aspects.create(:name => "Unicorns") @@ -50,7 +50,7 @@ Given /^(?:|[tT]hat )?following user[s]?(?: exist[s]?)?:$/ do |table| end Given /^I have been invited by an admin$/ do - admin = FactoryGirl.create(:user) + admin = FactoryBot.create(:user) admin.invitation_code i = EmailInviter.new("new_invitee@example.com", admin) i.send! @@ -107,8 +107,8 @@ Given /^a user with email "([^\"]*)" is tagged "([^\"]*)"$/ do |email, tags| end Given /^many posts from alice for bob$/ do - alice = FactoryGirl.create(:user_with_aspect, :username => 'alice', :email => 'alice@alice.alice', :password => 'password', :getting_started => false) - bob = FactoryGirl.create(:user_with_aspect, :username => 'bob', :email => 'bob@bob.bob', :password => 'password', :getting_started => false) + alice = FactoryBot.create(:user_with_aspect, :username => 'alice', :email => 'alice@alice.alice', :password => 'password', :getting_started => false) + bob = FactoryBot.create(:user_with_aspect, :username => 'bob', :email => 'bob@bob.bob', :password => 'password', :getting_started => false) connect_users_with_aspects(alice, bob) time_fulcrum = Time.now - 40000 time_interval = 1000 @@ -171,7 +171,7 @@ end When /^"([^\"]+)" has posted a (public )?status message with a photo$/ do |email, public_status| user = User.find_for_database_authentication(:username => email) - post = FactoryGirl.create( + post = FactoryBot.create( :status_message_with_photo, text: "Look at this dog", author: user.person, @@ -195,7 +195,7 @@ Given /^I have (\d+) contacts$/ do |n| aspect_memberships = [] count.times do - person = FactoryGirl.create(:person) + person = FactoryBot.create(:person) people << person end @@ -233,5 +233,5 @@ Then /^I should get a zipped file$/ do end And /^a person with ID "([^\"]*)" has been discovered$/ do |diaspora_id| - FactoryGirl.create(:person, diaspora_handle: diaspora_id) + FactoryBot.create(:person, diaspora_handle: diaspora_id) end diff --git a/features/support/user_cuke_helpers.rb b/features/support/user_cuke_helpers.rb index 196080408..6ed49828a 100644 --- a/features/support/user_cuke_helpers.rb +++ b/features/support/user_cuke_helpers.rb @@ -12,7 +12,7 @@ module UserCukeHelpers :getting_started => false } - user = FactoryGirl.create(:user, default_attrs.merge(overrides)) + user = FactoryBot.create(:user, default_attrs.merge(overrides)) add_standard_aspects(user) user end @@ -33,7 +33,7 @@ module UserCukeHelpers # create a new @me user, if not present, and log in using the # integration_sessions controller (automatic) def automatic_login - @me ||= FactoryGirl.create(:user_with_aspect, :getting_started => false) + @me ||= FactoryBot.create(:user_with_aspect, :getting_started => false) visit(new_integration_sessions_path(user_id: @me.id)) click_button "Login" end diff --git a/spec/controllers/admin/pods_controller_spec.rb b/spec/controllers/admin/pods_controller_spec.rb index 02085a180..c1e53d28a 100644 --- a/spec/controllers/admin/pods_controller_spec.rb +++ b/spec/controllers/admin/pods_controller_spec.rb @@ -2,7 +2,7 @@ describe Admin::PodsController, type: :controller do before do - @user = FactoryGirl.create :user + @user = FactoryBot.create :user Role.add_admin(@user.person) sign_in @user, scope: :user @@ -24,7 +24,7 @@ describe Admin::PodsController, type: :controller do end it "returns the json data" do - 3.times { FactoryGirl.create(:pod) } + 3.times { FactoryBot.create(:pod) } get :index, format: :json @@ -34,7 +34,7 @@ describe Admin::PodsController, type: :controller do describe "#recheck" do before do - @pod = FactoryGirl.create(:pod).reload + @pod = FactoryBot.create(:pod).reload allow(Pod).to receive(:find) { @pod } expect(@pod).to receive(:test_connection!) end diff --git a/spec/controllers/admin/users_controller_spec.rb b/spec/controllers/admin/users_controller_spec.rb index 751d05114..23ebf9238 100644 --- a/spec/controllers/admin/users_controller_spec.rb +++ b/spec/controllers/admin/users_controller_spec.rb @@ -2,7 +2,7 @@ describe Admin::UsersController, :type => :controller do before do - @user = FactoryGirl.create :user + @user = FactoryBot.create :user Role.add_admin(@user.person) sign_in @user, scope: :user @@ -10,7 +10,7 @@ describe Admin::UsersController, :type => :controller do describe '#close_account' do it 'queues a job to disable the given account' do - other_user = FactoryGirl.create :user + other_user = FactoryBot.create :user expect(other_user).to receive(:close_account!) allow(User).to receive(:find).and_return(other_user) @@ -20,7 +20,7 @@ describe Admin::UsersController, :type => :controller do describe '#lock_account' do it 'it locks the given account' do - other_user = FactoryGirl.create :user + other_user = FactoryBot.create :user other_user.lock_access! expect(other_user.reload.access_locked?).to be_truthy end @@ -28,7 +28,7 @@ describe Admin::UsersController, :type => :controller do describe '#unlock_account' do it 'it unlocks the given account' do - other_user = FactoryGirl.create :user + other_user = FactoryBot.create :user other_user.lock_access! other_user.unlock_access! expect(other_user.reload.access_locked?).to be_falsey diff --git a/spec/controllers/admins_controller_spec.rb b/spec/controllers/admins_controller_spec.rb index 1ee4a7321..c7a9d49d2 100644 --- a/spec/controllers/admins_controller_spec.rb +++ b/spec/controllers/admins_controller_spec.rb @@ -6,7 +6,7 @@ describe AdminsController, :type => :controller do before do - @user = FactoryGirl.create :user + @user = FactoryBot.create :user sign_in @user, scope: :user end @@ -82,11 +82,11 @@ describe AdminsController, :type => :controller do end it 'searches on age < 13 (COPPA)' do - u_13 = FactoryGirl.create(:user) + u_13 = FactoryBot.create(:user) u_13.profile.birthday = 10.years.ago.to_date u_13.profile.save! - o_13 = FactoryGirl.create(:user) + o_13 = FactoryBot.create(:user) o_13.profile.birthday = 20.years.ago.to_date o_13.profile.save! diff --git a/spec/controllers/api/openid_connect/authorizations_controller_spec.rb b/spec/controllers/api/openid_connect/authorizations_controller_spec.rb index d11151a87..29856bc58 100644 --- a/spec/controllers/api/openid_connect/authorizations_controller_spec.rb +++ b/spec/controllers/api/openid_connect/authorizations_controller_spec.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true describe Api::OpenidConnect::AuthorizationsController, type: :request do - let!(:client) { FactoryGirl.create(:o_auth_application) } + let!(:client) { FactoryBot.create(:o_auth_application) } before do sign_in alice, scope: :user @@ -89,7 +89,7 @@ describe Api::OpenidConnect::AuthorizationsController, type: :request do context "when multiple redirect URLs are pre-registered" do it "should return an invalid request error" do client_with_multiple_redirects = - FactoryGirl.create(:o_auth_application, redirect_uris: %w[http://localhost:3000/ http://localhost/]) + FactoryBot.create(:o_auth_application, redirect_uris: %w[http://localhost:3000/ http://localhost/]) post api_openid_connect_authorizations_new_path, params: {client_id: client_with_multiple_redirects.client_id, response_type: "id_token", scope: "openid", nonce: SecureRandom.hex(16), state: SecureRandom.hex(16)} expect(response.body).to include("The request was malformed") @@ -184,7 +184,7 @@ describe Api::OpenidConnect::AuthorizationsController, type: :request do context "when XSS script is passed as name" do it "should escape html" do - client_with_xss = FactoryGirl.create(:o_auth_application_with_xss) + client_with_xss = FactoryBot.create(:o_auth_application_with_xss) post api_openid_connect_authorizations_new_path, params: {client_id: client_with_xss.client_id, redirect_uri: "http://localhost:3000/", response_type: "id_token", scope: "openid", nonce: SecureRandom.hex(16), state: SecureRandom.hex(16)} @@ -440,7 +440,7 @@ describe Api::OpenidConnect::AuthorizationsController, type: :request do describe "#destroy" do context "with existent authorization" do it "removes the authorization" do - auth_with_read = FactoryGirl.create(:auth_with_default_scopes, o_auth_application: client) + auth_with_read = FactoryBot.create(:auth_with_default_scopes, o_auth_application: client) delete api_openid_connect_authorization_path(auth_with_read.id) expect(Api::OpenidConnect::Authorization.find_by(id: auth_with_read.id)).to be_nil end diff --git a/spec/controllers/api/openid_connect/clients_controller_spec.rb b/spec/controllers/api/openid_connect/clients_controller_spec.rb index ce51fee21..2b6293ca6 100644 --- a/spec/controllers/api/openid_connect/clients_controller_spec.rb +++ b/spec/controllers/api/openid_connect/clients_controller_spec.rb @@ -145,7 +145,7 @@ describe Api::OpenidConnect::ClientsController, type: :controller, suppress_csrf end describe "#find" do - let!(:client) { FactoryGirl.create(:o_auth_application) } + let!(:client) { FactoryBot.create(:o_auth_application) } context "when an OIDC client already exists" do it "should return a client id" do diff --git a/spec/controllers/api/openid_connect/token_endpoint_controller_spec.rb b/spec/controllers/api/openid_connect/token_endpoint_controller_spec.rb index 9eec6d41c..d21984db1 100644 --- a/spec/controllers/api/openid_connect/token_endpoint_controller_spec.rb +++ b/spec/controllers/api/openid_connect/token_endpoint_controller_spec.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true describe Api::OpenidConnect::TokenEndpointController, type: :controller, suppress_csrf_verification: :none do - let(:auth) { FactoryGirl.create(:auth_with_default_scopes) } + let(:auth) { FactoryBot.create(:auth_with_default_scopes) } describe "#create" do it "returns 200 on success" do diff --git a/spec/controllers/api/openid_connect/user_applications_spec.rb b/spec/controllers/api/openid_connect/user_applications_spec.rb index 1c40b2c16..07f46d0f2 100644 --- a/spec/controllers/api/openid_connect/user_applications_spec.rb +++ b/spec/controllers/api/openid_connect/user_applications_spec.rb @@ -2,9 +2,9 @@ describe Api::OpenidConnect::UserApplicationsController, type: :controller do before do - @app = FactoryGirl.create(:o_auth_application_with_xss) - @user = FactoryGirl.create :user - FactoryGirl.create :auth_with_default_scopes, user: @user, o_auth_application: @app + @app = FactoryBot.create(:o_auth_application_with_xss) + @user = FactoryBot.create :user + FactoryBot.create :auth_with_default_scopes, user: @user, o_auth_application: @app sign_in @user, scope: :user end diff --git a/spec/controllers/aspects_controller_spec.rb b/spec/controllers/aspects_controller_spec.rb index a243cfaf8..897b21ac9 100644 --- a/spec/controllers/aspects_controller_spec.rb +++ b/spec/controllers/aspects_controller_spec.rb @@ -82,7 +82,7 @@ describe AspectsController, :type => :controller do end it "doesn't overwrite random attributes" do - new_user = FactoryGirl.create :user + new_user = FactoryBot.create :user params = {"name" => "Bruisers"} params[:user_id] = new_user.id put :update, params: {id: @alices_aspect_1.id, aspect: params} diff --git a/spec/controllers/comments_controller_spec.rb b/spec/controllers/comments_controller_spec.rb index a6b0a45cc..e6a043d87 100644 --- a/spec/controllers/comments_controller_spec.rb +++ b/spec/controllers/comments_controller_spec.rb @@ -45,7 +45,7 @@ describe CommentsController, :type => :controller do end it "doesn't overwrite author_id" do - new_user = FactoryGirl.create(:user) + new_user = FactoryBot.create(:user) comment_hash[:author_id] = new_user.person.id.to_s post :create, params: comment_hash expect(Comment.find_by_text(comment_hash[:text]).author_id).to eq(alice.person.id) diff --git a/spec/controllers/contacts_controller_spec.rb b/spec/controllers/contacts_controller_spec.rb index 10cdc3ab5..ae5df1092 100644 --- a/spec/controllers/contacts_controller_spec.rb +++ b/spec/controllers/contacts_controller_spec.rb @@ -34,10 +34,10 @@ describe ContactsController, :type => :controller do context "format json" do context "for the contacts search" do before do - @person1 = FactoryGirl.create(:person) + @person1 = FactoryBot.create(:person) bob.share_with(@person1, bob.aspects.first) - @person2 = FactoryGirl.create(:person) - @person3 = FactoryGirl.create(:person) + @person2 = FactoryBot.create(:person) + @person3 = FactoryBot.create(:person) bob.contacts.create(person: @person3, aspects: [bob.aspects.first], receiving: true, sharing: true) end @@ -108,7 +108,7 @@ describe ContactsController, :type => :controller do context "with an aspect id" do before do @aspect = bob.aspects.create(name: "awesome contacts") - @person = FactoryGirl.create(:person) + @person = FactoryBot.create(:person) bob.share_with(@person, @aspect) end diff --git a/spec/controllers/conversations_controller_spec.rb b/spec/controllers/conversations_controller_spec.rb index 3ea06721f..cb94de294 100644 --- a/spec/controllers/conversations_controller_spec.rb +++ b/spec/controllers/conversations_controller_spec.rb @@ -30,7 +30,7 @@ describe ConversationsController, :type => :controller do end it "assigns a json list of contacts that are sharing with the person" do - sharing_user = FactoryGirl.create(:user_with_aspect) + sharing_user = FactoryBot.create(:user_with_aspect) sharing_user.share_with(alice.person, sharing_user.aspects.first) get :new, params: {modal: true} expect(assigns(:contacts_json)) @@ -139,7 +139,7 @@ describe ConversationsController, :type => :controller do end it "sets the author to the current_user" do - params[:author] = FactoryGirl.create(:user) + params[:author] = FactoryBot.create(:user) post :create, params: params, format: :js expect(Message.first.author).to eq(alice.person) expect(Conversation.first.author).to eq(alice.person) @@ -247,9 +247,9 @@ describe ConversationsController, :type => :controller do end context "with non-mutual contact" do - let(:person1) { FactoryGirl.create(:person) } - let(:person2) { FactoryGirl.create(:person) } - let(:person3) { FactoryGirl.create(:person) } + let(:person1) { FactoryBot.create(:person) } + let(:person2) { FactoryBot.create(:person) } + let(:person3) { FactoryBot.create(:person) } let(:params) { { conversation: {subject: "secret stuff", text: "text debug"}, @@ -306,7 +306,7 @@ describe ConversationsController, :type => :controller do end it "sets the author to the current_user" do - params[:author] = FactoryGirl.create(:user) + params[:author] = FactoryBot.create(:user) post :create, params: params, format: :js expect(Message.first.author).to eq(alice.person) expect(Conversation.first.author).to eq(alice.person) @@ -414,8 +414,8 @@ describe ConversationsController, :type => :controller do end context "with non-mutual contact" do - let(:contact1) { alice.contacts.create(receiving: false, sharing: true, person: FactoryGirl.create(:person)) } - let(:contact2) { alice.contacts.create(receiving: true, sharing: false, person: FactoryGirl.create(:person)) } + let(:contact1) { alice.contacts.create(receiving: false, sharing: true, person: FactoryBot.create(:person)) } + let(:contact2) { alice.contacts.create(receiving: true, sharing: false, person: FactoryBot.create(:person)) } let(:params) { { conversation: {subject: "secret stuff", text: "text debug"}, diff --git a/spec/controllers/jasmine_fixtures/admins_spec.rb b/spec/controllers/jasmine_fixtures/admins_spec.rb index 62bfd77a2..62966e0af 100644 --- a/spec/controllers/jasmine_fixtures/admins_spec.rb +++ b/spec/controllers/jasmine_fixtures/admins_spec.rb @@ -3,7 +3,7 @@ describe AdminsController, type: :controller do describe "#dashboard" do before do - @user = FactoryGirl.create :user + @user = FactoryBot.create :user Role.add_admin(@user.person) sign_in @user, scope: :user end diff --git a/spec/controllers/jasmine_fixtures/contacts_spec.rb b/spec/controllers/jasmine_fixtures/contacts_spec.rb index f2fccfcb6..fb8736834 100644 --- a/spec/controllers/jasmine_fixtures/contacts_spec.rb +++ b/spec/controllers/jasmine_fixtures/contacts_spec.rb @@ -20,7 +20,7 @@ describe ContactsController, :type => :controller do it "generates the aspects_manage_contacts_json fixture", fixture: true do # adds one not mutual contact - bob.share_with(FactoryGirl.create(:person), @aspect) + bob.share_with(FactoryBot.create(:person), @aspect) get :index, params: {a_id: @aspect.id, page: "1"}, format: :json save_fixture(response.body, "aspects_manage_contacts_json") diff --git a/spec/controllers/jasmine_fixtures/notifications_spec.rb b/spec/controllers/jasmine_fixtures/notifications_spec.rb index 26dd262e9..e9e044131 100644 --- a/spec/controllers/jasmine_fixtures/notifications_spec.rb +++ b/spec/controllers/jasmine_fixtures/notifications_spec.rb @@ -4,10 +4,10 @@ describe NotificationsController, :type => :controller do describe '#index' do before do sign_in alice, scope: :user - @post = FactoryGirl.create(:status_message) - FactoryGirl.create(:notification, :recipient => alice, :target => @post) + @post = FactoryBot.create(:status_message) + FactoryBot.create(:notification, :recipient => alice, :target => @post) get :read_all - FactoryGirl.create(:notification, :recipient => alice, :target => @post) + FactoryBot.create(:notification, :recipient => alice, :target => @post) eve.share_with(alice.person, eve.aspects.first) end diff --git a/spec/controllers/jasmine_fixtures/streams_spec.rb b/spec/controllers/jasmine_fixtures/streams_spec.rb index 3297816d2..0eac39bf4 100644 --- a/spec/controllers/jasmine_fixtures/streams_spec.rb +++ b/spec/controllers/jasmine_fixtures/streams_spec.rb @@ -21,7 +21,7 @@ describe StreamsController, :type => :controller do Timecop.travel(time += 1.minute) posts << alice.post(:status_message, :text => "hella infos yo!", :to => alice.aspects.first.id) Timecop.travel(time += 1.minute) - posts << alice.post(:reshare, :root_guid => FactoryGirl.create(:status_message, :public => true).guid, :to => 'all') + posts << alice.post(:reshare, :root_guid => FactoryBot.create(:status_message, :public => true).guid, :to => 'all') Timecop.travel(time += 1.minute) if i == 9 posts << alice.post(:status_message, diff --git a/spec/controllers/links_controller_spec.rb b/spec/controllers/links_controller_spec.rb index 841b77cd4..f45051669 100644 --- a/spec/controllers/links_controller_spec.rb +++ b/spec/controllers/links_controller_spec.rb @@ -3,7 +3,7 @@ describe LinksController, type: :controller do describe "#resolve" do context "with post" do - let(:post) { FactoryGirl.create(:status_message) } + let(:post) { FactoryBot.create(:status_message) } let(:link_text) { "#{post.author.diaspora_handle}/post/#{post.guid}" } subject { get :resolve, params: {q: link_query} } @@ -34,7 +34,7 @@ describe LinksController, type: :controller do end context "when post is non-fetchable" do - let(:diaspora_id) { FactoryGirl.create(:person).diaspora_handle } + let(:diaspora_id) { FactoryBot.create(:person).diaspora_handle } let(:guid) { "1234567890abcdef" } let(:link_query) { "web+diaspora://#{diaspora_id}/post/#{guid}" } diff --git a/spec/controllers/messages_controller_spec.rb b/spec/controllers/messages_controller_spec.rb index 4fd9bd4f3..c89eac69e 100644 --- a/spec/controllers/messages_controller_spec.rb +++ b/spec/controllers/messages_controller_spec.rb @@ -80,7 +80,7 @@ describe MessagesController, :type => :controller do end it "doesn't overwrite author_id" do - new_user = FactoryGirl.create(:user) + new_user = FactoryBot.create(:user) @message_params[:author_id] = new_user.person.id.to_s post :create, params: @message_params diff --git a/spec/controllers/notifications_controller_spec.rb b/spec/controllers/notifications_controller_spec.rb index 19c940481..45ae4b153 100644 --- a/spec/controllers/notifications_controller_spec.rb +++ b/spec/controllers/notifications_controller_spec.rb @@ -11,21 +11,21 @@ describe NotificationsController, :type => :controller do describe '#update' do it 'marks a notification as read if it gets no other information' do - note = FactoryGirl.create(:notification) + note = FactoryBot.create(:notification) expect(Notification).to receive(:where).and_return([note]) expect(note).to receive(:set_read_state).with(true) get :update, params: {id: note.id}, format: :json end it 'marks a notification as read if it is told to' do - note = FactoryGirl.create(:notification) + note = FactoryBot.create(:notification) expect(Notification).to receive(:where).and_return([note]) expect(note).to receive(:set_read_state).with(true) get :update, params: {id: note.id, set_unread: "false"}, format: :json end it 'marks a notification as unread if it is told to' do - note = FactoryGirl.create(:notification) + note = FactoryBot.create(:notification) expect(Notification).to receive(:where).and_return([note]) expect(note).to receive(:set_read_state).with(false) get :update, params: {id: note.id, set_unread: "true"}, format: :json @@ -33,7 +33,7 @@ describe NotificationsController, :type => :controller do it "marks a notification as unread without timestamping" do note = Timecop.travel(1.hour.ago) do - FactoryGirl.create(:notification, recipient: alice, unread: false) + FactoryBot.create(:notification, recipient: alice, unread: false) end get :update, params: {id: note.id, set_unread: "true"}, format: :json @@ -47,8 +47,8 @@ describe NotificationsController, :type => :controller do it 'only lets you read your own notifications' do user2 = bob - FactoryGirl.create(:notification, :recipient => alice) - note = FactoryGirl.create(:notification, :recipient => user2) + FactoryBot.create(:notification, :recipient => alice) + note = FactoryBot.create(:notification, :recipient => user2) get :update, params: {id: note.id, set_unread: "false"}, format: :json @@ -58,8 +58,8 @@ describe NotificationsController, :type => :controller do describe '#index' do before do - @post = FactoryGirl.create(:status_message) - @notification = FactoryGirl.create(:notification, recipient: alice, target: @post) + @post = FactoryBot.create(:status_message) + @notification = FactoryBot.create(:notification, recipient: alice, target: @post) end it 'succeeds' do @@ -98,7 +98,7 @@ describe NotificationsController, :type => :controller do end it 'paginates the notifications' do - 25.times { FactoryGirl.create(:notification, :recipient => alice, :target => @post) } + 25.times { FactoryBot.create(:notification, :recipient => alice, :target => @post) } get :index expect(assigns[:notifications].count).to eq(25) get :index, params: {page: 2} @@ -106,14 +106,14 @@ describe NotificationsController, :type => :controller do end it "supports a limit per_page parameter" do - 2.times { FactoryGirl.create(:notification, :recipient => alice, :target => @post) } + 2.times { FactoryBot.create(:notification, :recipient => alice, :target => @post) } get :index, params: {per_page: 2} expect(assigns[:notifications].count).to eq(2) end describe "special case for start sharing notifications" do it "should not provide a contacts menu for standard notifications" do - FactoryGirl.create(:notification, :recipient => alice, :target => @post) + FactoryBot.create(:notification, :recipient => alice, :target => @post) get :index, params: {per_page: 5} expect(Nokogiri(response.body).css('.aspect_membership')).to be_empty end @@ -134,15 +134,15 @@ describe NotificationsController, :type => :controller do describe "filter notifications" do it "supports filtering by notification type" do - FactoryGirl.create(:notification, :recipient => alice, :type => "Notifications::StartedSharing") + FactoryBot.create(:notification, :recipient => alice, :type => "Notifications::StartedSharing") get :index, params: {type: "started_sharing"} expect(assigns[:notifications].count).to eq(1) end it "supports filtering by read/unread" do - FactoryGirl.create(:notification, :recipient => alice, :target => @post) + FactoryBot.create(:notification, :recipient => alice, :target => @post) get :read_all - FactoryGirl.create(:notification, :recipient => alice, :target => @post) + FactoryBot.create(:notification, :recipient => alice, :target => @post) get :index, params: {show: "unread"} expect(assigns[:notifications].count).to eq(1) end @@ -150,7 +150,7 @@ describe NotificationsController, :type => :controller do context "after deleting a person" do before do - user = FactoryGirl.create(:user_with_aspect) + user = FactoryBot.create(:user_with_aspect) user.share_with(alice.person, user.aspects.first) user.person.delete end @@ -168,12 +168,12 @@ describe NotificationsController, :type => :controller do end describe "#read_all" do - let(:post) { FactoryGirl.create(:status_message) } + let(:post) { FactoryBot.create(:status_message) } it "marks all notifications as read" do request.env["HTTP_REFERER"] = "I wish I were spelled right" - FactoryGirl.create(:notification, recipient: alice, target: post) - FactoryGirl.create(:notification, recipient: alice, target: post) + FactoryBot.create(:notification, recipient: alice, target: post) + FactoryBot.create(:notification, recipient: alice, target: post) expect(Notification.where(unread: true).count).to eq(2) get :read_all @@ -182,39 +182,39 @@ describe NotificationsController, :type => :controller do it "marks all notifications in the current filter as read" do request.env["HTTP_REFERER"] = "I wish I were spelled right" - FactoryGirl.create(:notification, recipient: alice, target: post) - FactoryGirl.create(:notification, recipient: alice, type: "Notifications::StartedSharing") + FactoryBot.create(:notification, recipient: alice, target: post) + FactoryBot.create(:notification, recipient: alice, type: "Notifications::StartedSharing") expect(Notification.where(unread: true).count).to eq(2) get :read_all, params: {type: "started_sharing"} expect(Notification.where(unread: true).count).to eq(1) end it "should redirect back in the html version if it has > 0 notifications" do - FactoryGirl.create(:notification, recipient: alice, type: "Notifications::StartedSharing") + FactoryBot.create(:notification, recipient: alice, type: "Notifications::StartedSharing") get :read_all, params: {type: "liked"}, format: :html expect(response).to redirect_to(notifications_path) end it "should redirect back in the mobile version if it has > 0 notifications" do - FactoryGirl.create(:notification, recipient: alice, type: "Notifications::StartedSharing") + FactoryBot.create(:notification, recipient: alice, type: "Notifications::StartedSharing") get :read_all, params: {type: "liked"}, format: :mobile expect(response).to redirect_to(notifications_path) end it "should redirect to stream in the html version if it has 0 notifications" do - FactoryGirl.create(:notification, recipient: alice, type: "Notifications::StartedSharing") + FactoryBot.create(:notification, recipient: alice, type: "Notifications::StartedSharing") get :read_all, params: {type: "started_sharing"}, format: :html expect(response).to redirect_to(stream_path) end it "should redirect back in the mobile version if it has 0 notifications" do - FactoryGirl.create(:notification, recipient: alice, type: "Notifications::StartedSharing") + FactoryBot.create(:notification, recipient: alice, type: "Notifications::StartedSharing") get :read_all, params: {type: "started_sharing"}, format: :mobile expect(response).to redirect_to(stream_path) end it "should return a dummy value in the json version" do - FactoryGirl.create(:notification, recipient: alice, target: post) + FactoryBot.create(:notification, recipient: alice, target: post) get :read_all, format: :json expect(response).not_to be_redirect end diff --git a/spec/controllers/participations_controller_spec.rb b/spec/controllers/participations_controller_spec.rb index d38e7bc69..c79e21bc8 100644 --- a/spec/controllers/participations_controller_spec.rb +++ b/spec/controllers/participations_controller_spec.rb @@ -7,7 +7,7 @@ describe ParticipationsController, :type => :controller do end describe '#create' do - let(:stranger) { FactoryGirl.create(:user) } + let(:stranger) { FactoryBot.create(:user) } shared_examples 'on a visible post' do it 'creates the participation' do @@ -57,7 +57,7 @@ describe ParticipationsController, :type => :controller do end describe '#destroy' do - let(:post) { FactoryGirl.create(:status_message) } + let(:post) { FactoryBot.create(:status_message) } context 'on a post you partecipate to' do before { alice.participate! post } diff --git a/spec/controllers/people_controller_spec.rb b/spec/controllers/people_controller_spec.rb index dd11edadf..32774abad 100644 --- a/spec/controllers/people_controller_spec.rb +++ b/spec/controllers/people_controller_spec.rb @@ -15,18 +15,18 @@ describe PeopleController, :type => :controller do describe '#index (search)' do before do - @eugene = FactoryGirl.create( + @eugene = FactoryBot.create( :person, - profile: FactoryGirl.build(:profile, first_name: "Eugene", last_name: "w") + profile: FactoryBot.build(:profile, first_name: "Eugene", last_name: "w") ) - @korth = FactoryGirl.create( + @korth = FactoryBot.create( :person, - profile: FactoryGirl.build(:profile, first_name: "Evan", last_name: "Korth") + profile: FactoryBot.build(:profile, first_name: "Evan", last_name: "Korth") ) - @closed = FactoryGirl.create( + @closed = FactoryBot.create( :person, closed_account: true, - profile: FactoryGirl.build(:profile, first_name: "Closed", last_name: "Account") + profile: FactoryBot.build(:profile, first_name: "Closed", last_name: "Account") ) end @@ -57,8 +57,8 @@ describe PeopleController, :type => :controller do describe 'via html' do context 'query is a diaspora ID' do before do - @unsearchable_eugene = FactoryGirl.create(:person, :diaspora_handle => "eugene@example.org", - :profile => FactoryGirl.build(:profile, :first_name => "Eugene", + @unsearchable_eugene = FactoryBot.create(:person, :diaspora_handle => "eugene@example.org", + :profile => FactoryBot.build(:profile, :first_name => "Eugene", :last_name => "w", :searchable => false)) end it 'finds people even if they have searchable off' do @@ -99,8 +99,8 @@ describe PeopleController, :type => :controller do end it "assigns people" do - eugene2 = FactoryGirl.create(:person, - :profile => FactoryGirl.build(:profile, :first_name => "Eugene", + eugene2 = FactoryBot.create(:person, + :profile => FactoryBot.build(:profile, :first_name => "Eugene", :last_name => "w")) get :index, params: {q: "Eug"} expect(assigns[:people].map { |x| x.id }).to match_array([@eugene.id, eugene2.id]) @@ -129,8 +129,8 @@ describe PeopleController, :type => :controller do end it "excludes people who have searchable off" do - eugene2 = FactoryGirl.create(:person, - :profile => FactoryGirl.build(:profile, :first_name => "Eugene", + eugene2 = FactoryBot.create(:person, + :profile => FactoryBot.build(:profile, :first_name => "Eugene", :last_name => "w", :searchable => false)) get :index, params: {q: "Eug"} expect(assigns[:people]).not_to match_array([eugene2]) @@ -150,7 +150,7 @@ describe PeopleController, :type => :controller do @posts = [] @users = [] 8.times do |n| - user = FactoryGirl.create(:user) + user = FactoryBot.create(:user) @users << user aspect = user.aspects.create(:name => 'people') connect_users(@user, @user.aspects.first, user, aspect) @@ -173,7 +173,7 @@ describe PeopleController, :type => :controller do describe '#show' do before do - @person = FactoryGirl.create(:user).person + @person = FactoryBot.create(:user).person @presenter = PersonPresenter.new(@person, @user) end @@ -214,7 +214,7 @@ describe PeopleController, :type => :controller do end it 'redirects home for closed account' do - @person = FactoryGirl.create(:person, :closed_account => true) + @person = FactoryBot.create(:person, :closed_account => true) get :show, params: {id: @person.to_param} expect(response).to be_redirect expect(flash[:notice]).not_to be_blank @@ -275,7 +275,7 @@ describe PeopleController, :type => :controller do end it 'forces to sign in if the person is remote' do - p = FactoryGirl.create(:person) + p = FactoryBot.create(:person) get :show, params: {id: p.to_param} expect(response).to be_redirect @@ -325,7 +325,7 @@ describe PeopleController, :type => :controller do end it 'marks a corresponding notifications as read' do - note = FactoryGirl.create(:notification, :recipient => @user, :target => @person, :unread => true) + note = FactoryBot.create(:notification, :recipient => @user, :target => @person, :unread => true) expect { get :show, params: {id: @person.to_param} @@ -417,7 +417,7 @@ describe PeopleController, :type => :controller do end it "includes reshares" do - reshare = @user.post(:reshare, :public => true, :root_guid => FactoryGirl.create(:status_message, :public => true).guid, :to => alice.aspect_ids) + reshare = @user.post(:reshare, :public => true, :root_guid => FactoryBot.create(:status_message, :public => true).guid, :to => alice.aspect_ids) get :stream, params: {person_id: @user.person.to_param}, format: :json expect(assigns[:stream].posts.map { |x| x.id }).to include(reshare.id) end @@ -455,7 +455,7 @@ describe PeopleController, :type => :controller do end it "posts include reshares" do - reshare = @user.post(:reshare, :public => true, :root_guid => FactoryGirl.create(:status_message, :public => true).guid, :to => alice.aspect_ids) + reshare = @user.post(:reshare, :public => true, :root_guid => FactoryBot.create(:status_message, :public => true).guid, :to => alice.aspect_ids) get :stream, params: {person_id: @user.person.to_param}, format: :json expect(assigns[:stream].posts.map { |x| x.id }).to include(reshare.id) end @@ -479,7 +479,7 @@ describe PeopleController, :type => :controller do end it "posts include reshares" do - reshare = @user.post(:reshare, :public => true, :root_guid => FactoryGirl.create(:status_message, :public => true).guid, :to => alice.aspect_ids) + reshare = @user.post(:reshare, :public => true, :root_guid => FactoryBot.create(:status_message, :public => true).guid, :to => alice.aspect_ids) get :stream, params: {person_id: @user.person.to_param}, format: :json expect(assigns[:stream].posts.map { |x| x.id }).to include(reshare.id) end @@ -499,7 +499,7 @@ describe PeopleController, :type => :controller do describe '#hovercard' do before do - @hover_test = FactoryGirl.create(:person) + @hover_test = FactoryBot.create(:person) @hover_test.profile.tag_string = '#test #tags' @hover_test.profile.save! end @@ -542,18 +542,18 @@ describe PeopleController, :type => :controller do describe '#refresh_search ' do before(:each)do - @eugene = FactoryGirl.create( + @eugene = FactoryBot.create( :person, - profile: FactoryGirl.build(:profile, first_name: "Eugene", last_name: "w") + profile: FactoryBot.build(:profile, first_name: "Eugene", last_name: "w") ) - @korth = FactoryGirl.create( + @korth = FactoryBot.create( :person, - profile: FactoryGirl.build(:profile, first_name: "Evan", last_name: "Korth") + profile: FactoryBot.build(:profile, first_name: "Evan", last_name: "Korth") ) - @closed = FactoryGirl.create( + @closed = FactoryBot.create( :person, closed_account: true, - profile: FactoryGirl.build(:profile, first_name: "Closed", last_name: "Account") + profile: FactoryBot.build(:profile, first_name: "Closed", last_name: "Account") ) end diff --git a/spec/controllers/photos_controller_spec.rb b/spec/controllers/photos_controller_spec.rb index b443e862d..4d76435fa 100644 --- a/spec/controllers/photos_controller_spec.rb +++ b/spec/controllers/photos_controller_spec.rb @@ -54,14 +54,14 @@ describe PhotosController, :type => :controller do end it "doesn't allow mass assignment of person" do - new_user = FactoryGirl.create(:user) + new_user = FactoryBot.create(:user) @params[:photo][:author] = new_user post :create, params: @params expect(Photo.last.author).to eq(alice.person) end it "doesn't allow mass assignment of person_id" do - new_user = FactoryGirl.create(:user) + new_user = FactoryBot.create(:user) @params[:photo][:author_id] = new_user.id post :create, params: @params expect(Photo.last.author).to eq(alice.person) @@ -79,13 +79,13 @@ describe PhotosController, :type => :controller do describe '#index' do it "succeeds without any available pictures" do - get :index, params: {person_id: FactoryGirl.create(:person).guid} + get :index, params: {person_id: FactoryBot.create(:person).guid} expect(response).to be_successful end it "succeeds on mobile devices without any available pictures" do - get :index, params: {person_id: FactoryGirl.create(:person).guid}, format: :mobile + get :index, params: {person_id: FactoryBot.create(:person).guid}, format: :mobile expect(response).to be_successful end @@ -149,7 +149,7 @@ describe PhotosController, :type => :controller do end it "forces to sign in if the person is remote" do - p = FactoryGirl.create(:person) + p = FactoryBot.create(:person) get :index, params: {person_id: p.to_param} expect(response).to be_redirect diff --git a/spec/controllers/poll_participations_controller_spec.rb b/spec/controllers/poll_participations_controller_spec.rb index 45e6fdd33..05776e257 100644 --- a/spec/controllers/poll_participations_controller_spec.rb +++ b/spec/controllers/poll_participations_controller_spec.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true describe PollParticipationsController, type: :controller do - let(:poll_post) { FactoryGirl.create(:status_message_with_poll, public: true) } + let(:poll_post) { FactoryBot.create(:status_message_with_poll, public: true) } let(:poll_answer) { poll_post.poll.poll_answers.first } before do diff --git a/spec/controllers/posts_controller_spec.rb b/spec/controllers/posts_controller_spec.rb index d9e9b4a6d..85346b845 100644 --- a/spec/controllers/posts_controller_spec.rb +++ b/spec/controllers/posts_controller_spec.rb @@ -23,7 +23,7 @@ describe PostsController, type: :controller do end it "succeeds after removing a mention when closing the mentioned user's account" do - user = FactoryGirl.create(:user, username: "user") + user = FactoryBot.create(:user, username: "user") alice.share_with(user.person, alice.aspects.first) msg = alice.post(:status_message, text: "Mention @{User ; #{user.diaspora_handle}}", public: true) @@ -41,7 +41,7 @@ describe PostsController, type: :controller do end it "succeeds on mobile with a reshare" do - reshare_id = FactoryGirl.create(:reshare, author: alice.person).id + reshare_id = FactoryBot.create(:reshare, author: alice.person).id expect_any_instance_of(PostService).to receive(:mark_user_notifications).with(reshare_id) get :show, params: {id: reshare_id}, format: :mobile diff --git a/spec/controllers/profiles_controller_spec.rb b/spec/controllers/profiles_controller_spec.rb index 00700caec..6ff54d50a 100644 --- a/spec/controllers/profiles_controller_spec.rb +++ b/spec/controllers/profiles_controller_spec.rb @@ -10,7 +10,7 @@ describe ProfilesController, :type => :controller do end describe '#show' do - let(:mock_person) { FactoryGirl.create(:user) } + let(:mock_person) { FactoryBot.create(:user) } let(:mock_presenter) { double(:as_json => {:rock_star => "Jamie Cai"})} it "returns a post Presenter" do @@ -147,7 +147,7 @@ describe ProfilesController, :type => :controller do context 'mass assignment' do before do - new_person = FactoryGirl.create(:person) + new_person = FactoryBot.create(:person) @profile_params = {:profile =>{ :person_id => new_person.id, :diaspora_handle => 'abc@a.com'}} end diff --git a/spec/controllers/reshares_controller_spec.rb b/spec/controllers/reshares_controller_spec.rb index 3a31f424f..5a3f96ded 100644 --- a/spec/controllers/reshares_controller_spec.rb +++ b/spec/controllers/reshares_controller_spec.rb @@ -7,7 +7,7 @@ describe ResharesController, :type => :controller do } before do - @post = FactoryGirl.create(:status_message, :public => true) + @post = FactoryBot.create(:status_message, :public => true) @post_guid = @post.guid end @@ -41,7 +41,7 @@ describe ResharesController, :type => :controller do context 'resharing a reshared post' do before do - FactoryGirl.create(:reshare, :root => @post, :author => bob.person) + FactoryBot.create(:reshare, :root => @post, :author => bob.person) end it 'doesn\'t allow the user to reshare the post again' do @@ -54,7 +54,7 @@ describe ResharesController, :type => :controller do context 'resharing another user\'s reshare' do before do @root = @post - @post = FactoryGirl.create(:reshare, :root => @root, :author => alice.person) + @post = FactoryBot.create(:reshare, :root => @root, :author => alice.person) end it 'reshares the absolute root' do diff --git a/spec/controllers/services_controller_spec.rb b/spec/controllers/services_controller_spec.rb index 38ee497c4..4334e5ed9 100644 --- a/spec/controllers/services_controller_spec.rb +++ b/spec/controllers/services_controller_spec.rb @@ -22,7 +22,7 @@ describe ServicesController, :type => :controller do describe '#index' do before do - FactoryGirl.create(:service, user: user) + FactoryBot.create(:service, user: user) end it "displays user's connected services" do @@ -118,7 +118,7 @@ describe ServicesController, :type => :controller do describe '#destroy' do before do - @service1 = FactoryGirl.create(:service, :user => user) + @service1 = FactoryBot.create(:service, :user => user) end it 'destroys a service selected by id' do diff --git a/spec/controllers/streams_controller_spec.rb b/spec/controllers/streams_controller_spec.rb index e628f91ae..545865ae5 100644 --- a/spec/controllers/streams_controller_spec.rb +++ b/spec/controllers/streams_controller_spec.rb @@ -32,7 +32,7 @@ describe StreamsController, :type => :controller do context "getting started" do it "add the inviter to gon" do - user = FactoryGirl.create(:user, getting_started: true, invited_by: alice) + user = FactoryBot.create(:user, getting_started: true, invited_by: alice) sign_in user get :multi diff --git a/spec/controllers/two_factor_authentications_controller_spec.rb b/spec/controllers/two_factor_authentications_controller_spec.rb index e17a6e3ca..da0a9bb86 100644 --- a/spec/controllers/two_factor_authentications_controller_spec.rb +++ b/spec/controllers/two_factor_authentications_controller_spec.rb @@ -2,7 +2,7 @@ describe TwoFactorAuthenticationsController, type: :controller do before do - @user = FactoryGirl.create :user + @user = FactoryBot.create :user sign_in @user end diff --git a/spec/controllers/users_controller_spec.rb b/spec/controllers/users_controller_spec.rb index 85c70f18d..6e9d63784 100644 --- a/spec/controllers/users_controller_spec.rb +++ b/spec/controllers/users_controller_spec.rb @@ -51,7 +51,7 @@ describe UsersController, :type => :controller do describe '#public' do context "entry xml contents" do before do - @sm = FactoryGirl.create( + @sm = FactoryBot.create( :status_message, public: true, author: @user.person, @@ -78,7 +78,7 @@ describe UsersController, :type => :controller do end it "contains the original author for reshares" do - FactoryGirl.create(:reshare, root: @sm, author: bob.person) + FactoryBot.create(:reshare, root: @sm, author: bob.person) get :public, params: {username: bob.username}, format: :atom doc = Nokogiri::XML(response.body) expect(doc.css("entry author name")[0].content).to eq(@sm.author_name) @@ -86,14 +86,14 @@ describe UsersController, :type => :controller do end it 'includes reshares in the atom feed' do - reshare = FactoryGirl.create(:reshare, :author => @user.person) + reshare = FactoryBot.create(:reshare, :author => @user.person) get :public, params: {username: @user.username}, format: :atom expect(response.body).to include reshare.root.text end it 'do not show reshares in atom feed if origin post is deleted' do - post = FactoryGirl.create(:status_message, :public => true); - reshare = FactoryGirl.create(:reshare, :root => post, :author => @user.person) + post = FactoryBot.create(:status_message, :public => true); + reshare = FactoryBot.create(:reshare, :root => post, :author => @user.person) post.delete get :public, params: {username: @user.username}, format: :atom expect(response.code).to eq('200') diff --git a/spec/factories.rb b/spec/factories.rb index 42f1a04c3..3ea0fdf87 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -14,35 +14,35 @@ end require "diaspora_federation/test/factories" -FactoryGirl.define do +FactoryBot.define do factory :profile do sequence(:first_name) { |n| "Robert#{n}#{r_str}" } sequence(:last_name) { |n| "Grimm#{n}#{r_str}" } - bio "I am a cat lover and I love to run" - gender "robot" - location "Earth" - birthday Date.today - tag_string "#one #two" + bio { "I am a cat lover and I love to run" } + gender { "robot" } + location { "Earth" } + birthday { Date.today } + tag_string { "#one #two" } association :person end factory :profile_with_image_url, :parent => :profile do - image_url "http://example.com/image.jpg" - image_url_medium "http://example.com/image_mid.jpg" - image_url_small "http://example.com/image_small.jpg" + image_url { "http://example.com/image.jpg" } + image_url_medium { "http://example.com/image_mid.jpg" } + image_url_small { "http://example.com/image_small.jpg" } end factory(:person, aliases: %i(author)) do transient do - first_name nil + first_name { nil } end sequence(:diaspora_handle) {|n| "bob-person-#{n}#{r_str}@example.net" } pod { Pod.find_or_create_by(url: "http://example.net") } - serialized_public_key OpenSSL::PKey::RSA.generate(1024).public_key.export + serialized_public_key { OpenSSL::PKey::RSA.generate(1024).public_key.export } after(:build) do |person, evaluator| unless person.profile.first_name.present? - person.profile = FactoryGirl.build(:profile, person: person) + person.profile = FactoryBot.build(:profile, person: person) person.profile.first_name = evaluator.first_name if evaluator.first_name end end @@ -66,17 +66,17 @@ FactoryGirl.define do end factory :user do - getting_started false + getting_started { false } sequence(:username) { |n| "bob#{n}#{r_str}" } sequence(:email) { |n| "bob#{n}#{r_str}@pivotallabs.com" } - password "bluepin7" + password { "bluepin7" } password_confirmation { |u| u.password } - serialized_private_key OpenSSL::PKey::RSA.generate(1024).export + serialized_private_key { OpenSSL::PKey::RSA.generate(1024).export } transient do - profile nil + profile { nil } end after(:build) do |u, e| - u.person = FactoryGirl.build(:person, + u.person = FactoryBot.build(:person, pod: nil, serialized_public_key: u.encryption_key.public_key.export, diaspora_handle: "#{u.username}#{User.diaspora_id_host}") @@ -90,11 +90,11 @@ FactoryGirl.define do factory :user_with_aspect, parent: :user do transient do - friends [] + friends { [] } end after(:create) do |user, evaluator| - FactoryGirl.create(:aspect, user: user) + FactoryBot.create(:aspect, user: user) evaluator.friends.each do |friend| connect_users_with_aspects(user, friend) end @@ -102,7 +102,7 @@ FactoryGirl.define do end factory :aspect do - name "generic" + name { "generic" } user end @@ -112,20 +112,20 @@ FactoryGirl.define do factory(:status_message_with_poll) do after(:build) do |sm| - FactoryGirl.create(:poll, status_message: sm) + FactoryBot.create(:poll, status_message: sm) end end factory(:status_message_with_location) do after(:build) do |sm| - FactoryGirl.create(:location, status_message: sm) + FactoryBot.create(:location, status_message: sm) end end factory(:status_message_with_photo) do sequence(:text) {|n| "There are #{n} ninjas in this photo." } after(:build) do |sm| - FactoryGirl.create( + FactoryBot.create( :photo, author: sm.author, status_message: sm, @@ -136,8 +136,8 @@ FactoryGirl.define do end factory(:status_message_in_aspect) do - public false - author { FactoryGirl.create(:user_with_aspect).person } + public { false } + author { FactoryBot.create(:user_with_aspect).person } after(:build) do |sm| sm.aspects << sm.author.owner.aspects.first end @@ -145,7 +145,7 @@ FactoryGirl.define do factory(:status_message_with_participations) do transient do - participants [] + participants { [] } end after(:build) do |sm, ev| ev.participants.each do |participant| @@ -176,8 +176,8 @@ FactoryGirl.define do sequence(:question) {|n| "What do you think about #{n} ninjas?" } association :status_message after(:build) do |p| - p.poll_answers << FactoryGirl.build(:poll_answer, poll: p) - p.poll_answers << FactoryGirl.build(:poll_answer, poll: p) + p.poll_answers << FactoryBot.build(:poll_answer, poll: p) + p.poll_answers << FactoryBot.build(:poll_answer, poll: p) end end @@ -195,8 +195,8 @@ FactoryGirl.define do factory(:photo) do sequence(:random_string) {|n| SecureRandom.hex(10) } association :author, :factory => :person - height 42 - width 23 + height { 42 } + width { 23 } after(:build) do |p| p.unprocessed_image.store! File.open(File.join(File.dirname(__FILE__), 'fixtures', 'button.png')) p.update_remote_path @@ -204,11 +204,11 @@ FactoryGirl.define do end factory(:remote_photo, :parent => :photo) do - remote_photo_path 'https://photo.com/images/' - remote_photo_name 'kittehs.jpg' + remote_photo_path { 'https://photo.com/images/' } + remote_photo_name { 'kittehs.jpg' } association :author,:factory => :person - processed_image nil - unprocessed_image nil + processed_image { nil } + unprocessed_image { nil } end factory :reshare do @@ -217,8 +217,8 @@ FactoryGirl.define do end factory :invitation do - service "email" - identifier "bob.smith@smith.com" + service { "email" } + identifier { "bob.smith@smith.com" } association :sender, :factory => :user_with_aspect after(:build) do |i| i.aspect = i.sender.aspects.first @@ -228,12 +228,12 @@ FactoryGirl.define do factory :invitation_code do sequence(:token){|n| "sdfsdsf#{n}"} association :user - count 0 + count { 0 } end factory :service do |service| - nickname "sirrobertking" - type "Services::Twitter" + nickname { "sirrobertking" } + type { "Services::Twitter" } sequence(:uid) { |token| "00000#{token}" } sequence(:access_token) { |token| "12345#{token}" } @@ -244,7 +244,7 @@ FactoryGirl.define do factory :pod do sequence(:host) {|n| "pod#{n}.example#{r_str}.com" } - ssl true + ssl { true } end factory(:comment) do @@ -257,8 +257,8 @@ FactoryGirl.define do association(:parent, factory: :status_message) after(:build) do |comment| - order = SignatureOrder.first || FactoryGirl.create(:signature_order) - comment.signature = FactoryGirl.build(:comment_signature, comment: comment, signature_order: order) + order = SignatureOrder.first || FactoryBot.create(:signature_order) + comment.signature = FactoryBot.build(:comment_signature, comment: comment, signature_order: order) end end @@ -272,26 +272,26 @@ FactoryGirl.define do association :target, :factory => :comment after(:build) do |note| - note.actors << FactoryGirl.build(:person) + note.actors << FactoryBot.build(:person) end end factory(:notification_mentioned_in_comment, class: Notification) do association :recipient, factory: :user - type "Notifications::MentionedInComment" + type { "Notifications::MentionedInComment" } after(:build) do |note| - note.actors << FactoryGirl.build(:person) - note.target = FactoryGirl.create :mention_in_comment, person: note.recipient.person + note.actors << FactoryBot.build(:person) + note.target = FactoryBot.create :mention_in_comment, person: note.recipient.person end end factory(:tag, :class => ActsAsTaggableOn::Tag) do - name "partytimeexcellent" + name { "partytimeexcellent" } end factory(:o_embed_cache) do - url "http://youtube.com/kittens" + url { "http://youtube.com/kittens" } data { { "data" => "foo", @@ -301,12 +301,12 @@ FactoryGirl.define do end factory(:open_graph_cache) do - url "http://example.com/articles/123" - image "http://example.com/images/123.jpg" - title "Some article" - ob_type "article" - description "This is the article lead" - video_url "http://example.com/videos/123.html" + url { "http://example.com/articles/123" } + image { "http://example.com/images/123.jpg" } + title { "Some article" } + ob_type { "article" } + description { "This is the article lead" } + video_url { "http://example.com/videos/123.html" } end factory(:tag_following) do @@ -340,7 +340,7 @@ FactoryGirl.define do factory(:conversation_with_message, parent: :conversation) do after(:create) do |c| - msg = FactoryGirl.build(:message, author: c.author) + msg = FactoryBot.build(:message, author: c.author) msg.conversation_id = c.id msg.save end @@ -354,34 +354,34 @@ FactoryGirl.define do end factory(:signature_order) do - order "guid parent_guid text author" + order { "guid parent_guid text author" } end factory(:comment_signature) do - author_signature "some signature" + author_signature { "some signature" } association :signature_order, order: "guid parent_guid text author new_property" additional_data { {"new_property" => "some text"} } end factory(:like_signature) do - author_signature "some signature" + author_signature { "some signature" } association :signature_order, order: "positive guid parent_type parent_guid author new_property" additional_data { {"new_property" => "some text"} } end factory :role do association :person - name "moderator" + name { "moderator" } end factory(:poll_participation_signature) do - author_signature "some signature" + author_signature { "some signature" } association :signature_order, order: "guid parent_guid author poll_answer_guid new_property" additional_data { {"new_property" => "some text"} } end factory(:note, :parent => :status_message) do - text SecureRandom.hex(1000) + text { SecureRandom.hex(1000) } end factory(:status, parent: :status_message) @@ -394,28 +394,28 @@ FactoryGirl.define do factory :report do user association :item, factory: :status_message - text "offensive content" + text { "offensive content" } end factory :o_auth_application, class: Api::OpenidConnect::OAuthApplication do client_name { "Diaspora Test Client #{r_str}" } - redirect_uris %w(http://localhost:3000/) + redirect_uris { %w(http://localhost:3000/) } end factory :o_auth_application_with_ppid, parent: :o_auth_application do - ppid true - sector_identifier_uri "https://example.com/uri" + ppid { true } + sector_identifier_uri { "https://example.com/uri" } end factory :o_auth_application_with_xss, class: Api::OpenidConnect::OAuthApplication do - client_name "" - redirect_uris %w(http://localhost:3000/) + client_name { "" } + redirect_uris { %w(http://localhost:3000/) } end factory :auth_with_default_scopes, class: Api::OpenidConnect::Authorization do o_auth_application user - scopes %w[openid public:read] + scopes { %w[openid public:read] } after(:build) {|m| m.redirect_uri = m.o_auth_application.redirect_uris[0] } @@ -424,7 +424,7 @@ FactoryGirl.define do factory :auth_with_profile_and_ppid, class: Api::OpenidConnect::Authorization do association :o_auth_application, factory: :o_auth_application_with_ppid user - scopes %w[openid sub profile picture nickname name] + scopes { %w[openid sub profile picture nickname name] } after(:build) {|m| m.redirect_uri = m.o_auth_application.redirect_uris[0] } @@ -433,7 +433,7 @@ FactoryGirl.define do factory :auth_with_all_scopes, class: Api::OpenidConnect::Authorization do o_auth_application association :user, factory: :user_with_aspect - scopes Api::OpenidConnect::Authorization::SCOPES + scopes { Api::OpenidConnect::Authorization::SCOPES } after(:build) {|m| m.redirect_uri = m.o_auth_application.redirect_uris[0] } @@ -442,9 +442,9 @@ FactoryGirl.define do factory :auth_with_all_scopes_not_private, class: Api::OpenidConnect::Authorization do o_auth_application association :user, factory: :user_with_aspect - scopes %w[openid sub name nickname profile picture gender birthdate locale updated_at contacts:read contacts:modify + scopes { %w[openid sub name nickname profile picture gender birthdate locale updated_at contacts:read contacts:modify conversations email interactions notifications public:read public:modify profile profile:modify tags:read - tags:modify] + tags:modify] } after(:build) {|m| m.redirect_uri = m.o_auth_application.redirect_uris[0] } @@ -453,8 +453,8 @@ FactoryGirl.define do factory :auth_with_read_scopes, class: Api::OpenidConnect::Authorization do o_auth_application association :user, factory: :user_with_aspect - scopes %w[openid sub name nickname profile picture contacts:read conversations - email interactions notifications private:read public:read profile tags:read] + scopes { %w[openid sub name nickname profile picture contacts:read conversations + email interactions notifications private:read public:read profile tags:read] } after(:build) {|m| m.redirect_uri = m.o_auth_application.redirect_uris[0] } @@ -463,8 +463,8 @@ FactoryGirl.define do factory :auth_with_read_scopes_not_private, class: Api::OpenidConnect::Authorization do o_auth_application association :user, factory: :user_with_aspect - scopes %w[openid sub name nickname profile picture gender contacts:read conversations - email interactions notifications public:read profile tags:read] + scopes { %w[openid sub name nickname profile picture gender contacts:read conversations + email interactions notifications public:read profile tags:read] } after(:build) {|m| m.redirect_uri = m.o_auth_application.redirect_uris[0] } @@ -475,27 +475,27 @@ FactoryGirl.define do factory(:federation_person_from_webfinger, class: DiasporaFederation::Entities::Person) do sequence(:guid) { UUID.generate :compact } sequence(:diaspora_id) {|n| "bob-person-#{n}#{r_str}@example.net" } - url "https://example.net/" - exported_key OpenSSL::PKey::RSA.generate(1024).public_key.export + url { "https://example.net/" } + exported_key { OpenSSL::PKey::RSA.generate(1024).public_key.export } profile { DiasporaFederation::Entities::Profile.new( - FactoryGirl.attributes_for(:federation_profile_from_hcard, diaspora_id: diaspora_id)) + FactoryBot.attributes_for(:federation_profile_from_hcard, diaspora_id: diaspora_id)) } end factory(:federation_profile_from_hcard, class: DiasporaFederation::Entities::Profile) do sequence(:diaspora_id) {|n| "bob-person-#{n}#{r_str}@example.net" } sequence(:first_name) {|n| "My Name#{n}#{r_str}" } - last_name nil - image_url "/assets/user/default.png" - image_url_medium "/assets/user/default.png" - image_url_small "/assets/user/default.png" - searchable true + last_name { nil } + image_url { "/assets/user/default.png" } + image_url_medium { "/assets/user/default.png" } + image_url_small { "/assets/user/default.png" } + searchable { true } end factory :federation_profile_from_hcard_with_image_url, parent: :federation_profile_from_hcard do - image_url "http://example.com/image.jpg" - image_url_medium "http://example.com/image_mid.jpg" - image_url_small "http://example.com/image_small.jpg" + image_url { "http://example.com/image.jpg" } + image_url_medium { "http://example.com/image_mid.jpg" } + image_url_small { "http://example.com/image_small.jpg" } end end diff --git a/spec/federation_callbacks_spec.rb b/spec/federation_callbacks_spec.rb index 47601bde3..923a425d9 100644 --- a/spec/federation_callbacks_spec.rb +++ b/spec/federation_callbacks_spec.rb @@ -30,13 +30,13 @@ describe "diaspora federation callbacks" do end it "returns nil for a remote person" do - person = FactoryGirl.create(:person) + person = FactoryBot.create(:person) wf = DiasporaFederation.callbacks.trigger(:fetch_person_for_webfinger, person.diaspora_handle) expect(wf).to be_nil end it "returns nil for a closed account" do - user = FactoryGirl.create(:user) + user = FactoryBot.create(:user) user.person.lock_access! wf = DiasporaFederation.callbacks.trigger(:fetch_person_for_webfinger, user.diaspora_handle) expect(wf).to be_nil @@ -61,7 +61,7 @@ describe "diaspora federation callbacks" do end it "trims the full_name" do - user = FactoryGirl.create(:user) + user = FactoryBot.create(:user) user.person.profile.last_name = nil user.person.profile.save @@ -75,13 +75,13 @@ describe "diaspora federation callbacks" do end it "returns nil for a remote person" do - person = FactoryGirl.create(:person) + person = FactoryBot.create(:person) hcard = DiasporaFederation.callbacks.trigger(:fetch_person_for_hcard, person.guid) expect(hcard).to be_nil end it "returns nil for a closed account" do - user = FactoryGirl.create(:user) + user = FactoryBot.create(:user) user.person.lock_access! hcard = DiasporaFederation.callbacks.trigger(:fetch_person_for_hcard, user.guid) expect(hcard).to be_nil @@ -91,7 +91,7 @@ describe "diaspora federation callbacks" do describe ":save_person_after_webfinger" do context "new person" do it "creates a new person" do - person = DiasporaFederation::Entities::Person.new(FactoryGirl.attributes_for(:federation_person_from_webfinger)) + person = DiasporaFederation::Entities::Person.new(FactoryBot.attributes_for(:federation_person_from_webfinger)) DiasporaFederation.callbacks.trigger(:save_person_after_webfinger, person) @@ -112,10 +112,10 @@ describe "diaspora federation callbacks" do it "creates a new person with images" do person = DiasporaFederation::Entities::Person.new( - FactoryGirl.attributes_for( + FactoryBot.attributes_for( :federation_person_from_webfinger, profile: DiasporaFederation::Entities::Profile.new( - FactoryGirl.attributes_for(:federation_profile_from_hcard_with_image_url) + FactoryBot.attributes_for(:federation_profile_from_hcard_with_image_url) ) ) ) @@ -138,7 +138,7 @@ describe "diaspora federation callbacks" do end it "raises an error if a person with the same GUID already exists" do - person_data = FactoryGirl.attributes_for(:federation_person_from_webfinger).merge(guid: alice.guid) + person_data = FactoryBot.attributes_for(:federation_person_from_webfinger).merge(guid: alice.guid) person = DiasporaFederation::Entities::Person.new(person_data) expect { @@ -148,10 +148,10 @@ describe "diaspora federation callbacks" do end context "update profile" do - let(:existing_person_entity) { FactoryGirl.create(:person) } + let(:existing_person_entity) { FactoryBot.create(:person) } let(:person) { DiasporaFederation::Entities::Person.new( - FactoryGirl.attributes_for(:federation_person_from_webfinger, + FactoryBot.attributes_for(:federation_person_from_webfinger, diaspora_id: existing_person_entity.diaspora_handle) ) } @@ -192,8 +192,8 @@ describe "diaspora federation callbacks" do end end - let(:local_person) { FactoryGirl.create(:user).person } - let(:remote_person) { FactoryGirl.create(:person) } + let(:local_person) { FactoryBot.create(:user).person } + let(:remote_person) { FactoryBot.create(:person) } describe ":fetch_private_key" do it "returns a private key for a local user" do @@ -223,7 +223,7 @@ describe "diaspora federation callbacks" do end it "fetches an unknown user" do - person = FactoryGirl.build(:person) + person = FactoryBot.build(:person) expect(Person).to receive(:find_or_fetch_by_identifier).with(person.diaspora_handle).and_return(person) key = DiasporaFederation.callbacks.trigger(:fetch_public_key, person.diaspora_handle) @@ -244,7 +244,7 @@ describe "diaspora federation callbacks" do describe ":fetch_related_entity" do it "returns related entity for an existing local post" do - post = FactoryGirl.create(:status_message, author: local_person) + post = FactoryBot.create(:status_message, author: local_person) entity = DiasporaFederation.callbacks.trigger(:fetch_related_entity, "Post", post.guid) expect(entity.author).to eq(post.diaspora_handle) expect(entity.local).to be_truthy @@ -253,7 +253,7 @@ describe "diaspora federation callbacks" do end it "returns related entity for an existing remote post" do - post = FactoryGirl.create(:status_message, author: remote_person) + post = FactoryBot.create(:status_message, author: remote_person) entity = DiasporaFederation.callbacks.trigger(:fetch_related_entity, "Post", post.guid) expect(entity.author).to eq(post.diaspora_handle) expect(entity.local).to be_falsey @@ -262,7 +262,7 @@ describe "diaspora federation callbacks" do end it "returns related entity for an existing public post" do - post = FactoryGirl.create(:status_message, author: local_person, public: true) + post = FactoryBot.create(:status_message, author: local_person, public: true) entity = DiasporaFederation.callbacks.trigger(:fetch_related_entity, "Post", post.guid) expect(entity.author).to eq(post.diaspora_handle) expect(entity.local).to be_truthy @@ -271,8 +271,8 @@ describe "diaspora federation callbacks" do end it "returns related entity for an existing comment" do - post = FactoryGirl.create(:status_message, author: local_person, public: true) - comment = FactoryGirl.create(:comment, author: remote_person, parent: post) + post = FactoryBot.create(:status_message, author: local_person, public: true) + comment = FactoryBot.create(:comment, author: remote_person, parent: post) entity = DiasporaFederation.callbacks.trigger(:fetch_related_entity, "Comment", comment.guid) expect(entity.author).to eq(comment.diaspora_handle) expect(entity.local).to be_falsey @@ -284,7 +284,7 @@ describe "diaspora federation callbacks" do end it "returns related entity for an existing conversation" do - conversation = FactoryGirl.create(:conversation, author: local_person) + conversation = FactoryBot.create(:conversation, author: local_person) entity = DiasporaFederation.callbacks.trigger(:fetch_related_entity, "Conversation", conversation.guid) expect(entity.author).to eq(local_person.diaspora_handle) expect(entity.local).to be_truthy @@ -331,7 +331,7 @@ describe "diaspora federation callbacks" do end it "returns false if the no user is found" do - person = FactoryGirl.create(:person) + person = FactoryBot.create(:person) result = DiasporaFederation.callbacks.trigger(:queue_private_receive, person.guid, data, true) expect(result).to be_falsey end @@ -363,7 +363,7 @@ describe "diaspora federation callbacks" do it "receives a entity" do received = Fabricate(:status_message_entity, author: remote_person.diaspora_handle) - persisted = FactoryGirl.create(:status_message) + persisted = FactoryBot.create(:status_message) expect(Diaspora::Federation::Receive).to receive(:perform).with(received).and_return(persisted) expect(Workers::ReceiveLocal).to receive(:perform_async).with(persisted.class.to_s, persisted.id, []) @@ -373,7 +373,7 @@ describe "diaspora federation callbacks" do it "calls schedule_check_if_needed on the senders pod" do received = Fabricate(:status_message_entity, author: remote_person.diaspora_handle) - persisted = FactoryGirl.create(:status_message) + persisted = FactoryBot.create(:status_message) expect(Person).to receive(:by_account_identifier).with(received.author).and_return(remote_person) expect(remote_person.pod).to receive(:schedule_check_if_needed) @@ -385,7 +385,7 @@ describe "diaspora federation callbacks" do it "receives a entity for a recipient" do received = Fabricate(:status_message_entity, author: remote_person.diaspora_handle) - persisted = FactoryGirl.create(:status_message) + persisted = FactoryBot.create(:status_message) expect(Diaspora::Federation::Receive).to receive(:perform).with(received).and_return(persisted) expect(Workers::ReceiveLocal).to receive(:perform_async).with(persisted.class.to_s, persisted.id, [42]) @@ -405,7 +405,7 @@ describe "diaspora federation callbacks" do describe ":fetch_public_entity" do it "fetches a Post" do - post = FactoryGirl.create(:status_message, author: alice.person, public: true) + post = FactoryBot.create(:status_message, author: alice.person, public: true) entity = DiasporaFederation.callbacks.trigger(:fetch_public_entity, "Post", post.guid) expect(entity.guid).to eq(post.guid) @@ -414,7 +414,7 @@ describe "diaspora federation callbacks" do end it "fetches a StatusMessage" do - post = FactoryGirl.create(:status_message, author: alice.person, public: true) + post = FactoryBot.create(:status_message, author: alice.person, public: true) entity = DiasporaFederation.callbacks.trigger(:fetch_public_entity, "StatusMessage", post.guid) expect(entity.guid).to eq(post.guid) @@ -423,7 +423,7 @@ describe "diaspora federation callbacks" do end it "fetches a Reshare" do - post = FactoryGirl.create(:reshare, author: alice.person, public: true) + post = FactoryBot.create(:reshare, author: alice.person, public: true) entity = DiasporaFederation.callbacks.trigger(:fetch_public_entity, "Reshare", post.guid) expect(entity.guid).to eq(post.guid) @@ -431,8 +431,8 @@ describe "diaspora federation callbacks" do end it "fetches a StatusMessage by a Poll guid" do - post = FactoryGirl.create(:status_message, author: alice.person, public: true) - poll = FactoryGirl.create(:poll, status_message: post) + post = FactoryBot.create(:status_message, author: alice.person, public: true) + poll = FactoryBot.create(:poll, status_message: post) entity = DiasporaFederation.callbacks.trigger(:fetch_public_entity, "Poll", poll.guid) expect(entity.guid).to eq(post.guid) @@ -443,15 +443,15 @@ describe "diaspora federation callbacks" do end it "doesn't fetch a private StatusMessage by a Poll guid" do - post = FactoryGirl.create(:status_message, author: alice.person, public: false) - poll = FactoryGirl.create(:poll, status_message: post) + post = FactoryBot.create(:status_message, author: alice.person, public: false) + poll = FactoryBot.create(:poll, status_message: post) expect( DiasporaFederation.callbacks.trigger(:fetch_public_entity, "Poll", poll.guid) ).to be_nil end it "does not fetch a private post" do - post = FactoryGirl.create(:status_message, author: alice.person, public: false) + post = FactoryBot.create(:status_message, author: alice.person, public: false) expect( DiasporaFederation.callbacks.trigger(:fetch_public_entity, "StatusMessage", post.guid) @@ -467,8 +467,8 @@ describe "diaspora federation callbacks" do describe ":fetch_person_url_to" do it "returns the url with with the pod of the person" do - pod = FactoryGirl.create(:pod) - person = FactoryGirl.create(:person, pod: pod) + pod = FactoryBot.create(:pod) + person = FactoryBot.create(:person, pod: pod) expect( DiasporaFederation.callbacks.trigger(:fetch_person_url_to, person.diaspora_handle, "/path/on/pod") @@ -476,8 +476,8 @@ describe "diaspora federation callbacks" do end it "fetches an unknown user" do - pod = FactoryGirl.build(:pod) - person = FactoryGirl.build(:person, pod: pod) + pod = FactoryBot.build(:pod) + person = FactoryBot.build(:person, pod: pod) expect(Person).to receive(:find_or_fetch_by_identifier).with(person.diaspora_handle).and_return(person) expect( @@ -497,11 +497,11 @@ describe "diaspora federation callbacks" do end describe ":update_pod" do - let(:pod) { FactoryGirl.create(:pod) } + let(:pod) { FactoryBot.create(:pod) } let(:pod_url) { pod.url_to("/") } it "sets the correct error for curl-errors" do - pod = FactoryGirl.create(:pod) + pod = FactoryBot.create(:pod) DiasporaFederation.callbacks.trigger(:update_pod, pod.url_to("/"), :ssl_cacert) @@ -511,7 +511,7 @@ describe "diaspora federation callbacks" do end it "sets :no_errors to a pod that was down but up now and return code 202" do - pod = FactoryGirl.create(:pod, status: :unknown_error) + pod = FactoryBot.create(:pod, status: :unknown_error) DiasporaFederation.callbacks.trigger(:update_pod, pod.url_to("/"), 202) @@ -520,7 +520,7 @@ describe "diaspora federation callbacks" do end it "does not change a pod that has status :version_failed and was successful" do - pod = FactoryGirl.create(:pod, status: :version_failed) + pod = FactoryBot.create(:pod, status: :version_failed) DiasporaFederation.callbacks.trigger(:update_pod, pod.url_to("/"), 202) @@ -529,7 +529,7 @@ describe "diaspora federation callbacks" do end it "sets :http_failed if it has an unsuccessful http status code" do - pod = FactoryGirl.create(:pod) + pod = FactoryBot.create(:pod) DiasporaFederation.callbacks.trigger(:update_pod, pod.url_to("/"), 404) diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb index feb94673c..ddadb5cd5 100644 --- a/spec/helpers/application_helper_spec.rb +++ b/spec/helpers/application_helper_spec.rb @@ -7,7 +7,7 @@ describe ApplicationHelper, :type => :helper do before do @user = alice - @person = FactoryGirl.create(:person) + @person = FactoryBot.create(:person) end describe "#all_services_connected?" do @@ -25,7 +25,7 @@ describe ApplicationHelper, :type => :helper do end it 'returns true if all networks are connected' do - 3.times { |t| @current_user.services << FactoryGirl.build(:service) } + 3.times { |t| @current_user.services << FactoryBot.build(:service) } expect(all_services_connected?).to be true end @@ -48,7 +48,7 @@ describe ApplicationHelper, :type => :helper do end it "returns false if the service is already connected" do - @current_user.services << FactoryGirl.build(:service, provider: "service") + @current_user.services << FactoryBot.build(:service, provider: "service") expect(AppConfig).to receive(:show_service?).with("service", alice).and_return(true) expect(service_unconnected?("service")).to be false end diff --git a/spec/helpers/conversations_helper_spec.rb b/spec/helpers/conversations_helper_spec.rb index a1613bbaa..b5954e0e5 100644 --- a/spec/helpers/conversations_helper_spec.rb +++ b/spec/helpers/conversations_helper_spec.rb @@ -2,7 +2,7 @@ describe ConversationsHelper, :type => :helper do before do - @conversation = FactoryGirl.create(:conversation) + @conversation = FactoryBot.create(:conversation) end describe '#conversation_class' do diff --git a/spec/helpers/gon_helper_spec.rb b/spec/helpers/gon_helper_spec.rb index 5b21b1d44..a4def503f 100644 --- a/spec/helpers/gon_helper_spec.rb +++ b/spec/helpers/gon_helper_spec.rb @@ -4,9 +4,9 @@ describe GonHelper, type: :helper do include_context :gon describe "#gon_load_contact" do - let(:contact) { FactoryGirl.build(:contact) } + let(:contact) { FactoryBot.build(:contact) } let(:current_user) { contact.user } - let(:another_contact) { FactoryGirl.build(:contact, user: current_user) } + let(:another_contact) { FactoryBot.build(:contact, user: current_user) } before do RequestStore.store[:gon] = Gon::Request.new(controller.request.env) diff --git a/spec/helpers/notifications_helper_spec.rb b/spec/helpers/notifications_helper_spec.rb index dea069ef6..9357e3200 100644 --- a/spec/helpers/notifications_helper_spec.rb +++ b/spec/helpers/notifications_helper_spec.rb @@ -4,12 +4,12 @@ describe NotificationsHelper, type: :helper do include ApplicationHelper before do - @user = FactoryGirl.create(:user) - @person = FactoryGirl.create(:person) - @post = FactoryGirl.create(:status_message, author: @user.person) - @person2 = FactoryGirl.create(:person) - Notifications::Liked.notify(FactoryGirl.create(:like, author: @person, target: @post), []) - Notifications::Liked.notify(FactoryGirl.create(:like, author: @person2, target: @post), []) + @user = FactoryBot.create(:user) + @person = FactoryBot.create(:person) + @post = FactoryBot.create(:status_message, author: @user.person) + @person2 = FactoryBot.create(:person) + Notifications::Liked.notify(FactoryBot.create(:like, author: @person, target: @post), []) + Notifications::Liked.notify(FactoryBot.create(:like, author: @person2, target: @post), []) @notification = Notifications::Liked.find_by(target: @post, recipient: @user) end @@ -20,19 +20,19 @@ describe NotificationsHelper, type: :helper do let(:output){ strip_tags(notification_people_link(@note)) } before do - @max = FactoryGirl.create(:person) + @max = FactoryBot.create(:person) @max.profile.first_name = 'max' @max.profile.last_name = 'salzberg' - @sarah = FactoryGirl.create(:person) + @sarah = FactoryBot.create(:person) @sarah.profile.first_name = 'sarah' @sarah.profile.last_name = 'mei' - @daniel = FactoryGirl.create(:person) + @daniel = FactoryBot.create(:person) @daniel.profile.first_name = 'daniel' @daniel.profile.last_name = 'grippi' - @ilya = FactoryGirl.create(:person) + @ilya = FactoryBot.create(:person) @ilya.profile.first_name = 'ilya' @ilya.profile.last_name = 'zhit' @note = double() @@ -94,7 +94,7 @@ describe NotificationsHelper, type: :helper do end let(:status_message) { - FactoryGirl.create(:status_message_in_aspect, author: alice.person, text: text_mentioning(bob)) + FactoryBot.create(:status_message_in_aspect, author: alice.person, text: text_mentioning(bob)) } describe "when mentioned in status message" do @@ -111,7 +111,7 @@ describe NotificationsHelper, type: :helper do describe "when mentioned in comment" do it "should include correct wording, post link and comment link" do - comment = FactoryGirl.create(:comment, author: bob.person, text: text_mentioning(alice), post: status_message) + comment = FactoryBot.create(:comment, author: bob.person, text: text_mentioning(alice), post: status_message) Notifications::MentionedInComment.notify(comment, [alice.id]) notification = Notifications::MentionedInComment.last expect(notification).not_to be_nil diff --git a/spec/helpers/notifier_helper_spec.rb b/spec/helpers/notifier_helper_spec.rb index 946753aa8..c4d5a4c6e 100644 --- a/spec/helpers/notifier_helper_spec.rb +++ b/spec/helpers/notifier_helper_spec.rb @@ -8,7 +8,7 @@ describe NotifierHelper, :type => :helper do describe '#post_message' do before do # post for markdown test - @markdown_post = FactoryGirl.create(:status_message, + @markdown_post = FactoryBot.create(:status_message, text: "[link](http://diasporafoundation.org) **bold text** *other text*", public: true) @striped_markdown_post = "link (http://diasporafoundation.org) bold text other text" end @@ -18,14 +18,14 @@ describe NotifierHelper, :type => :helper do end it "falls back to the title if the post has no text" do - photo = FactoryGirl.build(:photo, public: true) - photo_post = FactoryGirl.build(:status_message, author: photo.author, text: "", photos: [photo], public: true) + photo = FactoryBot.build(:photo, public: true) + photo_post = FactoryBot.build(:status_message, author: photo.author, text: "", photos: [photo], public: true) expect(helper.post_message(photo_post)) .to eq(I18n.t("posts.show.photos_by", count: 1, author: photo_post.author_name)) end it "falls back to the title, if the root post was deleted" do - reshare = FactoryGirl.create(:reshare) + reshare = FactoryBot.create(:reshare) reshare.root.destroy expect(helper.post_message(Reshare.find(reshare.id))) .to eq(I18n.t("posts.show.reshare_by", author: reshare.author_name)) @@ -35,13 +35,13 @@ describe NotifierHelper, :type => :helper do describe '#comment_message' do before do # comment for markdown test - @markdown_comment = FactoryGirl.create(:comment) + @markdown_comment = FactoryBot.create(:comment) @markdown_comment.post.public = true @markdown_comment.text = "[link](http://diasporafoundation.org) **bold text** *other text*" @striped_markdown_comment = "link (http://diasporafoundation.org) bold text other text" # comment for limited post - @limited_comment = FactoryGirl.create(:comment) + @limited_comment = FactoryBot.create(:comment) @limited_comment.post.public = false @limited_comment.text = "This is top secret comment. Shhhhhhhh!!!" end diff --git a/spec/helpers/people_helper_spec.rb b/spec/helpers/people_helper_spec.rb index 4b4140918..12ab56230 100644 --- a/spec/helpers/people_helper_spec.rb +++ b/spec/helpers/people_helper_spec.rb @@ -7,7 +7,7 @@ describe PeopleHelper, :type => :helper do before do @user = alice - @person = FactoryGirl.create(:person) + @person = FactoryBot.create(:person) end describe "#birthday_format" do @@ -47,7 +47,7 @@ describe PeopleHelper, :type => :helper do describe '#person_link' do before do - @person = FactoryGirl.create(:person) + @person = FactoryBot.create(:person) end it 'includes the name of the person if they have a first name' do @@ -86,7 +86,7 @@ describe PeopleHelper, :type => :helper do describe '#local_or_remote_person_path' do before do - @user = FactoryGirl.create(:user) + @user = FactoryBot.create(:user) end it "links by id if there is a period in the user's username" do diff --git a/spec/helpers/posts_helper_spec.rb b/spec/helpers/posts_helper_spec.rb index 90b73c273..1b7e536f6 100644 --- a/spec/helpers/posts_helper_spec.rb +++ b/spec/helpers/posts_helper_spec.rb @@ -8,7 +8,7 @@ describe PostsHelper, :type => :helper do describe '#post_page_title' do before do - @sm = FactoryGirl.create(:status_message) + @sm = FactoryBot.create(:status_message) end context 'with posts with text' do @@ -22,7 +22,7 @@ describe PostsHelper, :type => :helper do context "with a reshare" do it "returns 'Reshare by...'" do - reshare = FactoryGirl.create(:reshare, author: alice.person) + reshare = FactoryBot.create(:reshare, author: alice.person) expect(post_page_title(reshare)).to eq I18n.t("posts.show.reshare_by", author: reshare.author_name) end end @@ -31,7 +31,7 @@ describe PostsHelper, :type => :helper do describe '#post_iframe_url' do before do - @post = FactoryGirl.create(:status_message) + @post = FactoryBot.create(:status_message) end it "returns an iframe tag" do diff --git a/spec/integration/account_deletion_spec.rb b/spec/integration/account_deletion_spec.rb index d09b5d564..300231f35 100644 --- a/spec/integration/account_deletion_spec.rb +++ b/spec/integration/account_deletion_spec.rb @@ -7,7 +7,7 @@ describe "deleteing account", type: :request do end context "of local user" do - subject(:user) { FactoryGirl.create(:user_with_aspect) } + subject(:user) { FactoryBot.create(:user_with_aspect) } let(:person) { user.person } before do diff --git a/spec/integration/account_migration_spec.rb b/spec/integration/account_migration_spec.rb index 1dcfbc713..dcc9b6754 100644 --- a/spec/integration/account_migration_spec.rb +++ b/spec/integration/account_migration_spec.rb @@ -3,10 +3,10 @@ require "integration/federation/federation_helper" def create_remote_contact(user, pod_host) - FactoryGirl.create( + FactoryBot.create( :contact, user: user, - person: FactoryGirl.create( + person: FactoryBot.create( :person, pod: Pod.find_or_create_by(url: "http://#{pod_host}"), diaspora_handle: "#{r_str}@#{pod_host}" @@ -16,29 +16,29 @@ end shared_examples_for "every migration scenario" do it "updates person references" do - contact = FactoryGirl.create(:contact, person: old_person) - post = FactoryGirl.create(:status_message, author: old_person) - reshare = FactoryGirl.create(:reshare, author: old_person) - photo = FactoryGirl.create(:photo, author: old_person) - comment = FactoryGirl.create(:comment, author: old_person) - like = FactoryGirl.create(:like, author: old_person) - participation = FactoryGirl.create(:participation, author: old_person) - poll_participation = FactoryGirl.create(:poll_participation, author: old_person) - mention = FactoryGirl.create(:mention, person: old_person) - message = FactoryGirl.create(:message, author: old_person) - conversation = FactoryGirl.create(:conversation, author: old_person) - block = FactoryGirl.create(:user).blocks.create(person: old_person) - role = FactoryGirl.create(:role, person: old_person) + contact = FactoryBot.create(:contact, person: old_person) + post = FactoryBot.create(:status_message, author: old_person) + reshare = FactoryBot.create(:reshare, author: old_person) + photo = FactoryBot.create(:photo, author: old_person) + comment = FactoryBot.create(:comment, author: old_person) + like = FactoryBot.create(:like, author: old_person) + participation = FactoryBot.create(:participation, author: old_person) + poll_participation = FactoryBot.create(:poll_participation, author: old_person) + mention = FactoryBot.create(:mention, person: old_person) + message = FactoryBot.create(:message, author: old_person) + conversation = FactoryBot.create(:conversation, author: old_person) + block = FactoryBot.create(:user).blocks.create(person: old_person) + role = FactoryBot.create(:role, person: old_person) # Create ConversationVisibility by creating a conversation with participants - conversation2 = FactoryGirl.build(:conversation) - FactoryGirl.create(:contact, user: old_user, person: conversation2.author) if old_person.local? + conversation2 = FactoryBot.build(:conversation) + FactoryBot.create(:contact, user: old_user, person: conversation2.author) if old_person.local? conversation2.participants << old_person conversation2.save! visibility = ConversationVisibility.find_by(person_id: old_person.id) # In order to create a notification actor we need to create a notification first - notification = FactoryGirl.build(:notification) + notification = FactoryBot.build(:notification) notification.actors << old_person notification.save! actor = notification.notification_actors.find_by(person_id: old_person.id) @@ -110,7 +110,7 @@ end shared_examples_for "migration scenarios initiated remotely" do it "resends known contacts to the new user" do 2.times do - contact = FactoryGirl.create(:contact, person: old_user.person, sharing: true) + contact = FactoryBot.create(:contact, person: old_user.person, sharing: true) expect(DiasporaFederation::Federation::Sender).to receive(:private) .with( contact.user_id, @@ -157,17 +157,17 @@ end shared_examples_for "migration scenarios with local user rename" do it "updates user references" do - invited_user = FactoryGirl.create(:user, invited_by: old_user) - aspect = FactoryGirl.create(:aspect, user: old_user, name: r_str) - contact = FactoryGirl.create(:contact, user: old_user) - service = FactoryGirl.create(:service, user: old_user) + invited_user = FactoryBot.create(:user, invited_by: old_user) + aspect = FactoryBot.create(:aspect, user: old_user, name: r_str) + contact = FactoryBot.create(:contact, user: old_user) + service = FactoryBot.create(:service, user: old_user) pref = UserPreference.create!(user: old_user, email_type: "also_commented") - tag_following = FactoryGirl.create(:tag_following, user: old_user) - block = FactoryGirl.create(:block, user: old_user) - notification = FactoryGirl.create(:notification, recipient: old_user) - report = FactoryGirl.create(:report, user: old_user) - authorization = FactoryGirl.create(:auth_with_read_scopes, user: old_user) - share_visibility = FactoryGirl.create(:share_visibility, user: old_user) + tag_following = FactoryBot.create(:tag_following, user: old_user) + block = FactoryBot.create(:block, user: old_user) + notification = FactoryBot.create(:notification, recipient: old_user) + report = FactoryBot.create(:report, user: old_user) + authorization = FactoryBot.create(:auth_with_read_scopes, user: old_user) + share_visibility = FactoryBot.create(:share_visibility, user: old_user) run_migration @@ -229,7 +229,7 @@ describe "account migration" do # this is the case when we're a pod, which was left by a person in favor of remote one context "old user is local, new user is remote" do - let(:old_user) { FactoryGirl.create(:user) } + let(:old_user) { FactoryBot.create(:user) } let(:old_person) { old_user.person } let(:new_user) { remote_user_on_pod_b } let(:new_person) { new_user.person } @@ -282,7 +282,7 @@ describe "account migration" do context "old user is remote and new user is local" do let(:old_user) { remote_user_on_pod_c } let(:old_person) { old_user.person } - let(:new_user) { FactoryGirl.create(:user) } + let(:new_user) { FactoryBot.create(:user) } let(:new_person) { new_user.person } def run_migration @@ -300,7 +300,7 @@ describe "account migration" do end context "when new person has been migrated before" do - let(:intermidiate_person) { FactoryGirl.create(:user).person } + let(:intermidiate_person) { FactoryBot.create(:user).person } before do AccountMigration.create!(old_person: intermidiate_person, new_person: new_person).perform! @@ -320,9 +320,9 @@ describe "account migration" do # this is the case when a user changes diaspora id but stays on the same pod context "old user is local and new user is local" do - let(:old_user) { FactoryGirl.create(:user) } + let(:old_user) { FactoryBot.create(:user) } let(:old_person) { old_user.person } - let(:new_user) { FactoryGirl.create(:user) } + let(:new_user) { FactoryBot.create(:user) } let(:new_person) { new_user.person } def run_migration @@ -345,7 +345,7 @@ describe "account migration" do include_examples "migration scenarios with local user rename" context "when new user has been migrated before" do - let(:intermidiate_person) { FactoryGirl.create(:user).person } + let(:intermidiate_person) { FactoryBot.create(:user).person } before do AccountMigration.create!(old_person: intermidiate_person, new_person: new_person).perform! diff --git a/spec/integration/api/aspects_controller_spec.rb b/spec/integration/api/aspects_controller_spec.rb index a664b66ea..9661b288c 100644 --- a/spec/integration/api/aspects_controller_spec.rb +++ b/spec/integration/api/aspects_controller_spec.rb @@ -4,21 +4,21 @@ require_relative "api_spec_helper" describe Api::V1::AspectsController do let(:auth) { - FactoryGirl.create( + FactoryBot.create( :auth_with_default_scopes, scopes: %w[openid contacts:read contacts:modify] ) } let(:auth_read_only) { - FactoryGirl.create( + FactoryBot.create( :auth_with_default_scopes, scopes: %w[openid contacts:read] ) } let(:auth_minimum_scopes) { - FactoryGirl.create(:auth_with_default_scopes) + FactoryBot.create(:auth_with_default_scopes) } let!(:access_token) { auth.create_access_token.to_s } diff --git a/spec/integration/api/comments_controller_spec.rb b/spec/integration/api/comments_controller_spec.rb index 0b4cdfd6d..9f8e08c7e 100644 --- a/spec/integration/api/comments_controller_spec.rb +++ b/spec/integration/api/comments_controller_spec.rb @@ -4,22 +4,22 @@ require_relative "api_spec_helper" describe Api::V1::CommentsController do let(:auth) { - FactoryGirl.create( + FactoryBot.create( :auth_with_default_scopes, scopes: %w[openid public:read public:modify private:read interactions], - user: FactoryGirl.create(:user, profile: FactoryGirl.create(:profile_with_image_url)) + user: FactoryBot.create(:user, profile: FactoryBot.create(:profile_with_image_url)) ) } let(:auth_public_only) { - FactoryGirl.create( + FactoryBot.create( :auth_with_default_scopes, scopes: %w[openid public:read public:modify interactions] ) } let(:auth_minimum_scopes) { - FactoryGirl.create(:auth_with_default_scopes) + FactoryBot.create(:auth_with_default_scopes) } let!(:access_token) { auth.create_access_token.to_s } @@ -28,8 +28,8 @@ describe Api::V1::CommentsController do let(:invalid_token) { SecureRandom.hex(9) } before do - alice.person.profile = FactoryGirl.create(:profile_with_image_url) - eve.person.profile = FactoryGirl.create(:profile_with_image_url) + alice.person.profile = FactoryBot.create(:profile_with_image_url) + eve.person.profile = FactoryBot.create(:profile_with_image_url) @status = alice.post( "Post", diff --git a/spec/integration/api/contacts_controller_spec.rb b/spec/integration/api/contacts_controller_spec.rb index f6953d030..ccc8488a0 100644 --- a/spec/integration/api/contacts_controller_spec.rb +++ b/spec/integration/api/contacts_controller_spec.rb @@ -4,21 +4,21 @@ require_relative "api_spec_helper" describe Api::V1::ContactsController do let(:auth) { - FactoryGirl.create( + FactoryBot.create( :auth_with_default_scopes, scopes: %w[openid contacts:read contacts:modify] ) } let(:auth_read_only) { - FactoryGirl.create( + FactoryBot.create( :auth_with_default_scopes, scopes: %w[openid contacts:read] ) } let(:auth_minimum_scopes) { - FactoryGirl.create(:auth_with_default_scopes) + FactoryBot.create(:auth_with_default_scopes) } let!(:access_token) { auth.create_access_token.to_s } @@ -31,7 +31,7 @@ describe Api::V1::ContactsController do auth.user.share_with(eve.person, @aspect1) @aspect2 = auth.user.aspects.create(name: "another aspect") @eve_aspect = eve.aspects.first - alice.person.profile = FactoryGirl.create(:profile_with_image_url) + alice.person.profile = FactoryBot.create(:profile_with_image_url) end describe "#show" do diff --git a/spec/integration/api/conversations_controller_spec.rb b/spec/integration/api/conversations_controller_spec.rb index 2e4818b5f..9c69462a5 100644 --- a/spec/integration/api/conversations_controller_spec.rb +++ b/spec/integration/api/conversations_controller_spec.rb @@ -4,19 +4,19 @@ require_relative "api_spec_helper" describe Api::V1::ConversationsController do let(:auth) { - FactoryGirl.create( + FactoryBot.create( :auth_with_default_scopes, scopes: %w[openid conversations], - user: FactoryGirl.create(:user, profile: FactoryGirl.create(:profile_with_image_url)) + user: FactoryBot.create(:user, profile: FactoryBot.create(:profile_with_image_url)) ) } let(:auth_participant) { - FactoryGirl.create(:auth_with_all_scopes) + FactoryBot.create(:auth_with_all_scopes) } let(:auth_minimum_scopes) { - FactoryGirl.create(:auth_with_default_scopes) + FactoryBot.create(:auth_with_default_scopes) } let!(:access_token) { auth.create_access_token.to_s } @@ -25,7 +25,7 @@ describe Api::V1::ConversationsController do let(:invalid_token) { SecureRandom.hex(9) } before do - alice.person.profile = FactoryGirl.create(:profile_with_image_url) + alice.person.profile = FactoryBot.create(:profile_with_image_url) auth.user.aspects.create(name: "first") auth.user.share_with(alice.person, auth.user.aspects[0]) diff --git a/spec/integration/api/likes_controller_spec.rb b/spec/integration/api/likes_controller_spec.rb index 88e7ac95e..b65b54583 100644 --- a/spec/integration/api/likes_controller_spec.rb +++ b/spec/integration/api/likes_controller_spec.rb @@ -4,22 +4,22 @@ require_relative "api_spec_helper" describe Api::V1::LikesController do let(:auth) { - FactoryGirl.create( + FactoryBot.create( :auth_with_default_scopes, scopes: %w[openid public:read public:modify private:read private:modify interactions], - user: FactoryGirl.create(:user, profile: FactoryGirl.create(:profile_with_image_url)) + user: FactoryBot.create(:user, profile: FactoryBot.create(:profile_with_image_url)) ) } let(:auth_public_only) { - FactoryGirl.create( + FactoryBot.create( :auth_with_default_scopes, scopes: %w[openid public:read public:modify interactions] ) } let(:auth_minimum_scopes) { - FactoryGirl.create(:auth_with_default_scopes) + FactoryBot.create(:auth_with_default_scopes) } let!(:access_token) { auth.create_access_token.to_s } @@ -28,8 +28,8 @@ describe Api::V1::LikesController do let(:invalid_token) { SecureRandom.hex(9) } before do - alice.person.profile = FactoryGirl.create(:profile_with_image_url) - bob.person.profile = FactoryGirl.create(:profile_with_image_url) + alice.person.profile = FactoryBot.create(:profile_with_image_url) + bob.person.profile = FactoryBot.create(:profile_with_image_url) @status = auth.user.post( :status_message, diff --git a/spec/integration/api/messages_controller_spec.rb b/spec/integration/api/messages_controller_spec.rb index 2cbcf38b8..b292bdf50 100644 --- a/spec/integration/api/messages_controller_spec.rb +++ b/spec/integration/api/messages_controller_spec.rb @@ -4,15 +4,15 @@ require_relative "api_spec_helper" describe Api::V1::MessagesController do let(:auth) { - FactoryGirl.create( + FactoryBot.create( :auth_with_default_scopes, scopes: %w[openid conversations], - user: FactoryGirl.create(:user, profile: FactoryGirl.create(:profile_with_image_url)) + user: FactoryBot.create(:user, profile: FactoryBot.create(:profile_with_image_url)) ) } let(:auth_minimum_scopes) { - FactoryGirl.create(:auth_with_default_scopes) + FactoryBot.create(:auth_with_default_scopes) } let!(:access_token) { auth.create_access_token.to_s } diff --git a/spec/integration/api/notifications_controller_spec.rb b/spec/integration/api/notifications_controller_spec.rb index f889367b7..485f05113 100644 --- a/spec/integration/api/notifications_controller_spec.rb +++ b/spec/integration/api/notifications_controller_spec.rb @@ -4,11 +4,11 @@ require_relative "api_spec_helper" describe Api::V1::NotificationsController do let(:auth) { - FactoryGirl.create(:auth_with_all_scopes) + FactoryBot.create(:auth_with_all_scopes) } let(:auth_minimum_scopes) { - FactoryGirl.create(:auth_with_default_scopes) + FactoryBot.create(:auth_with_default_scopes) } let!(:access_token) { auth.create_access_token.to_s } @@ -25,8 +25,8 @@ describe Api::V1::NotificationsController do :status_message, text: "This is a status message mentioning @{#{auth.user.diaspora_handle}}" ) - @notification = FactoryGirl.create(:notification, recipient: auth.user, target: @post, created_at: 1.hour.ago) - @mentioned = FactoryGirl.create(:notification_mentioned_in_comment, recipient: auth.user, target: @post) + @notification = FactoryBot.create(:notification, recipient: auth.user, target: @post, created_at: 1.hour.ago) + @mentioned = FactoryBot.create(:notification_mentioned_in_comment, recipient: auth.user, target: @post) end describe "#index" do @@ -153,7 +153,7 @@ describe Api::V1::NotificationsController do public: true, to: "all" ) - alice_notification = FactoryGirl.create(:notification, recipient: alice, target: alice_post) + alice_notification = FactoryBot.create(:notification, recipient: alice, target: alice_post) get( api_v1_notification_path(alice_notification.guid), diff --git a/spec/integration/api/photos_controller_spec.rb b/spec/integration/api/photos_controller_spec.rb index 7e57bb601..970e3777d 100644 --- a/spec/integration/api/photos_controller_spec.rb +++ b/spec/integration/api/photos_controller_spec.rb @@ -4,35 +4,35 @@ require_relative "api_spec_helper" describe Api::V1::PhotosController do let(:auth) { - FactoryGirl.create( + FactoryBot.create( :auth_with_default_scopes, scopes: %w[openid public:read public:modify private:read private:modify] ) } let(:auth_public_only) { - FactoryGirl.create( + FactoryBot.create( :auth_with_default_scopes, scopes: %w[openid public:read public:modify] ) } let(:auth_read_only) { - FactoryGirl.create( + FactoryBot.create( :auth_with_default_scopes, scopes: %w[openid public:read private:read] ) } let(:auth_public_only_read_only) { - FactoryGirl.create( + FactoryBot.create( :auth_with_default_scopes, scopes: %w[openid public:read] ) } let(:auth_minimum_scopes) { - FactoryGirl.create(:auth_with_default_scopes) + FactoryBot.create(:auth_with_default_scopes) } let!(:access_token) { auth.create_access_token.to_s } diff --git a/spec/integration/api/post_interactions_controller_spec.rb b/spec/integration/api/post_interactions_controller_spec.rb index 2e785029a..fe75a8488 100644 --- a/spec/integration/api/post_interactions_controller_spec.rb +++ b/spec/integration/api/post_interactions_controller_spec.rb @@ -4,21 +4,21 @@ require_relative "api_spec_helper" describe Api::V1::PostInteractionsController do let(:auth) { - FactoryGirl.create( + FactoryBot.create( :auth_with_default_scopes, scopes: %w[openid public:read public:modify private:read private:modify interactions] ) } let(:auth_public_only) { - FactoryGirl.create( + FactoryBot.create( :auth_with_default_scopes, scopes: %w[openid public:read public:modify interactions] ) } let(:auth_minimum_scopes) { - FactoryGirl.create(:auth_with_default_scopes) + FactoryBot.create(:auth_with_default_scopes) } let!(:access_token) { auth.create_access_token.to_s } diff --git a/spec/integration/api/posts_controller_spec.rb b/spec/integration/api/posts_controller_spec.rb index 0a6d416b0..c7356ac35 100644 --- a/spec/integration/api/posts_controller_spec.rb +++ b/spec/integration/api/posts_controller_spec.rb @@ -4,35 +4,35 @@ require_relative "api_spec_helper" describe Api::V1::PostsController do let(:auth) { - FactoryGirl.create( + FactoryBot.create( :auth_with_default_scopes, scopes: %w[openid public:read public:modify private:read private:modify], - user: FactoryGirl.create(:user, profile: FactoryGirl.create(:profile_with_image_url)) + user: FactoryBot.create(:user, profile: FactoryBot.create(:profile_with_image_url)) ) } let(:auth_public_only) { - FactoryGirl.create( + FactoryBot.create( :auth_with_default_scopes, scopes: %w[openid public:read public:modify] ) } let(:auth_read_only) { - FactoryGirl.create( + FactoryBot.create( :auth_with_default_scopes, scopes: %w[openid public:read private:read] ) } let(:auth_public_only_read_only) { - FactoryGirl.create( + FactoryBot.create( :auth_with_default_scopes, scopes: %w[openid public:read] ) } - let(:auth_minimum_scopes) { FactoryGirl.create(:auth_with_default_scopes) } + let(:auth_minimum_scopes) { FactoryBot.create(:auth_with_default_scopes) } let!(:access_token) { auth.create_access_token.to_s } let!(:access_token_public_only) { auth_public_only.create_access_token.to_s } let!(:access_token_read_only) { auth_read_only.create_access_token.to_s } @@ -41,9 +41,9 @@ describe Api::V1::PostsController do let(:invalid_token) { SecureRandom.hex(9) } before do - alice.person.profile = FactoryGirl.create(:profile_with_image_url) - bob.person.profile = FactoryGirl.create(:profile_with_image_url) - eve.person.profile = FactoryGirl.create(:profile_with_image_url) + alice.person.profile = FactoryBot.create(:profile_with_image_url) + bob.person.profile = FactoryBot.create(:profile_with_image_url) + eve.person.profile = FactoryBot.create(:profile_with_image_url) @alice_aspect = alice.aspects.first @alice_photo1 = alice.post(:photo, pending: true, user_file: File.open(photo_fixture_name), to: @alice_aspect.id) @@ -87,8 +87,8 @@ describe Api::V1::PostsController do merged_params = merged_params.merge(poll_params) merged_params = merged_params.merge(photos: @alice_photo_ids) status_message = StatusMessageCreationService.new(alice).create(merged_params) - status_message.open_graph_cache = FactoryGirl.create(:open_graph_cache, video_url: "http://example.org") - status_message.o_embed_cache = FactoryGirl.create(:o_embed_cache) + status_message.open_graph_cache = FactoryBot.create(:open_graph_cache, video_url: "http://example.org") + status_message.o_embed_cache = FactoryBot.create(:o_embed_cache) status_message.save get( @@ -132,7 +132,7 @@ describe Api::V1::PostsController do context "access reshare style post by post ID" do it "gets post" do - reshare_post = FactoryGirl.create(:reshare, root: @status, author: bob.person) + reshare_post = FactoryBot.create(:reshare, root: @status, author: bob.person) get( api_v1_post_path(reshare_post.guid), params: { diff --git a/spec/integration/api/reshares_controller_spec.rb b/spec/integration/api/reshares_controller_spec.rb index 16cdbe12b..b957fe9bc 100644 --- a/spec/integration/api/reshares_controller_spec.rb +++ b/spec/integration/api/reshares_controller_spec.rb @@ -4,15 +4,15 @@ require_relative "api_spec_helper" describe Api::V1::ResharesController do let(:auth) { - FactoryGirl.create(:auth_with_all_scopes) + FactoryBot.create(:auth_with_all_scopes) } let(:auth_read_only) { - FactoryGirl.create(:auth_with_read_scopes) + FactoryBot.create(:auth_with_read_scopes) } let(:auth_minimum_scopes) { - FactoryGirl.create(:auth_with_default_scopes) + FactoryBot.create(:auth_with_default_scopes) } let!(:access_token) { auth.create_access_token.to_s } @@ -21,7 +21,7 @@ describe Api::V1::ResharesController do let(:invalid_token) { SecureRandom.hex(9) } before do - alice.person.profile = FactoryGirl.create(:profile_with_image_url) + alice.person.profile = FactoryBot.create(:profile_with_image_url) @user_post = auth.user.post( :status_message, diff --git a/spec/integration/api/search_controller_spec.rb b/spec/integration/api/search_controller_spec.rb index 8ea002ad7..0c98e698b 100644 --- a/spec/integration/api/search_controller_spec.rb +++ b/spec/integration/api/search_controller_spec.rb @@ -4,21 +4,21 @@ require_relative "api_spec_helper" describe Api::V1::SearchController do let(:auth) { - FactoryGirl.create( + FactoryBot.create( :auth_with_default_scopes, scopes: %w[openid public:read public:modify private:read contacts:read private:modify] ) } let(:auth_read_only) { - FactoryGirl.create( + FactoryBot.create( :auth_with_default_scopes, scopes: %w[openid public:read private:read] ) } let(:auth_public_only_read_only) { - FactoryGirl.create( + FactoryBot.create( :auth_with_default_scopes, scopes: %w[openid public:read] ) @@ -31,21 +31,21 @@ describe Api::V1::SearchController do describe "#user_index" do before do - @searchable_user = FactoryGirl.create( + @searchable_user = FactoryBot.create( :person, diaspora_handle: "findable@example.org", - profile: FactoryGirl.build(:profile, first_name: "Terry", last_name: "Smith") + profile: FactoryBot.build(:profile, first_name: "Terry", last_name: "Smith") ) - @closed_user = FactoryGirl.create( + @closed_user = FactoryBot.create( :person, closed_account: true, - profile: FactoryGirl.build(:profile, first_name: "Closed", last_name: "Account") + profile: FactoryBot.build(:profile, first_name: "Closed", last_name: "Account") ) - @unsearchable_user = FactoryGirl.create( + @unsearchable_user = FactoryBot.create( :person, diaspora_handle: "unsearchable@example.org", - profile: FactoryGirl.build( + profile: FactoryBot.build( :profile, first_name: "Unsearchable", last_name: "Person", @@ -57,9 +57,9 @@ describe Api::V1::SearchController do it "succeeds by tag" do tag = SecureRandom.hex(5) 5.times do - FactoryGirl.create(:person, profile: FactoryGirl.build(:profile, tag_string: "##{tag}")) + FactoryBot.create(:person, profile: FactoryBot.build(:profile, tag_string: "##{tag}")) end - FactoryGirl.create(:person, closed_account: true, profile: FactoryGirl.build(:profile, tag_string: "##{tag}")) + FactoryBot.create(:person, closed_account: true, profile: FactoryBot.build(:profile, tag_string: "##{tag}")) get( "/api/v1/search/users", @@ -202,7 +202,7 @@ describe Api::V1::SearchController do end def add_contact(receiving, sharing) - other = FactoryGirl.create(:user) + other = FactoryBot.create(:user) other.profile.update(first_name: name) if receiving @@ -312,7 +312,7 @@ describe Api::V1::SearchController do end def add_contact(*aspects) - other = FactoryGirl.create(:person, profile: FactoryGirl.build(:profile, first_name: contact_name)) + other = FactoryBot.create(:person, profile: FactoryBot.build(:profile, first_name: contact_name)) aspects.each do |aspect| auth.user.share_with(other, aspect) end @@ -464,9 +464,9 @@ describe Api::V1::SearchController do describe "tag_index" do before do - FactoryGirl.create(:tag, name: "apipartyone") - FactoryGirl.create(:tag, name: "apipartytwo") - FactoryGirl.create(:tag, name: "apipartythree") + FactoryBot.create(:tag, name: "apipartyone") + FactoryBot.create(:tag, name: "apipartytwo") + FactoryBot.create(:tag, name: "apipartythree") end it "succeeds" do diff --git a/spec/integration/api/streams_controller_spec.rb b/spec/integration/api/streams_controller_spec.rb index a3af82201..fa650664d 100644 --- a/spec/integration/api/streams_controller_spec.rb +++ b/spec/integration/api/streams_controller_spec.rb @@ -4,26 +4,26 @@ require_relative "api_spec_helper" describe Api::V1::StreamsController do let(:auth_read_only) { - FactoryGirl.create( + FactoryBot.create( :auth_with_default_scopes, scopes: %w[openid public:read private:read contacts:read tags:read], - user: FactoryGirl.create(:user, profile: FactoryGirl.create(:profile_with_image_url)) + user: FactoryBot.create(:user, profile: FactoryBot.create(:profile_with_image_url)) ) } let(:auth_public_only_tags) { - FactoryGirl.create( + FactoryBot.create( :auth_with_default_scopes, scopes: %w[openid public:read tags:read], - user: FactoryGirl.create(:user, profile: FactoryGirl.create(:profile_with_image_url)) + user: FactoryBot.create(:user, profile: FactoryBot.create(:profile_with_image_url)) ) } let(:auth_public_only_read_only) { - FactoryGirl.create( + FactoryBot.create( :auth_with_default_scopes, scopes: %w[openid public:read], - user: FactoryGirl.create(:user, profile: FactoryGirl.create(:profile_with_image_url)) + user: FactoryBot.create(:user, profile: FactoryBot.create(:profile_with_image_url)) ) } diff --git a/spec/integration/api/tag_followings_controller_spec.rb b/spec/integration/api/tag_followings_controller_spec.rb index 18446affc..c3bf30f66 100755 --- a/spec/integration/api/tag_followings_controller_spec.rb +++ b/spec/integration/api/tag_followings_controller_spec.rb @@ -4,20 +4,20 @@ require_relative "api_spec_helper" describe Api::V1::TagFollowingsController do let(:auth) { - FactoryGirl.create( + FactoryBot.create( :auth_with_default_scopes, scopes: %w[openid tags:read tags:modify] ) } let(:auth_read_only) { - FactoryGirl.create( + FactoryBot.create( :auth_with_default_scopes, scopes: %w[openid tags:read] ) } - let(:auth_minimum_scopes) { FactoryGirl.create(:auth_with_default_scopes) } + let(:auth_minimum_scopes) { FactoryBot.create(:auth_with_default_scopes) } let!(:access_token) { auth.create_access_token.to_s } let!(:access_token_read_only) { auth_read_only.create_access_token.to_s } let!(:access_token_minimum_scopes) { auth_minimum_scopes.create_access_token.to_s } diff --git a/spec/integration/api/user_info_controller_spec.rb b/spec/integration/api/user_info_controller_spec.rb index 97834a05c..2ecff11fc 100644 --- a/spec/integration/api/user_info_controller_spec.rb +++ b/spec/integration/api/user_info_controller_spec.rb @@ -4,7 +4,7 @@ describe Api::OpenidConnect::UserInfoController do include Rails.application.routes.url_helpers let!(:auth_with_read_and_ppid) { - FactoryGirl.create(:auth_with_profile_and_ppid) + FactoryBot.create(:auth_with_profile_and_ppid) } let!(:access_token_with_read) { auth_with_read_and_ppid.create_access_token.to_s } diff --git a/spec/integration/api/users_controller_spec.rb b/spec/integration/api/users_controller_spec.rb index c68ded1f3..a3833c06d 100644 --- a/spec/integration/api/users_controller_spec.rb +++ b/spec/integration/api/users_controller_spec.rb @@ -11,36 +11,36 @@ describe Api::V1::UsersController do } let(:auth) { - FactoryGirl.create( + FactoryBot.create( :auth_with_default_scopes, scopes: full_scopes, - user: FactoryGirl.create(:user, profile: FactoryGirl.create(:profile_with_image_url)) + user: FactoryBot.create(:user, profile: FactoryBot.create(:profile_with_image_url)) ) } let(:auth_public_only) { - FactoryGirl.create( + FactoryBot.create( :auth_with_default_scopes, scopes: %w[openid public:read public:modify] ) } let(:auth_read_only) { - FactoryGirl.create( + FactoryBot.create( :auth_with_default_scopes, scopes: %w[openid public:read private:read contacts:read profile] ) } let(:auth_public_only_read_only) { - FactoryGirl.create( + FactoryBot.create( :auth_with_default_scopes, scopes: %w[openid public:read] ) } let(:auth_minimum_scopes) { - FactoryGirl.create(:auth_with_default_scopes) + FactoryBot.create(:auth_with_default_scopes) } let!(:access_token) { auth.create_access_token.to_s } let!(:access_token_public_only) { auth_public_only.create_access_token.to_s } @@ -50,7 +50,7 @@ describe Api::V1::UsersController do let(:invalid_token) { SecureRandom.hex(9) } before do - alice.person.profile = FactoryGirl.create(:profile_with_image_url) + alice.person.profile = FactoryBot.create(:profile_with_image_url) end describe "#show" do @@ -111,7 +111,7 @@ describe Api::V1::UsersController do end it "succeeds with limited data on non-public/not shared" do - eve.person.profile = FactoryGirl.create(:profile_with_image_url) + eve.person.profile = FactoryBot.create(:profile_with_image_url) eve.profile[:public_details] = false eve.profile.save get( @@ -146,10 +146,10 @@ describe Api::V1::UsersController do end it "fails for private profile if don't have contacts:read" do - unsearchable_user = FactoryGirl.create( + unsearchable_user = FactoryBot.create( :person, diaspora_handle: "unsearchable@example.org", - profile: FactoryGirl.build( + profile: FactoryBot.build( :profile, first_name: "Unsearchable", last_name: "Person", @@ -511,7 +511,7 @@ describe Api::V1::UsersController do end describe "#block" do - let(:person) { FactoryGirl.create(:user).person } + let(:person) { FactoryBot.create(:user).person } context "success" do it "with proper credentials and flags" do diff --git a/spec/integration/archive_shared.rb b/spec/integration/archive_shared.rb index fd6c6389e..adc371589 100644 --- a/spec/integration/archive_shared.rb +++ b/spec/integration/archive_shared.rb @@ -6,7 +6,7 @@ def expect_person_fetch(diaspora_id, public_key) expect(instance).to receive(:fetch_and_save) { attributes = {diaspora_handle: diaspora_id} attributes[:serialized_public_key] = public_key if public_key.present? - FactoryGirl.create(:person, attributes) + FactoryBot.create(:person, attributes) } } } diff --git a/spec/integration/contacts_spec.rb b/spec/integration/contacts_spec.rb index 00436ccae..7b32ced10 100644 --- a/spec/integration/contacts_spec.rb +++ b/spec/integration/contacts_spec.rb @@ -17,7 +17,7 @@ describe ContactsController, type: :request do end context "user has no contacts" do - let!(:user) { FactoryGirl.create(:user) } + let!(:user) { FactoryBot.create(:user) } before do expect(user.contacts.size).to eq(0) @@ -46,11 +46,11 @@ describe ContactsController, type: :request do end context "user has contacts" do - let!(:user) { FactoryGirl.create(:user) } + let!(:user) { FactoryBot.create(:user) } before do - FactoryGirl.create(:contact, person: alice.person, user: user) - FactoryGirl.create(:contact, person: bob.person, user: user) + FactoryBot.create(:contact, person: alice.person, user: user) + FactoryBot.create(:contact, person: bob.person, user: user) expect(user.reload.contacts.size).to eq(2) end diff --git a/spec/integration/dispatching_spec.rb b/spec/integration/dispatching_spec.rb index 30ab378b9..8139c79a2 100644 --- a/spec/integration/dispatching_spec.rb +++ b/spec/integration/dispatching_spec.rb @@ -4,7 +4,7 @@ describe "Dispatching", type: :request do context "a comment retraction on a public post" do it "triggers a public dispatch" do # Alice has a public post and comments on it - post = FactoryGirl.create(:status_message, public: true, author: alice.person) + post = FactoryBot.create(:status_message, public: true, author: alice.person) comment = alice.comment!(post, "awesomesauseum") diff --git a/spec/integration/export/memory_usage_spec.rb b/spec/integration/export/memory_usage_spec.rb index 9036796ee..efa07b493 100644 --- a/spec/integration/export/memory_usage_spec.rb +++ b/spec/integration/export/memory_usage_spec.rb @@ -31,11 +31,11 @@ describe Diaspora::Exporter do create_basic_users 1000.times { - FactoryGirl.create(:signed_comment, post: bob.person.posts.first) - FactoryGirl.create(:status_message, author: bob.person) - FactoryGirl.create(:comment, author: bob.person) - FactoryGirl.create(:contact, user: bob) - FactoryGirl.create(:participation, author: bob.person) + FactoryBot.create(:signed_comment, post: bob.person.posts.first) + FactoryBot.create(:status_message, author: bob.person) + FactoryBot.create(:comment, author: bob.person) + FactoryBot.create(:contact, user: bob) + FactoryBot.create(:participation, author: bob.person) } end end diff --git a/spec/integration/exporter_spec.rb b/spec/integration/exporter_spec.rb index 7794c07de..ef3750179 100644 --- a/spec/integration/exporter_spec.rb +++ b/spec/integration/exporter_spec.rb @@ -5,7 +5,7 @@ # the COPYRIGHT file. describe Diaspora::Exporter do - let(:user) { FactoryGirl.create(:user_with_aspect) } + let(:user) { FactoryBot.create(:user_with_aspect) } context "output json" do let(:json) { Diaspora::Exporter.new(user).execute } @@ -74,7 +74,7 @@ describe Diaspora::Exporter do end it "contains a public status message" do - status_message = FactoryGirl.create(:status_message, author: user.person, public: true) + status_message = FactoryBot.create(:status_message, author: user.person, public: true) serialized = { "subscribed_pods_uris": [AppConfig.pod_uri.to_s], "entity_type": "status_message", @@ -108,7 +108,7 @@ describe Diaspora::Exporter do end it "contains a status message with a poll" do - status_message = FactoryGirl.create(:status_message_with_poll, author: user.person) + status_message = FactoryBot.create(:status_message_with_poll, author: user.person) serialized = { "entity_type": "status_message", "entity_data": { @@ -140,7 +140,7 @@ describe Diaspora::Exporter do end it "contains a status message with a photo" do - status_message = FactoryGirl.create(:status_message_with_photo, author: user.person) + status_message = FactoryBot.create(:status_message_with_photo, author: user.person) serialized = { "entity_type": "status_message", @@ -173,7 +173,7 @@ describe Diaspora::Exporter do end it "contains a status message with a location" do - status_message = FactoryGirl.create(:status_message_with_location, author: user.person) + status_message = FactoryBot.create(:status_message_with_location, author: user.person) serialized = { "entity_type": "status_message", @@ -198,7 +198,7 @@ describe Diaspora::Exporter do end it "contains a reshare" do - reshare = FactoryGirl.create(:reshare, author: user.person) + reshare = FactoryBot.create(:reshare, author: user.person) serialized_reshare = { "subscribed_pods_uris": [reshare.root.author.pod.url_to(""), AppConfig.pod_uri.to_s], "entity_type": "reshare", @@ -227,7 +227,7 @@ describe Diaspora::Exporter do end it "contains a comment" do - comment = FactoryGirl.create(:comment, author: user.person) + comment = FactoryBot.create(:comment, author: user.person) serialized_comment = { "entity_type": "comment", "entity_data": { @@ -246,7 +246,7 @@ describe Diaspora::Exporter do end it "contains a like" do - like = FactoryGirl.create(:like, author: user.person) + like = FactoryBot.create(:like, author: user.person) serialized_like = { "entity_type": "like", "entity_data": { @@ -265,7 +265,7 @@ describe Diaspora::Exporter do end it "contains a poll participation" do - poll_participation = FactoryGirl.create(:poll_participation, author: user.person) + poll_participation = FactoryBot.create(:poll_participation, author: user.person) serialized_participation = { "entity_type": "poll_participation", "entity_data": { diff --git a/spec/integration/federation/attack_vectors_spec.rb b/spec/integration/federation/attack_vectors_spec.rb index 4810c8203..f53e6e37e 100644 --- a/spec/integration/federation/attack_vectors_spec.rb +++ b/spec/integration/federation/attack_vectors_spec.rb @@ -42,7 +42,7 @@ describe "attack vectors", type: :request do end it "public post should not be spoofed from another author" do - post = FactoryGirl.build(:status_message, public: true, author: eve.person) + post = FactoryBot.build(:status_message, public: true, author: eve.person) post_message(generate_payload(Diaspora::Federation::Entities.post(post), alice)) @@ -77,7 +77,7 @@ describe "attack vectors", type: :request do original_message = eve.post(:status_message, text: "store this!", to: eves_aspect.id) # someone else tries to make a message with the same guid - malicious_message = FactoryGirl.build( + malicious_message = FactoryBot.build( :status_message, id: original_message.id, guid: original_message.guid, @@ -95,7 +95,7 @@ describe "attack vectors", type: :request do original_message = eve.post(:status_message, text: "store this!", to: eves_aspect.id) # eve tries to send me another message with the same ID - malicious_message = FactoryGirl.build(:status_message, id: original_message.id, text: "BAD!!!", author: eve.person) + malicious_message = FactoryBot.build(:status_message, id: original_message.id, text: "BAD!!!", author: eve.person) post_message(generate_payload(Diaspora::Federation::Entities.post(malicious_message), eve, bob), bob) diff --git a/spec/integration/federation/federation_helper.rb b/spec/integration/federation/federation_helper.rb index 311fd85df..b8f486429 100644 --- a/spec/integration/federation/federation_helper.rb +++ b/spec/integration/federation/federation_helper.rb @@ -21,10 +21,10 @@ def allow_public_key_fetch(user) end def create_undiscovered_user(pod) - FactoryGirl.build(:user).tap do |user| + FactoryBot.build(:user).tap do |user| allow(user).to receive(:person).and_return( - FactoryGirl.build(:person, - profile: FactoryGirl.build(:profile), + FactoryBot.build(:person, + profile: FactoryBot.build(:profile), serialized_public_key: user.encryption_key.public_key.export, pod: Pod.find_or_create_by(url: "http://#{pod}"), diaspora_handle: "#{user.username}@#{pod}") diff --git a/spec/integration/federation/receive_federation_messages_spec.rb b/spec/integration/federation/receive_federation_messages_spec.rb index b53bc97c1..edc612c09 100644 --- a/spec/integration/federation/receive_federation_messages_spec.rb +++ b/spec/integration/federation/receive_federation_messages_spec.rb @@ -84,7 +84,7 @@ describe "Receive federation messages feature" do end context "when our pod was left" do - let(:sender) { FactoryGirl.create(:user) } + let(:sender) { FactoryBot.create(:user) } it "locks the old user account access" do run_migration @@ -108,7 +108,7 @@ describe "Receive federation messages feature" do context "reshare" do it "reshare of public post passes" do - post = FactoryGirl.create(:status_message, author: alice.person, public: true) + post = FactoryBot.create(:status_message, author: alice.person, public: true) reshare = Fabricate( :reshare_entity, root_author: alice.diaspora_handle, root_guid: post.guid, author: sender_id) @@ -128,7 +128,7 @@ describe "Receive federation messages feature" do end it "reshare of private post fails" do - post = FactoryGirl.create(:status_message, author: alice.person, public: false) + post = FactoryBot.create(:status_message, author: alice.person, public: false) reshare = Fabricate( :reshare_entity, root_author: alice.diaspora_handle, root_guid: post.guid, author: sender_id) expect { @@ -211,7 +211,7 @@ describe "Receive federation messages feature" do context "with message" do context "local" do let(:parent) { - FactoryGirl.build(:conversation, author: alice.person).tap do |target| + FactoryBot.build(:conversation, author: alice.person).tap do |target| target.participants << remote_user_on_pod_b.person target.participants << remote_user_on_pod_c.person target.save @@ -238,7 +238,7 @@ describe "Receive federation messages feature" do context "remote" do let(:parent) { - FactoryGirl.build(:conversation, author: remote_user_on_pod_b.person).tap do |target| + FactoryBot.build(:conversation, author: remote_user_on_pod_b.person).tap do |target| target.participants << alice.person target.participants << remote_user_on_pod_c.person target.save diff --git a/spec/integration/federation/shared_receive_stream_items.rb b/spec/integration/federation/shared_receive_stream_items.rb index 1431b9e1a..226778b35 100644 --- a/spec/integration/federation/shared_receive_stream_items.rb +++ b/spec/integration/federation/shared_receive_stream_items.rb @@ -32,8 +32,8 @@ shared_examples_for "messages which are indifferent about sharing fact" do end describe "with messages which require a status to operate on" do - let(:local_parent) { FactoryGirl.create(:status_message, author: alice.person, public: public) } - let(:remote_parent) { FactoryGirl.create(:status_message, author: remote_user_on_pod_b.person, public: public) } + let(:local_parent) { FactoryBot.create(:status_message, author: alice.person, public: public) } + let(:remote_parent) { FactoryBot.create(:status_message, author: remote_user_on_pod_b.person, public: public) } describe "notifications are sent where required" do it "for comment on local post" do @@ -103,15 +103,15 @@ shared_examples_for "messages which are indifferent about sharing fact" do context "with poll_participation" do let(:local_parent) { - FactoryGirl.create( + FactoryBot.create( :poll, - status_message: FactoryGirl.create(:status_message, author: alice.person, public: public) + status_message: FactoryBot.create(:status_message, author: alice.person, public: public) ) } let(:remote_parent) { - FactoryGirl.create( + FactoryBot.create( :poll, - status_message: FactoryGirl.create(:status_message, author: remote_user_on_pod_b.person, public: public) + status_message: FactoryBot.create(:status_message, author: remote_user_on_pod_b.person, public: public) ) } let(:entity_name) { :poll_participation_entity } @@ -127,7 +127,7 @@ shared_examples_for "messages which can't be send without sharing" do describe "retractions for non-relayable objects" do %w[status_message photo].each do |target| context "with #{target}" do - let(:target_object) { FactoryGirl.create(target.to_sym, author: remote_user_on_pod_b.person) } + let(:target_object) { FactoryBot.create(target.to_sym, author: remote_user_on_pod_b.person) } it_behaves_like "it retracts non-relayable object" end @@ -136,8 +136,8 @@ shared_examples_for "messages which can't be send without sharing" do describe "with messages which require a status to operate on" do let(:public) { recipient.nil? } - let(:local_parent) { FactoryGirl.create(:status_message, author: alice.person, public: public) } - let(:remote_parent) { FactoryGirl.create(:status_message, author: remote_user_on_pod_b.person, public: public) } + let(:local_parent) { FactoryBot.create(:status_message, author: alice.person, public: public) } + let(:remote_parent) { FactoryBot.create(:status_message, author: remote_user_on_pod_b.person, public: public) } # this one shouldn't depend on the sharing fact. this must be fixed describe "notifications are sent where required" do @@ -168,14 +168,14 @@ shared_examples_for "messages which can't be send without sharing" do it_behaves_like "it retracts relayable object" do # case for to-upstream federation let(:target_object) { - FactoryGirl.create(:comment, author: remote_user_on_pod_b.person, post: local_parent) + FactoryBot.create(:comment, author: remote_user_on_pod_b.person, post: local_parent) } end it_behaves_like "it retracts relayable object" do # case for to-downsteam federation let(:target_object) { - FactoryGirl.create(:comment, author: remote_user_on_pod_c.person, post: remote_parent) + FactoryBot.create(:comment, author: remote_user_on_pod_c.person, post: remote_parent) } end end @@ -184,14 +184,14 @@ shared_examples_for "messages which can't be send without sharing" do it_behaves_like "it retracts relayable object" do # case for to-upstream federation let(:target_object) { - FactoryGirl.create(:like, author: remote_user_on_pod_b.person, target: local_parent) + FactoryBot.create(:like, author: remote_user_on_pod_b.person, target: local_parent) } end it_behaves_like "it retracts relayable object" do # case for to-downsteam federation let(:target_object) { - FactoryGirl.create(:like, author: remote_user_on_pod_c.person, target: remote_parent) + FactoryBot.create(:like, author: remote_user_on_pod_c.person, target: remote_parent) } end end diff --git a/spec/integration/mentioning_spec.rb b/spec/integration/mentioning_spec.rb index 621d8281a..93ff270f7 100644 --- a/spec/integration/mentioning_spec.rb +++ b/spec/integration/mentioning_spec.rb @@ -138,9 +138,9 @@ describe "mentioning", type: :request do end end - let(:user1) { FactoryGirl.create(:user_with_aspect) } - let(:user2) { FactoryGirl.create(:user_with_aspect, friends: [user1, user3]) } - let(:user3) { FactoryGirl.create(:user_with_aspect) } + let(:user1) { FactoryBot.create(:user_with_aspect) } + let(:user2) { FactoryBot.create(:user_with_aspect, friends: [user1, user3]) } + let(:user3) { FactoryBot.create(:user_with_aspect) } # see: https://github.com/diaspora/diaspora/issues/4160 it "only mentions people that are in the target aspect" do @@ -226,18 +226,18 @@ describe "mentioning", type: :request do end context "in comments" do - let(:author) { FactoryGirl.create(:user_with_aspect) } + let(:author) { FactoryBot.create(:user_with_aspect) } shared_context "commenter is author" do let(:commenter) { author } end shared_context "commenter is author's friend" do - let(:commenter) { FactoryGirl.create(:user_with_aspect, friends: [author]) } + let(:commenter) { FactoryBot.create(:user_with_aspect, friends: [author]) } end shared_context "commenter is not author's friend" do - let(:commenter) { FactoryGirl.create(:user) } + let(:commenter) { FactoryBot.create(:user) } end shared_context "mentioned user is author" do @@ -245,15 +245,15 @@ describe "mentioning", type: :request do end shared_context "mentioned user is author's friend" do - let(:mentioned_user) { FactoryGirl.create(:user_with_aspect, friends: [author]) } + let(:mentioned_user) { FactoryBot.create(:user_with_aspect, friends: [author]) } end shared_context "mentioned user is not author's friend" do - let(:mentioned_user) { FactoryGirl.create(:user) } + let(:mentioned_user) { FactoryBot.create(:user) } end context "with public post" do - let(:status_msg) { FactoryGirl.create(:status_message, author: author.person, public: true) } + let(:status_msg) { FactoryBot.create(:status_message, author: author.person, public: true) } [ ["commenter is author's friend", "mentioned user is not author's friend"], @@ -281,7 +281,7 @@ describe "mentioning", type: :request do context "when comment is received via federation" do context "when mentioned user is remote" do it "relays the comment to the mentioned user" do - mentioned_person = FactoryGirl.create(:person) + mentioned_person = FactoryBot.create(:person) expect_any_instance_of(Diaspora::Federation::Dispatcher::Public) .to receive(:deliver_to_remote).with([mentioned_person]) @@ -301,7 +301,7 @@ describe "mentioning", type: :request do include_context commenters_context include_context mentioned_context - let(:parent) { FactoryGirl.create(:status_message_in_aspect, author: author.person) } + let(:parent) { FactoryBot.create(:status_message_in_aspect, author: author.person) } let(:comment) { inlined_jobs do commenter.comment!(parent, text_mentioning(mentioned_user)) @@ -318,7 +318,7 @@ describe "mentioning", type: :request do end context "when comment is received via federation" do - let(:parent) { FactoryGirl.create(:status_message_in_aspect, author: user2.person) } + let(:parent) { FactoryBot.create(:status_message_in_aspect, author: user2.person) } before do user3.like!(parent) @@ -355,7 +355,7 @@ describe "mentioning", type: :request do end context "commenter can't mention a non-participant" do - let(:status_msg) { FactoryGirl.create(:status_message_in_aspect, author: author.person) } + let(:status_msg) { FactoryBot.create(:status_message_in_aspect, author: author.person) } [ ["commenter is author's friend", "mentioned user is not author's friend"], @@ -381,8 +381,8 @@ describe "mentioning", type: :request do end it "only creates one notification for the mentioned person, when mentioned person commented twice before" do - parent = FactoryGirl.create(:status_message_in_aspect, author: author.person) - mentioned_user = FactoryGirl.create(:user_with_aspect, friends: [author]) + parent = FactoryBot.create(:status_message_in_aspect, author: author.person) + mentioned_user = FactoryBot.create(:user_with_aspect, friends: [author]) mentioned_user.comment!(parent, "test comment 1") mentioned_user.comment!(parent, "test comment 2") comment = inlined_jobs do diff --git a/spec/integration/migration_service_spec.rb b/spec/integration/migration_service_spec.rb index f4daf1645..e1f0b8d02 100644 --- a/spec/integration/migration_service_spec.rb +++ b/spec/integration/migration_service_spec.rb @@ -43,10 +43,10 @@ describe MigrationService do Fabricate(:like_entity, author: archive_author, author_signature: "ignored XXXXXXXXXXXXXXXXXXXXXXXXXXX", - parent_guid: FactoryGirl.create(:status_message).guid) + parent_guid: FactoryBot.create(:status_message).guid) } let(:poll_participation_entity) { - poll = FactoryGirl.create(:status_message_with_poll).poll + poll = FactoryBot.create(:status_message_with_poll).poll Fabricate(:poll_participation_entity, author: archive_author, author_signature: "ignored XXXXXXXXXXXXXXXXXXXXXXXXXXX", @@ -70,14 +70,14 @@ describe MigrationService do Fabricate(:comment_entity, data) } - let(:post_subscriber) { FactoryGirl.create(:person) } - let(:known_contact_person) { FactoryGirl.create(:person) } - let!(:collided_status_message) { FactoryGirl.create(:status_message, guid: colliding_status_message_entity.guid) } - let!(:collided_like) { FactoryGirl.create(:like, guid: like_entity.guid) } - let!(:reshare_root_author) { FactoryGirl.create(:person, diaspora_handle: reshare_entity.root_author) } + let(:post_subscriber) { FactoryBot.create(:person) } + let(:known_contact_person) { FactoryBot.create(:person) } + let!(:collided_status_message) { FactoryBot.create(:status_message, guid: colliding_status_message_entity.guid) } + let!(:collided_like) { FactoryBot.create(:like, guid: like_entity.guid) } + let!(:reshare_root_author) { FactoryBot.create(:person, diaspora_handle: reshare_entity.root_author) } # This is for testing migrated contacts handling - let(:account_migration) { FactoryGirl.create(:account_migration).tap(&:perform!) } + let(:account_migration) { FactoryBot.create(:account_migration).tap(&:perform!) } let(:migrated_contact_diaspora_id) { account_migration.old_person.diaspora_handle } let(:migrated_contact_new_diaspora_id) { account_migration.new_person.diaspora_handle } @@ -175,7 +175,7 @@ describe MigrationService do expect(DiasporaFederation::Federation::Fetcher) .to receive(:fetch_public) .with(root_author.diaspora_handle, "Post", root_guid) { - FactoryGirl.create(:status_message, guid: root_guid, author: root_author, public: true) + FactoryBot.create(:status_message, guid: root_guid, author: root_author, public: true) } end @@ -195,13 +195,13 @@ describe MigrationService do # This is expected to be called during relayable validation expect_relayable_parent_fetch(archive_author, comment_entity.parent_guid) { - FactoryGirl.create(:status_message, guid: comment_entity.parent_guid) + FactoryBot.create(:status_message, guid: comment_entity.parent_guid) } expect_relayable_parent_fetch(archive_author, unknown_poll_guid, "Poll") { - FactoryGirl.create( + FactoryBot.create( :poll_answer, - poll: FactoryGirl.create(:poll, guid: unknown_poll_guid), + poll: FactoryBot.create(:poll, guid: unknown_poll_guid), guid: unknown_poll_answer_guid ) } @@ -219,7 +219,7 @@ describe MigrationService do shared_examples "imports archive" do it "imports archive" do expect_relayable_parent_fetch(archive_author, unknown_subscription_guid) { - FactoryGirl.create(:status_message, guid: unknown_subscription_guid) + FactoryBot.create(:status_message, guid: unknown_subscription_guid) } expect_reshare_root_fetch(reshare_root_author, reshare_entity.root_guid) @@ -316,22 +316,22 @@ describe MigrationService do context "old user is a known remote user" do let(:old_person) { - FactoryGirl.create(:person, - profile: FactoryGirl.build(:profile), + FactoryBot.create(:person, + profile: FactoryBot.build(:profile), serialized_public_key: archive_private_key.public_key.export, diaspora_handle: archive_author) } # Some existing data for old_person to test data merge/migration - let!(:existing_contact) { FactoryGirl.create(:contact, person: old_person, sharing: true, receiving: true) } + let!(:existing_contact) { FactoryBot.create(:contact, person: old_person, sharing: true, receiving: true) } let!(:existing_subscription) { - FactoryGirl.create(:participation, + FactoryBot.create(:participation, author: old_person, - target: FactoryGirl.create(:status_message, guid: existing_subscription_guid)) + target: FactoryBot.create(:status_message, guid: existing_subscription_guid)) } let!(:existing_status_message) { - FactoryGirl.create(:status_message, + FactoryBot.create(:status_message, author: old_person, guid: known_status_message_entity.guid).tap {|status_message| status_message.participants << post_subscriber @@ -347,7 +347,7 @@ describe MigrationService do context "when account migration already exists" do before do setup_validation_time_expectations - FactoryGirl.create(:account_migration, old_person: old_person) + FactoryBot.create(:account_migration, old_person: old_person) end it "raises exception" do diff --git a/spec/integration/mobile_posts_spec.rb b/spec/integration/mobile_posts_spec.rb index f12f9cf07..cf6ddd8ea 100644 --- a/spec/integration/mobile_posts_spec.rb +++ b/spec/integration/mobile_posts_spec.rb @@ -2,7 +2,7 @@ describe PostsController, type: :request do context "with a poll" do - let(:sm) { FactoryGirl.build(:status_message_with_poll, public: true) } + let(:sm) { FactoryBot.build(:status_message_with_poll, public: true) } it "displays the poll" do get "/posts/#{sm.id}", params: {format: :mobile} @@ -23,7 +23,7 @@ describe PostsController, type: :request do end context "with a location" do - let(:sm) { FactoryGirl.build(:status_message_with_location, public: true) } + let(:sm) { FactoryBot.build(:status_message_with_location, public: true) } it "displays the location" do get "/posts/#{sm.id}", params: {format: :mobile} diff --git a/spec/integration/tag_people_spec.rb b/spec/integration/tag_people_spec.rb index 09ea0cb5b..663108d57 100644 --- a/spec/integration/tag_people_spec.rb +++ b/spec/integration/tag_people_spec.rb @@ -2,7 +2,7 @@ describe TagsController, type: :request do describe 'will_paginate people on the tag page' do - let(:people) { (1..2).map { FactoryGirl.create(:person) } } + let(:people) { (1..2).map { FactoryBot.create(:person) } } let(:tag) { "diaspora" } before do diff --git a/spec/lib/api/openid_connect/protected_resource_endpoint_spec.rb b/spec/lib/api/openid_connect/protected_resource_endpoint_spec.rb index 0419e4a8d..b82c494de 100644 --- a/spec/lib/api/openid_connect/protected_resource_endpoint_spec.rb +++ b/spec/lib/api/openid_connect/protected_resource_endpoint_spec.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true describe Api::OpenidConnect::ProtectedResourceEndpoint, type: :request do - let(:auth_with_read) { FactoryGirl.create(:auth_with_read_scopes) } + let(:auth_with_read) { FactoryBot.create(:auth_with_read_scopes) } let!(:access_token_with_read) { auth_with_read.create_access_token.to_s } let!(:expired_access_token) do access_token = auth_with_read.o_auth_access_tokens.create! diff --git a/spec/lib/api/openid_connect/token_endpoint_spec.rb b/spec/lib/api/openid_connect/token_endpoint_spec.rb index 0283cb0c9..6e4d5fef2 100644 --- a/spec/lib/api/openid_connect/token_endpoint_spec.rb +++ b/spec/lib/api/openid_connect/token_endpoint_spec.rb @@ -1,13 +1,13 @@ # frozen_string_literal: true describe Api::OpenidConnect::TokenEndpoint, type: :request do - let!(:client) { FactoryGirl.create(:o_auth_application_with_ppid) } + let!(:client) { FactoryBot.create(:o_auth_application_with_ppid) } let!(:auth) { Api::OpenidConnect::Authorization.find_or_create_by( o_auth_application: client, user: bob, redirect_uri: "http://localhost:3000/", scopes: ["openid"]) } let!(:code) { auth.create_code } - let!(:client_with_specific_id) { FactoryGirl.create(:o_auth_application_with_ppid) } + let!(:client_with_specific_id) { FactoryBot.create(:o_auth_application_with_ppid) } let!(:auth_with_specific_id) do client_with_specific_id.client_id = "14d692cd53d9c1a9f46fd69e0e57443e" client_with_specific_id.jwks = File.read(jwks_file_path) diff --git a/spec/lib/archive_importer/contact_importer_spec.rb b/spec/lib/archive_importer/contact_importer_spec.rb index e72a89c9d..083b266a1 100644 --- a/spec/lib/archive_importer/contact_importer_spec.rb +++ b/spec/lib/archive_importer/contact_importer_spec.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true describe ArchiveImporter::ContactImporter do - let(:target) { FactoryGirl.create(:user) } + let(:target) { FactoryBot.create(:user) } let(:contact_importer) { described_class.new(import_object, target) } describe "#import" do @@ -33,8 +33,8 @@ describe ArchiveImporter::ContactImporter do end context "with correct data" do - let(:aspect) { FactoryGirl.create(:aspect, user: target) } - let(:person) { FactoryGirl.create(:person) } + let(:aspect) { FactoryBot.create(:aspect, user: target) } + let(:person) { FactoryBot.create(:person) } let(:import_object) { { "person_guid" => person.guid, diff --git a/spec/lib/archive_importer/entity_importer_spec.rb b/spec/lib/archive_importer/entity_importer_spec.rb index ecc11b49a..d97e3e7dd 100644 --- a/spec/lib/archive_importer/entity_importer_spec.rb +++ b/spec/lib/archive_importer/entity_importer_spec.rb @@ -19,7 +19,7 @@ describe ArchiveImporter::EntityImporter do JSON context "with known author" do - let!(:author) { FactoryGirl.create(:person, diaspora_handle: "author@example.com") } + let!(:author) { FactoryBot.create(:person, diaspora_handle: "author@example.com") } it "runs entity receive routine" do expect(Diaspora::Federation::Receive).to receive(:perform) @@ -45,8 +45,8 @@ describe ArchiveImporter::EntityImporter do end context "with comment" do - let(:status_message) { FactoryGirl.create(:status_message) } - let(:author) { FactoryGirl.create(:user) } + let(:status_message) { FactoryBot.create(:status_message) } + let(:author) { FactoryBot.create(:user) } let(:comment_entity) { data = Fabricate.attributes_for(:comment_entity, author: author.diaspora_handle, @@ -68,12 +68,12 @@ describe ArchiveImporter::EntityImporter do end it "does not relay a remote comment during import" do - comment_author = FactoryGirl.build(:user) + comment_author = FactoryBot.build(:user) comment_author.person.owner = nil comment_author.person.pod = Pod.find_or_create_by(url: "http://example.net") comment_author.person.save! - status_message = FactoryGirl.create(:status_message, author: alice.person, public: true) + status_message = FactoryBot.create(:status_message, author: alice.person, public: true) comment_data = Fabricate.attributes_for(:comment_entity, author: comment_author.diaspora_handle, parent_guid: status_message.guid).tap do |data| diff --git a/spec/lib/archive_importer/own_entity_importer_shared.rb b/spec/lib/archive_importer/own_entity_importer_shared.rb index cdd81a7a5..dae3ee170 100644 --- a/spec/lib/archive_importer/own_entity_importer_shared.rb +++ b/spec/lib/archive_importer/own_entity_importer_shared.rb @@ -2,7 +2,7 @@ shared_examples "own entity importer" do describe "#import" do - let(:new_user) { FactoryGirl.create(:user) } + let(:new_user) { FactoryBot.create(:user) } let(:instance) { described_class.new(entity_json.as_json, new_user) } context "with known entity" do diff --git a/spec/lib/archive_importer/own_entity_importer_spec.rb b/spec/lib/archive_importer/own_entity_importer_spec.rb index ac5f67b2b..ace5fe80b 100644 --- a/spec/lib/archive_importer/own_entity_importer_spec.rb +++ b/spec/lib/archive_importer/own_entity_importer_spec.rb @@ -5,7 +5,7 @@ require "lib/archive_importer/own_entity_importer_shared" describe ArchiveImporter::OwnEntityImporter do it_behaves_like "own entity importer" do let(:entity_class) { StatusMessage } - let!(:status_message) { FactoryGirl.create(:status_message) } + let!(:status_message) { FactoryBot.create(:status_message) } let(:entity) { Diaspora::Federation::Entities.build(status_message) } let(:known_entity_with_correct_author) { @@ -14,7 +14,7 @@ describe ArchiveImporter::OwnEntityImporter do let(:known_entity_with_incorrect_author) { result = known_entity_with_correct_author - result[:entity_data][:author] = FactoryGirl.create(:person).diaspora_handle + result[:entity_data][:author] = FactoryBot.create(:person).diaspora_handle result } diff --git a/spec/lib/archive_importer/own_relayable_importer_spec.rb b/spec/lib/archive_importer/own_relayable_importer_spec.rb index 7cd141cd0..2de01b0e1 100644 --- a/spec/lib/archive_importer/own_relayable_importer_spec.rb +++ b/spec/lib/archive_importer/own_relayable_importer_spec.rb @@ -5,7 +5,7 @@ require "lib/archive_importer/own_entity_importer_shared" describe ArchiveImporter::OwnRelayableImporter do it_behaves_like "own entity importer" do let(:entity_class) { Comment } - let!(:comment) { FactoryGirl.create(:comment, author: FactoryGirl.create(:user).person) } + let!(:comment) { FactoryBot.create(:comment, author: FactoryBot.create(:user).person) } let(:known_entity_with_correct_author) { Diaspora::Federation::Entities.build(comment).to_json @@ -14,7 +14,7 @@ describe ArchiveImporter::OwnRelayableImporter do let(:known_entity_with_incorrect_author) { Fabricate( :comment_entity, - author: FactoryGirl.create(:user).diaspora_handle, + author: FactoryBot.create(:user).diaspora_handle, guid: comment.guid, parent_guid: comment.parent.guid ).to_json @@ -23,8 +23,8 @@ describe ArchiveImporter::OwnRelayableImporter do let(:unknown_entity) { Fabricate( :comment_entity, - author: FactoryGirl.create(:user).diaspora_handle, - parent_guid: FactoryGirl.create(:status_message).guid + author: FactoryBot.create(:user).diaspora_handle, + parent_guid: FactoryBot.create(:status_message).guid ).to_json } end diff --git a/spec/lib/archive_importer/post_importer_spec.rb b/spec/lib/archive_importer/post_importer_spec.rb index e7702a566..8361164a9 100644 --- a/spec/lib/archive_importer/post_importer_spec.rb +++ b/spec/lib/archive_importer/post_importer_spec.rb @@ -5,14 +5,14 @@ require "lib/archive_importer/own_entity_importer_shared" describe ArchiveImporter::PostImporter do describe "#import" do let(:old_person) { post.author } - let(:new_user) { FactoryGirl.create(:user) } + let(:new_user) { FactoryBot.create(:user) } let(:entity) { Diaspora::Federation::Entities.build(post) } let(:entity_json) { entity.to_json.as_json } let(:instance) { described_class.new(entity_json, new_user) } it_behaves_like "own entity importer" do let(:entity_class) { StatusMessage } - let!(:post) { FactoryGirl.create(:status_message) } + let!(:post) { FactoryBot.create(:status_message) } let(:known_entity_with_correct_author) { entity.to_json @@ -20,7 +20,7 @@ describe ArchiveImporter::PostImporter do let(:known_entity_with_incorrect_author) { result = known_entity_with_correct_author - result[:entity_data][:author] = FactoryGirl.create(:person).diaspora_handle + result[:entity_data][:author] = FactoryBot.create(:person).diaspora_handle result } @@ -33,8 +33,8 @@ describe ArchiveImporter::PostImporter do end context "with subscription" do - let(:post) { FactoryGirl.build(:status_message, public: true) } - let(:subscribed_person) { FactoryGirl.create(:person) } + let(:post) { FactoryBot.build(:status_message, public: true) } + let(:subscribed_person) { FactoryBot.create(:person) } let(:subscribed_person_id) { subscribed_person.diaspora_handle } before do @@ -66,7 +66,7 @@ describe ArchiveImporter::PostImporter do end context "when subscribed user has migrated" do - let(:account_migration) { FactoryGirl.create(:account_migration) } + let(:account_migration) { FactoryBot.create(:account_migration) } let(:subscribed_person) { account_migration.old_person } # TODO: rewrite this test when new subscription implementation is there diff --git a/spec/lib/archive_importer_spec.rb b/spec/lib/archive_importer_spec.rb index aa360c417..99858f147 100644 --- a/spec/lib/archive_importer_spec.rb +++ b/spec/lib/archive_importer_spec.rb @@ -4,7 +4,7 @@ require "integration/federation/federation_helper" describe ArchiveImporter do describe "#import" do - let(:target) { FactoryGirl.create(:user) } + let(:target) { FactoryBot.create(:user) } let(:archive_importer) { archive_importer = ArchiveImporter.new(archive_hash) archive_importer.user = target @@ -32,7 +32,7 @@ describe ArchiveImporter do end context "with subscription" do - let(:status_message) { FactoryGirl.create(:status_message) } + let(:status_message) { FactoryBot.create(:status_message) } let(:archive_hash) { { "user" => { diff --git a/spec/lib/archive_validator/author_private_key_validator_spec.rb b/spec/lib/archive_validator/author_private_key_validator_spec.rb index 2c93f7520..cbaae8a8e 100644 --- a/spec/lib/archive_validator/author_private_key_validator_spec.rb +++ b/spec/lib/archive_validator/author_private_key_validator_spec.rb @@ -6,7 +6,7 @@ describe ArchiveValidator::AuthorPrivateKeyValidator do include_context "validators shared context" context "when private key doesn't match the key in the archive" do - let(:author) { FactoryGirl.create(:person) } + let(:author) { FactoryBot.create(:person) } it "contains error" do expect(validator.messages) @@ -19,7 +19,7 @@ describe ArchiveValidator::AuthorPrivateKeyValidator do let(:author_pkey) { OpenSSL::PKey::RSA.generate(512) } let(:archive_private_key) { author_pkey.export } - let(:author) { FactoryGirl.create(:person, serialized_public_key: author_pkey.public_key.export) } + let(:author) { FactoryBot.create(:person, serialized_public_key: author_pkey.public_key.export) } include_examples "validation result is valid" end @@ -38,7 +38,7 @@ describe ArchiveValidator::AuthorPrivateKeyValidator do RSA let(:author) { - FactoryGirl.create(:person, serialized_public_key: <<~RSA) + FactoryBot.create(:person, serialized_public_key: <<~RSA) -----BEGIN RSA PUBLIC KEY----- MEgCQQDbMMJomgsvb5XguS+UrQnvPrq2/1CkMGKYXlgPgRUin/VSwU24C8FjHIKB lKi2kuka4XBlcZperynttJSxacThAgMBAAE= diff --git a/spec/lib/archive_validator/contact_validator_spec.rb b/spec/lib/archive_validator/contact_validator_spec.rb index a64365063..2c706f73b 100644 --- a/spec/lib/archive_validator/contact_validator_spec.rb +++ b/spec/lib/archive_validator/contact_validator_spec.rb @@ -17,7 +17,7 @@ describe ArchiveValidator::ContactValidator do end context "with a correct contact" do - let(:known_id) { FactoryGirl.create(:person).diaspora_handle } + let(:known_id) { FactoryBot.create(:person).diaspora_handle } before do include_in_input_archive( @@ -47,7 +47,7 @@ describe ArchiveValidator::ContactValidator do context "and discovery is successful" do before do expect_any_instance_of(DiasporaFederation::Discovery::Discovery).to receive(:fetch_and_save) { - FactoryGirl.create(:person, diaspora_handle: unknown_id) + FactoryBot.create(:person, diaspora_handle: unknown_id) } end @@ -72,7 +72,7 @@ describe ArchiveValidator::ContactValidator do end context "when person is deleted" do - let(:person) { FactoryGirl.create(:person) } + let(:person) { FactoryBot.create(:person) } let(:diaspora_id) { person.diaspora_handle } let(:contact) { @@ -95,7 +95,7 @@ describe ArchiveValidator::ContactValidator do end context "when person is migrated" do - let(:account_migration) { FactoryGirl.create(:account_migration).tap(&:perform!) } + let(:account_migration) { FactoryBot.create(:account_migration).tap(&:perform!) } let(:person) { account_migration.old_person } let(:diaspora_id) { person.diaspora_handle } diff --git a/spec/lib/archive_validator/contacts_validator_spec.rb b/spec/lib/archive_validator/contacts_validator_spec.rb index 0e4f3f485..f729436f7 100644 --- a/spec/lib/archive_validator/contacts_validator_spec.rb +++ b/spec/lib/archive_validator/contacts_validator_spec.rb @@ -7,7 +7,7 @@ describe ArchiveValidator::ContactsValidator do include_context "with known author" let(:correct_item) { - person = FactoryGirl.create(:person) + person = FactoryBot.create(:person) { "contact_groups_membership" => [], "person_guid" => person.guid, @@ -30,7 +30,7 @@ describe ArchiveValidator::ContactsValidator do } let(:incorrect_item) { - person = FactoryGirl.create(:person) + person = FactoryBot.create(:person) person.lock_access! { "contact_groups_membership" => [], diff --git a/spec/lib/archive_validator/own_relayable_validator_spec.rb b/spec/lib/archive_validator/own_relayable_validator_spec.rb index 35b3371d1..fed7e7683 100644 --- a/spec/lib/archive_validator/own_relayable_validator_spec.rb +++ b/spec/lib/archive_validator/own_relayable_validator_spec.rb @@ -7,14 +7,14 @@ describe ArchiveValidator::OwnRelayableValidator do include_context "relayable validator context" let(:relayable_entity) { :comment_entity } - let(:author) { FactoryGirl.create(:user).person } + let(:author) { FactoryBot.create(:user).person } let(:relayable_author) { author_id } def create_root - FactoryGirl.create(:status_message, guid: parent_guid) + FactoryBot.create(:status_message, guid: parent_guid) end before do @@ -32,7 +32,7 @@ describe ArchiveValidator::OwnRelayableValidator do expect(DiasporaFederation::Federation::Fetcher) .to receive(:fetch_public) .with(author.diaspora_handle, "Post", parent_guid) { - FactoryGirl.create(:status_message, guid: parent_guid) + FactoryBot.create(:status_message, guid: parent_guid) } end @@ -85,7 +85,7 @@ describe ArchiveValidator::OwnRelayableValidator do context "with known root" do def create_root - smwp = FactoryGirl.create(:status_message_with_poll) + smwp = FactoryBot.create(:status_message_with_poll) smwp.poll.update(guid: parent_guid) end @@ -100,7 +100,7 @@ describe ArchiveValidator::OwnRelayableValidator do expect(DiasporaFederation::Federation::Fetcher) .to receive(:fetch_public) .with(author.diaspora_handle, "Poll", parent_guid) { - FactoryGirl.create(:poll, guid: parent_guid) + FactoryBot.create(:poll, guid: parent_guid) } end diff --git a/spec/lib/archive_validator/posts_validator_spec.rb b/spec/lib/archive_validator/posts_validator_spec.rb index eca332ea8..5ecef5b7f 100644 --- a/spec/lib/archive_validator/posts_validator_spec.rb +++ b/spec/lib/archive_validator/posts_validator_spec.rb @@ -7,7 +7,7 @@ describe ArchiveValidator::PostsValidator do include_context "with known author" let(:correct_item) { - status_message = FactoryGirl.create(:status_message) + status_message = FactoryBot.create(:status_message) { "entity_data" => { "guid" => UUID.generate(:compact), diff --git a/spec/lib/archive_validator/relayable_validator_spec.rb b/spec/lib/archive_validator/relayable_validator_spec.rb index 1a9f366d7..bd442466c 100644 --- a/spec/lib/archive_validator/relayable_validator_spec.rb +++ b/spec/lib/archive_validator/relayable_validator_spec.rb @@ -6,7 +6,7 @@ describe ArchiveValidator::RelayableValidator do include_context "validators shared context" include_context "relayable validator context" - let(:author) { FactoryGirl.create(:user).person } + let(:author) { FactoryBot.create(:user).person } context "with comment" do let(:relayable_entity) { :comment_entity } diff --git a/spec/lib/archive_validator/relayables_validator_spec.rb b/spec/lib/archive_validator/relayables_validator_spec.rb index c635c67ab..c3d5945b9 100644 --- a/spec/lib/archive_validator/relayables_validator_spec.rb +++ b/spec/lib/archive_validator/relayables_validator_spec.rb @@ -6,7 +6,7 @@ describe ArchiveValidator::RelayablesValidator do include_context "validators shared context" include_context "with known author" - let(:parent_guid) { FactoryGirl.create(:status_message).guid } + let(:parent_guid) { FactoryBot.create(:status_message).guid } let(:not_found_guid) { UUID.generate(:compact).tap {|guid| stub_request(:get, "http://example.net/fetch/post/#{guid}").to_return(status: 404) diff --git a/spec/lib/archive_validator/shared.rb b/spec/lib/archive_validator/shared.rb index b5ea74635..8c4c3d6fd 100644 --- a/spec/lib/archive_validator/shared.rb +++ b/spec/lib/archive_validator/shared.rb @@ -45,7 +45,7 @@ shared_context "validators shared context" do end shared_context "with known author" do - let(:author) { FactoryGirl.create(:person) } + let(:author) { FactoryBot.create(:person) } end shared_examples "validation result is valid" do @@ -87,7 +87,7 @@ shared_examples "a relayable validator" do context "when the comment is already known" do let!(:original_comment) { - FactoryGirl.create(:comment, guid: guid, author: Person.by_account_identifier(relayable_author)) + FactoryBot.create(:comment, guid: guid, author: Person.by_account_identifier(relayable_author)) } include_examples "validation result is valid" diff --git a/spec/lib/diaspora/exporter/others_relayables_spec.rb b/spec/lib/diaspora/exporter/others_relayables_spec.rb index 5f1bc7f4c..d73ff35ef 100644 --- a/spec/lib/diaspora/exporter/others_relayables_spec.rb +++ b/spec/lib/diaspora/exporter/others_relayables_spec.rb @@ -1,12 +1,12 @@ # frozen_string_literal: true describe Diaspora::Exporter::OthersRelayables do - let(:status_message) { FactoryGirl.create(:status_message) } + let(:status_message) { FactoryBot.create(:status_message) } let(:person) { status_message.author } let(:instance) { Diaspora::Exporter::OthersRelayables.new(person.id) } describe "#comments" do - let(:comment) { FactoryGirl.create(:comment, post: status_message) } + let(:comment) { FactoryBot.create(:comment, post: status_message) } it "has a comment in the data set" do expect(instance.comments).to eq([comment]) @@ -14,7 +14,7 @@ describe Diaspora::Exporter::OthersRelayables do end describe "#likes" do - let(:like) { FactoryGirl.create(:like, target: status_message) } + let(:like) { FactoryBot.create(:like, target: status_message) } it "has a like in the data set" do expect(instance.likes).to eq([like]) @@ -22,9 +22,9 @@ describe Diaspora::Exporter::OthersRelayables do end describe "#poll_participations" do - let(:status_message) { FactoryGirl.create(:status_message_with_poll) } + let(:status_message) { FactoryBot.create(:status_message_with_poll) } let(:poll_participation) { - FactoryGirl.create( + FactoryBot.create( :poll_participation, poll_answer: status_message.poll.poll_answers.first ) diff --git a/spec/lib/diaspora/exporter_spec.rb b/spec/lib/diaspora/exporter_spec.rb index 6a9b1056f..d65800660 100644 --- a/spec/lib/diaspora/exporter_spec.rb +++ b/spec/lib/diaspora/exporter_spec.rb @@ -6,7 +6,7 @@ describe Diaspora::Exporter do expect_any_instance_of(Export::UserSerializer).to receive(:as_json).and_return(user: "user_data") expect_any_instance_of(Export::OthersDataSerializer).to receive(:as_json).and_return(others_date: "others_data") - json = Diaspora::Exporter.new(FactoryGirl.create(:user)).execute + json = Diaspora::Exporter.new(FactoryBot.create(:user)).execute expect(json).to include_json( version: "2.0", user: "user_data", diff --git a/spec/lib/diaspora/federated/contact_retraction_spec.rb b/spec/lib/diaspora/federated/contact_retraction_spec.rb index 04e19ea1c..c24b35b5b 100644 --- a/spec/lib/diaspora/federated/contact_retraction_spec.rb +++ b/spec/lib/diaspora/federated/contact_retraction_spec.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true describe ContactRetraction do - let(:contact) { FactoryGirl.build(:contact, sharing: true, receiving: true) } + let(:contact) { FactoryBot.build(:contact, sharing: true, receiving: true) } let(:retraction) { ContactRetraction.for(contact) } describe "#subscribers" do @@ -22,7 +22,7 @@ describe ContactRetraction do describe ".retraction_data_for" do it "creates a retraction for a contact" do - contact = FactoryGirl.build(:contact, sharing: false, receiving: false) + contact = FactoryBot.build(:contact, sharing: false, receiving: false) expect(Diaspora::Federation::Entities).to receive(:contact).with(contact).and_call_original data = ContactRetraction.retraction_data_for(contact) @@ -48,7 +48,7 @@ describe ContactRetraction do describe ".defer_dispatch" do it "queues a job to send the retraction later" do - contact = FactoryGirl.build(:contact, user: local_luke, person: remote_raphael) + contact = FactoryBot.build(:contact, user: local_luke, person: remote_raphael) retraction = ContactRetraction.for(contact) federation_retraction_data = Diaspora::Federation::Entities.contact(contact).to_h diff --git a/spec/lib/diaspora/federated/retraction_spec.rb b/spec/lib/diaspora/federated/retraction_spec.rb index ff1149064..615de2a42 100644 --- a/spec/lib/diaspora/federated/retraction_spec.rb +++ b/spec/lib/diaspora/federated/retraction_spec.rb @@ -37,7 +37,7 @@ describe Retraction do end it "creates the retraction data for a relayable" do - comment = FactoryGirl.create(:comment, author: alice.person, post: post) + comment = FactoryBot.create(:comment, author: alice.person, post: post) data = Retraction.retraction_data_for(comment) expect(data[:target_guid]).to eq(comment.guid) @@ -55,7 +55,7 @@ describe Retraction do end it "creates a retraction for a relayable" do - comment = FactoryGirl.create(:comment, author: alice.person, post: post) + comment = FactoryBot.create(:comment, author: alice.person, post: post) expect(Retraction).to receive(:retraction_data_for).with(comment) @@ -117,7 +117,7 @@ describe Retraction do context "relayable" do let(:post) { local_luke.post(:status_message, text: "hello", public: true) } - let(:comment) { FactoryGirl.create(:comment, post: post, author: remote_raphael) } + let(:comment) { FactoryBot.create(:comment, post: post, author: remote_raphael) } it "sends retraction to target author if deleted by parent author" do retraction = Retraction.for(comment) @@ -161,7 +161,7 @@ describe Retraction do end it "returns true for a public comment if parent post is not local" do - remote_post = FactoryGirl.create(:status_message, author: remote_raphael, public: true) + remote_post = FactoryBot.create(:status_message, author: remote_raphael, public: true) comment = alice.comment!(remote_post, "destroy!") expect(Retraction.for(comment).public?).to be_truthy end diff --git a/spec/lib/diaspora/federation/dispatcher/private_spec.rb b/spec/lib/diaspora/federation/dispatcher/private_spec.rb index a5453023b..e8d9beb02 100644 --- a/spec/lib/diaspora/federation/dispatcher/private_spec.rb +++ b/spec/lib/diaspora/federation/dispatcher/private_spec.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true describe Diaspora::Federation::Dispatcher::Private do - let(:post) { FactoryGirl.create(:status_message, author: alice.person, text: "hello", public: false) } - let(:comment) { FactoryGirl.create(:comment, author: alice.person, post: post) } + let(:post) { FactoryBot.create(:status_message, author: alice.person, text: "hello", public: false) } + let(:comment) { FactoryBot.create(:comment, author: alice.person, post: post) } before do alice.share_with(remote_raphael, alice.aspects.first) @@ -16,7 +16,7 @@ describe Diaspora::Federation::Dispatcher::Private do aspect2 = alice.aspects.create(name: "cat people") alice.add_contact_to_aspect(alice.contact_for(bob.person), aspect2) - post = FactoryGirl.create( + post = FactoryBot.create( :status_message, author: alice.person, text: "hello", @@ -58,7 +58,7 @@ describe Diaspora::Federation::Dispatcher::Private do end it "does not queue a private send job when no remote recipients specified" do - bobs_post = FactoryGirl.create(:status_message, author: alice.person, text: "hello", public: false) + bobs_post = FactoryBot.create(:status_message, author: alice.person, text: "hello", public: false) bob.add_to_streams(bobs_post, [bob.aspects.first]) expect(Workers::SendPrivate).not_to receive(:perform_async) @@ -67,7 +67,7 @@ describe Diaspora::Federation::Dispatcher::Private do end it "queues private send job for a specific subscriber" do - remote_person = FactoryGirl.create(:person) + remote_person = FactoryBot.create(:person) expect(Workers::SendPrivate).to receive(:perform_async) do |user_id, _entity_string, targets| expect(user_id).to eq(alice.id) @@ -91,9 +91,9 @@ describe Diaspora::Federation::Dispatcher::Private do end it "only queues a private send job for a active pods" do - remote_person = FactoryGirl.create(:person) - offline_pod = FactoryGirl.create(:pod, status: :net_failed, offline_since: DateTime.now.utc - 15.days) - offline_person = FactoryGirl.create(:person, pod: offline_pod) + remote_person = FactoryBot.create(:person) + offline_pod = FactoryBot.create(:pod, status: :net_failed, offline_since: DateTime.now.utc - 15.days) + offline_person = FactoryBot.create(:person, pod: offline_pod) expect(Workers::SendPrivate).to receive(:perform_async) do |user_id, _entity_string, targets| expect(user_id).to eq(alice.id) diff --git a/spec/lib/diaspora/federation/dispatcher/public_spec.rb b/spec/lib/diaspora/federation/dispatcher/public_spec.rb index 6efc8716f..a14ae8d7b 100644 --- a/spec/lib/diaspora/federation/dispatcher/public_spec.rb +++ b/spec/lib/diaspora/federation/dispatcher/public_spec.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true describe Diaspora::Federation::Dispatcher::Public do - let(:post) { FactoryGirl.create(:status_message, author: alice.person, text: "hello", public: true) } - let(:comment) { FactoryGirl.create(:comment, author: alice.person, post: post) } + let(:post) { FactoryBot.create(:status_message, author: alice.person, text: "hello", public: true) } + let(:comment) { FactoryBot.create(:comment, author: alice.person, post: post) } describe "#dispatch" do context "pubsubhubbub" do @@ -96,8 +96,8 @@ describe Diaspora::Federation::Dispatcher::Public do end it "only queues a public send job for a active pods" do - offline_pod = FactoryGirl.create(:pod, status: :net_failed, offline_since: DateTime.now.utc - 15.days) - offline_person = FactoryGirl.create(:person, pod: offline_pod) + offline_pod = FactoryBot.create(:pod, status: :net_failed, offline_since: DateTime.now.utc - 15.days) + offline_person = FactoryBot.create(:person, pod: offline_pod) expect(Workers::SendPublic).to receive(:perform_async) do |user_id, _entity_string, urls, xml| expect(user_id).to eq(alice.id) diff --git a/spec/lib/diaspora/federation/dispatcher_spec.rb b/spec/lib/diaspora/federation/dispatcher_spec.rb index a4faa0ab9..2b11d6363 100644 --- a/spec/lib/diaspora/federation/dispatcher_spec.rb +++ b/spec/lib/diaspora/federation/dispatcher_spec.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true describe Diaspora::Federation::Dispatcher do - let(:post) { FactoryGirl.create(:status_message, author: alice.person, text: "hello", public: true) } + let(:post) { FactoryBot.create(:status_message, author: alice.person, text: "hello", public: true) } let(:opts) { {service_types: "Services::Twitter"} } describe ".build" do @@ -14,7 +14,7 @@ describe Diaspora::Federation::Dispatcher do end it "creates a private dispatcher for a private post" do - private = FactoryGirl.create(:status_message, author: alice.person, text: "hello", public: false) + private = FactoryBot.create(:status_message, author: alice.person, text: "hello", public: false) expect(Diaspora::Federation::Dispatcher::Private).to receive(:new).with(alice, private, opts).and_call_original @@ -34,7 +34,7 @@ describe Diaspora::Federation::Dispatcher do end it "uses the parent author as sender for a comment if the parent is local" do - comment = FactoryGirl.create(:comment, author: bob.person, post: post) + comment = FactoryBot.create(:comment, author: bob.person, post: post) expect(Diaspora::Federation::Dispatcher::Public).to receive(:new).with(alice, comment, {}).and_call_original @@ -44,8 +44,8 @@ describe Diaspora::Federation::Dispatcher do end it "uses the original sender for a comment if the parent is not local" do - remote_post = FactoryGirl.create(:status_message, author: remote_raphael, text: "hello", public: true) - comment = FactoryGirl.create(:comment, author: bob.person, post: remote_post) + remote_post = FactoryBot.create(:status_message, author: remote_raphael, text: "hello", public: true) + comment = FactoryBot.create(:comment, author: bob.person, post: remote_post) expect(Diaspora::Federation::Dispatcher::Public).to receive(:new).with(bob, comment, {}).and_call_original diff --git a/spec/lib/diaspora/federation/entities_spec.rb b/spec/lib/diaspora/federation/entities_spec.rb index 03f625573..7a1fac6ea 100644 --- a/spec/lib/diaspora/federation/entities_spec.rb +++ b/spec/lib/diaspora/federation/entities_spec.rb @@ -3,7 +3,7 @@ describe Diaspora::Federation::Entities do describe ".build" do it "builds an account deletion" do - diaspora_entity = FactoryGirl.build(:account_deletion) + diaspora_entity = FactoryBot.build(:account_deletion) federation_entity = described_class.build(diaspora_entity) expect(federation_entity).to be_instance_of(DiasporaFederation::Entities::AccountDeletion) @@ -11,7 +11,7 @@ describe Diaspora::Federation::Entities do end it "builds an account migration" do - diaspora_entity = FactoryGirl.build(:account_migration) + diaspora_entity = FactoryBot.build(:account_migration) diaspora_entity.old_private_key = OpenSSL::PKey::RSA.generate(1024).export federation_entity = described_class.build(diaspora_entity) @@ -21,7 +21,7 @@ describe Diaspora::Federation::Entities do end it "builds a comment" do - diaspora_entity = FactoryGirl.build(:comment) + diaspora_entity = FactoryBot.build(:comment) federation_entity = described_class.build(diaspora_entity) expect(federation_entity).to be_instance_of(DiasporaFederation::Entities::Comment) @@ -35,7 +35,7 @@ describe Diaspora::Federation::Entities do end it "builds a comment with signature" do - diaspora_entity = FactoryGirl.build(:comment, signature: FactoryGirl.build(:comment_signature)) + diaspora_entity = FactoryBot.build(:comment, signature: FactoryBot.build(:comment_signature)) federation_entity = described_class.build(diaspora_entity) expect(federation_entity).to be_instance_of(DiasporaFederation::Entities::Comment) @@ -51,9 +51,9 @@ describe Diaspora::Federation::Entities do it "builds a comment with edited_at" do edited_at = Time.now.utc + 3600 - diaspora_entity = FactoryGirl.build( + diaspora_entity = FactoryBot.build( :comment, - signature: FactoryGirl.build(:comment_signature, additional_data: {"edited_at" => edited_at}) + signature: FactoryBot.build(:comment_signature, additional_data: {"edited_at" => edited_at}) ) federation_entity = described_class.build(diaspora_entity) @@ -70,7 +70,7 @@ describe Diaspora::Federation::Entities do end it "builds a contact" do - diaspora_entity = FactoryGirl.build(:contact, receiving: true) + diaspora_entity = FactoryBot.build(:contact, receiving: true) federation_entity = described_class.build(diaspora_entity) expect(federation_entity).to be_instance_of(DiasporaFederation::Entities::Contact) @@ -82,7 +82,7 @@ describe Diaspora::Federation::Entities do end it "builds a contact for a block" do - diaspora_entity = FactoryGirl.create(:block) + diaspora_entity = FactoryBot.create(:block) federation_entity = described_class.build(diaspora_entity) expect(federation_entity).to be_instance_of(DiasporaFederation::Entities::Contact) @@ -94,8 +94,8 @@ describe Diaspora::Federation::Entities do end context "Conversation" do - let(:participant) { FactoryGirl.create(:person) } - let(:diaspora_entity) { FactoryGirl.create(:conversation_with_message, participants: [participant]) } + let(:participant) { FactoryBot.create(:person) } + let(:diaspora_entity) { FactoryBot.create(:conversation_with_message, participants: [participant]) } let(:federation_entity) { described_class.build(diaspora_entity) } it "builds a conversation" do @@ -124,7 +124,7 @@ describe Diaspora::Federation::Entities do end it "builds a like" do - diaspora_entity = FactoryGirl.build(:like) + diaspora_entity = FactoryBot.build(:like) federation_entity = described_class.build(diaspora_entity) expect(federation_entity).to be_instance_of(DiasporaFederation::Entities::Like) @@ -137,7 +137,7 @@ describe Diaspora::Federation::Entities do end it "builds a like with signature" do - diaspora_entity = FactoryGirl.build(:like, signature: FactoryGirl.build(:like_signature)) + diaspora_entity = FactoryBot.build(:like, signature: FactoryBot.build(:like_signature)) federation_entity = described_class.build(diaspora_entity) expect(federation_entity).to be_instance_of(DiasporaFederation::Entities::Like) @@ -151,7 +151,7 @@ describe Diaspora::Federation::Entities do end it "builds a message" do - diaspora_entity = FactoryGirl.create(:message) + diaspora_entity = FactoryBot.create(:message) federation_entity = described_class.build(diaspora_entity) expect(federation_entity).to be_instance_of(DiasporaFederation::Entities::Message) @@ -163,7 +163,7 @@ describe Diaspora::Federation::Entities do end it "builds a participation" do - diaspora_entity = FactoryGirl.build(:participation) + diaspora_entity = FactoryBot.build(:participation) federation_entity = described_class.build(diaspora_entity) expect(federation_entity).to be_instance_of(DiasporaFederation::Entities::Participation) @@ -174,7 +174,7 @@ describe Diaspora::Federation::Entities do end it "builds a photo" do - diaspora_entity = FactoryGirl.create(:photo) + diaspora_entity = FactoryBot.create(:photo) federation_entity = described_class.build(diaspora_entity) expect(federation_entity).to be_instance_of(DiasporaFederation::Entities::Photo) @@ -190,7 +190,7 @@ describe Diaspora::Federation::Entities do end it "builds a poll participation" do - diaspora_entity = FactoryGirl.build(:poll_participation) + diaspora_entity = FactoryBot.build(:poll_participation) federation_entity = described_class.build(diaspora_entity) expect(federation_entity).to be_instance_of(DiasporaFederation::Entities::PollParticipation) @@ -203,8 +203,8 @@ describe Diaspora::Federation::Entities do end it "builds a poll participation with signature" do - signature = FactoryGirl.build(:poll_participation_signature) - diaspora_entity = FactoryGirl.build(:poll_participation, signature: signature) + signature = FactoryBot.build(:poll_participation_signature) + diaspora_entity = FactoryBot.build(:poll_participation, signature: signature) federation_entity = described_class.build(diaspora_entity) expect(federation_entity).to be_instance_of(DiasporaFederation::Entities::PollParticipation) @@ -218,7 +218,7 @@ describe Diaspora::Federation::Entities do end it "builds a profile" do - diaspora_entity = FactoryGirl.build(:profile_with_image_url) + diaspora_entity = FactoryBot.build(:profile_with_image_url) federation_entity = described_class.build(diaspora_entity) expect(federation_entity).to be_instance_of(DiasporaFederation::Entities::Profile) @@ -240,7 +240,7 @@ describe Diaspora::Federation::Entities do end it "builds a reshare" do - diaspora_entity = FactoryGirl.create(:reshare) + diaspora_entity = FactoryBot.create(:reshare) federation_entity = described_class.build(diaspora_entity) expect(federation_entity).to be_instance_of(DiasporaFederation::Entities::Reshare) @@ -253,7 +253,7 @@ describe Diaspora::Federation::Entities do context "Retraction" do it "builds a Retraction entity for a Photo retraction" do - target = FactoryGirl.create(:photo, author: alice.person) + target = FactoryBot.create(:photo, author: alice.person) retraction = Retraction.for(target) federation_entity = described_class.build(retraction) @@ -264,7 +264,7 @@ describe Diaspora::Federation::Entities do end it "builds a Contact for a Contact retraction" do - target = FactoryGirl.create(:contact, receiving: false) + target = FactoryBot.create(:contact, receiving: false) retraction = ContactRetraction.for(target) federation_entity = described_class.build(retraction) @@ -277,8 +277,8 @@ describe Diaspora::Federation::Entities do end it "builds a Contact for a Contact retraction with block" do - target = FactoryGirl.create(:contact, receiving: false) - FactoryGirl.create(:block, user: target.user, person: target.person) + target = FactoryBot.create(:contact, receiving: false) + FactoryBot.create(:block, user: target.user, person: target.person) retraction = ContactRetraction.for(target) federation_entity = described_class.build(retraction) @@ -291,7 +291,7 @@ describe Diaspora::Federation::Entities do end it "builds a Contact for a Block retraction" do - target = FactoryGirl.create(:block) + target = FactoryBot.create(:block) target.delete retraction = ContactRetraction.for(target) federation_entity = described_class.build(retraction) @@ -307,7 +307,7 @@ describe Diaspora::Federation::Entities do context "StatusMessage" do it "builds a status message" do - diaspora_entity = FactoryGirl.create(:status_message) + diaspora_entity = FactoryBot.create(:status_message) federation_entity = described_class.build(diaspora_entity) expect(federation_entity).to be_instance_of(DiasporaFederation::Entities::StatusMessage) @@ -324,7 +324,7 @@ describe Diaspora::Federation::Entities do end it "includes the photos" do - diaspora_entity = FactoryGirl.create(:status_message_with_photo) + diaspora_entity = FactoryBot.create(:status_message_with_photo) diaspora_photo = diaspora_entity.photos.first federation_entity = described_class.build(diaspora_entity) federation_photo = federation_entity.photos.first @@ -342,7 +342,7 @@ describe Diaspora::Federation::Entities do end it "includes the location" do - diaspora_entity = FactoryGirl.create(:status_message_with_location) + diaspora_entity = FactoryBot.create(:status_message_with_location) diaspora_location = diaspora_entity.location federation_entity = described_class.build(diaspora_entity) federation_location = federation_entity.location @@ -353,7 +353,7 @@ describe Diaspora::Federation::Entities do end it "includes the poll" do - diaspora_entity = FactoryGirl.create(:status_message_with_poll) + diaspora_entity = FactoryBot.create(:status_message_with_poll) diaspora_poll = diaspora_entity.poll federation_entity = described_class.build(diaspora_entity) federation_poll = federation_entity.poll diff --git a/spec/lib/diaspora/federation/receive_spec.rb b/spec/lib/diaspora/federation/receive_spec.rb index 9e345dc25..00c8d9e7f 100644 --- a/spec/lib/diaspora/federation/receive_spec.rb +++ b/spec/lib/diaspora/federation/receive_spec.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true describe Diaspora::Federation::Receive do - let(:sender) { FactoryGirl.create(:person) } - let(:post) { FactoryGirl.create(:status_message, text: "hello", public: true, author: alice.person) } + let(:sender) { FactoryBot.create(:person) } + let(:post) { FactoryBot.create(:status_message, text: "hello", public: true, author: alice.person) } describe ".account_deletion" do let(:account_deletion_entity) { Fabricate(:account_deletion_entity, author: sender.diaspora_handle) } @@ -36,7 +36,7 @@ describe Diaspora::Federation::Receive do end describe ".account_migration" do - let(:new_person) { FactoryGirl.create(:person) } + let(:new_person) { FactoryBot.create(:person) } let(:profile_entity) { Fabricate(:profile_entity, author: new_person.diaspora_handle) } let(:account_migration_entity) { Fabricate(:account_migration_entity, author: sender.diaspora_handle, profile: profile_entity) @@ -288,7 +288,7 @@ describe Diaspora::Federation::Receive do it_behaves_like "it relays relayables", Like context "like for a comment" do - let(:comment) { FactoryGirl.create(:comment, post: post) } + let(:comment) { FactoryBot.create(:comment, post: post) } let(:like_entity) { build_relayable_federation_entity( :like, @@ -331,7 +331,7 @@ describe Diaspora::Federation::Receive do describe ".message" do let(:conversation) { - FactoryGirl.build(:conversation, author: alice.person).tap do |conv| + FactoryBot.build(:conversation, author: alice.person).tap do |conv| conv.participants << sender conv.save! end @@ -446,7 +446,7 @@ describe Diaspora::Federation::Receive do end describe ".poll_participation" do - let(:post_with_poll) { FactoryGirl.create(:status_message_with_poll, author: alice.person) } + let(:post_with_poll) { FactoryBot.create(:status_message_with_poll, author: alice.person) } let(:poll_participation_entity) { build_relayable_federation_entity( :poll_participation, @@ -550,7 +550,7 @@ describe Diaspora::Federation::Receive do describe ".retraction" do it "destroys the post" do - remote_post = FactoryGirl.create(:status_message, author: sender, public: true) + remote_post = FactoryBot.create(:status_message, author: sender, public: true) retraction = Fabricate( :retraction_entity, @@ -594,8 +594,8 @@ describe Diaspora::Federation::Receive do context "Relayable" do it "relays the retraction and destroys the relayable when the parent-author is local" do - local_post = FactoryGirl.create(:status_message, author: alice.person, public: true) - remote_comment = FactoryGirl.create(:comment, author: sender, post: local_post) + local_post = FactoryBot.create(:status_message, author: alice.person, public: true) + remote_comment = FactoryBot.create(:comment, author: sender, post: local_post) retraction = Fabricate( :retraction_entity, @@ -617,8 +617,8 @@ describe Diaspora::Federation::Receive do end it "destroys the relayable when the parent-author is not local" do - remote_post = FactoryGirl.create(:status_message, author: sender, public: true) - remote_comment = FactoryGirl.create(:comment, author: sender, post: remote_post) + remote_post = FactoryBot.create(:status_message, author: sender, public: true) + remote_comment = FactoryBot.create(:comment, author: sender, post: remote_post) retraction = Fabricate( :retraction_entity, diff --git a/spec/lib/diaspora/fetcher/public_spec.rb b/spec/lib/diaspora/fetcher/public_spec.rb index 58f751ef7..38749a2d7 100644 --- a/spec/lib/diaspora/fetcher/public_spec.rb +++ b/spec/lib/diaspora/fetcher/public_spec.rb @@ -12,7 +12,7 @@ describe Diaspora::Fetcher::Public do # the guid of the person is "7445f9a0a6c28ebb" @fixture = File.open(Rails.root.join('spec', 'fixtures', 'public_posts.json')).read @fetcher = Diaspora::Fetcher::Public.new - @person = FactoryGirl.create(:person, guid: "7445f9a0a6c28ebb", + @person = FactoryBot.create(:person, guid: "7445f9a0a6c28ebb", pod: Pod.find_or_create_by(url: "https://remote-testpod.net"), diaspora_handle: "testuser@remote-testpod.net") @@ -154,13 +154,13 @@ describe Diaspora::Fetcher::Public do it 'returns false if the person is unfetchable' do expect(public_fetcher.instance_eval { - @person = FactoryGirl.create(:person, {:fetch_status => Diaspora::Fetcher::Public::Status_Unfetchable}) + @person = FactoryBot.create(:person, {:fetch_status => Diaspora::Fetcher::Public::Status_Unfetchable}) qualifies_for_fetching? }).to be false end it 'returns false and sets the person unfetchable for a local account' do - user = FactoryGirl.create(:user) + user = FactoryBot.create(:user) expect(public_fetcher.instance_eval { @person = user.person qualifies_for_fetching? @@ -169,7 +169,7 @@ describe Diaspora::Fetcher::Public do end it 'returns false if the person is processing already (or has been processed)' do - person = FactoryGirl.create(:person) + person = FactoryBot.create(:person) person.fetch_status = Diaspora::Fetcher::Public::Status_Fetched person.save expect(public_fetcher.instance_eval { @@ -179,7 +179,7 @@ describe Diaspora::Fetcher::Public do end it "returns true, if the user is remote and hasn't been fetched" do - person = FactoryGirl.create(:person, {:diaspora_handle => 'neo@theone.net'}) + person = FactoryBot.create(:person, {:diaspora_handle => 'neo@theone.net'}) expect(public_fetcher.instance_eval { @person = person qualifies_for_fetching? @@ -216,7 +216,7 @@ describe Diaspora::Fetcher::Public do describe '#check_existing' do it 'returns false if a post with the same guid exists' do - post = {'guid' => FactoryGirl.create(:status_message).guid} + post = {'guid' => FactoryBot.create(:status_message).guid} expect(public_fetcher.instance_eval { check_existing post }).to be false end @@ -227,7 +227,7 @@ describe Diaspora::Fetcher::Public do end describe '#check_author' do - let!(:some_person) { FactoryGirl.create(:person) } + let!(:some_person) { FactoryBot.create(:person) } before do person = some_person diff --git a/spec/lib/diaspora/mentionable_spec.rb b/spec/lib/diaspora/mentionable_spec.rb index c6a11f2ba..63a065ed5 100644 --- a/spec/lib/diaspora/mentionable_spec.rb +++ b/spec/lib/diaspora/mentionable_spec.rb @@ -150,7 +150,7 @@ STR end it "fetches unknown handles" do - person = FactoryGirl.build(:person) + person = FactoryBot.build(:person) expect(Person).to receive(:find_or_fetch_by_identifier).with("xxx@xxx.xx").and_return(person) ppl = Diaspora::Mentionable.people_from_string("@{a; xxx@xxx.xx}") expect(ppl).to eq([person]) @@ -166,9 +166,9 @@ STR end describe ".filter_people" do - let(:user_a) { FactoryGirl.create(:user_with_aspect, username: "user_a") } - let(:user_b) { FactoryGirl.create(:user, username: "user_b") } - let(:user_c) { FactoryGirl.create(:user, username: "user_c") } + let(:user_a) { FactoryBot.create(:user_with_aspect, username: "user_a") } + let(:user_b) { FactoryBot.create(:user, username: "user_b") } + let(:user_c) { FactoryBot.create(:user, username: "user_c") } before do user_a.aspects.create!(name: "second") diff --git a/spec/lib/diaspora/message_renderer_spec.rb b/spec/lib/diaspora/message_renderer_spec.rb index 248563ed8..2477a917d 100644 --- a/spec/lib/diaspora/message_renderer_spec.rb +++ b/spec/lib/diaspora/message_renderer_spec.rb @@ -98,7 +98,7 @@ describe Diaspora::MessageRenderer do context "with diaspora:// links" do it "replaces diaspora:// links with pod-local links" do - target = FactoryGirl.create(:status_message) + target = FactoryBot.create(:status_message) expect( message("Have a look at diaspora://#{target.diaspora_handle}/post/#{target.guid}.").html ).to match(/Have a look at #{AppConfig.url_to("/posts/#{target.guid}")}./) @@ -115,7 +115,7 @@ describe Diaspora::MessageRenderer do end it "ignores a diaspora:// links with an invalid entity type" do - target = FactoryGirl.create(:status_message) + target = FactoryBot.create(:status_message) text = "Try this: `diaspora://#{target.diaspora_handle}/posts/#{target.guid}`" expect(message(text).html).to match(/#{text}/) end @@ -180,7 +180,7 @@ describe Diaspora::MessageRenderer do end it "should leave mentions intact for real diaspora handles" do - new_person = FactoryGirl.create(:person, diaspora_handle: 'maxwell@joindiaspora.com') + new_person = FactoryBot.create(:person, diaspora_handle: 'maxwell@joindiaspora.com') expect( message( "Hey @{maxwell@joindiaspora.com; #{new_person.diaspora_handle}}!", @@ -206,8 +206,8 @@ describe Diaspora::MessageRenderer do context "with diaspora:// links" do it "replaces diaspora:// links with pod-local links" do - target1 = FactoryGirl.create(:status_message) - target2 = FactoryGirl.create(:status_message) + target1 = FactoryBot.create(:status_message) + target2 = FactoryBot.create(:status_message) text = "Have a look at [this post](diaspora://#{target1.diaspora_handle}/post/#{target1.guid}) and " \ "this one too diaspora://#{target2.diaspora_handle}/post/#{target2.guid}." @@ -255,8 +255,8 @@ describe Diaspora::MessageRenderer do context "with diaspora:// links" do it "replaces diaspora:// links with pod-local links" do - target1 = FactoryGirl.create(:status_message) - target2 = FactoryGirl.create(:status_message) + target1 = FactoryBot.create(:status_message) + target2 = FactoryBot.create(:status_message) text = "Have a look at [this post](diaspora://#{target1.diaspora_handle}/post/#{target1.guid}) and " \ "this one too diaspora://#{target2.diaspora_handle}/post/#{target2.guid}." @@ -312,8 +312,8 @@ describe Diaspora::MessageRenderer do context "with diaspora:// links" do it "replaces diaspora:// links with pod-local links" do - target1 = FactoryGirl.create(:status_message) - target2 = FactoryGirl.create(:status_message) + target1 = FactoryBot.create(:status_message) + target2 = FactoryBot.create(:status_message) text = "Have a look at [this post](diaspora://#{target1.diaspora_handle}/post/#{target1.guid}) and " \ "this one too diaspora://#{target2.diaspora_handle}/post/#{target2.guid}." diff --git a/spec/lib/evil_query_spec.rb b/spec/lib/evil_query_spec.rb index d83f8cbc8..2fc99deda 100644 --- a/spec/lib/evil_query_spec.rb +++ b/spec/lib/evil_query_spec.rb @@ -47,7 +47,7 @@ end describe EvilQuery::Participation do before do - @status_message = FactoryGirl.create(:status_message, :author => bob.person) + @status_message = FactoryBot.create(:status_message, :author => bob.person) end it "includes posts liked by the user" do @@ -66,10 +66,10 @@ describe EvilQuery::Participation do describe "ordering" do before do - @status_messageA = FactoryGirl.create(:status_message, :author => bob.person) - @status_messageB = FactoryGirl.create(:status_message, :author => bob.person) - @status_messageD = FactoryGirl.create(:status_message, :author => bob.person) - @status_messageE = FactoryGirl.create(:status_message, :author => bob.person) + @status_messageA = FactoryBot.create(:status_message, :author => bob.person) + @status_messageB = FactoryBot.create(:status_message, :author => bob.person) + @status_messageD = FactoryBot.create(:status_message, :author => bob.person) + @status_messageE = FactoryBot.create(:status_message, :author => bob.person) time = Time.now diff --git a/spec/lib/stream/base_spec.rb b/spec/lib/stream/base_spec.rb index 08fa3d89c..8a1f7df10 100644 --- a/spec/lib/stream/base_spec.rb +++ b/spec/lib/stream/base_spec.rb @@ -21,7 +21,7 @@ describe Stream::Base do before do bob.post(:status_message, :text => "sup", :to => bob.aspects.first.id) @liked_status = bob.posts.last - @like = FactoryGirl.create(:like, :target => @liked_status, :author => alice.person) + @like = FactoryBot.create(:like, :target => @liked_status, :author => alice.person) end it "marks the posts as liked" do @@ -32,33 +32,33 @@ describe Stream::Base do describe '.can_comment?' do before do - @person = FactoryGirl.create(:person) + @person = FactoryBot.create(:person) allow(@stream).to receive(:people).and_return([bob.person, eve.person, @person]) end it 'allows me to comment on my local contacts post' do - post = FactoryGirl.create(:status_message, :author => bob.person) + post = FactoryBot.create(:status_message, :author => bob.person) expect(@stream.can_comment?(post)).to be true end it 'allows me to comment on my own post' do - post = FactoryGirl.create(:status_message, :author => alice.person) + post = FactoryBot.create(:status_message, :author => alice.person) expect(@stream.can_comment?(post)).to be true end it 'allows me to comment on any local public post' do - post = FactoryGirl.create(:status_message, :author => eve.person) + post = FactoryBot.create(:status_message, :author => eve.person) expect(@stream.can_comment?(post)).to be true end it 'allows me to comment on a remote contacts post' do Contact.create!(:user => @stream.user, :person => @person) - post = FactoryGirl.create(:status_message, :author => @person) + post = FactoryBot.create(:status_message, :author => @person) expect(@stream.can_comment?(post)).to be true end it 'returns false if person is remote and not a contact' do - post = FactoryGirl.create(:status_message, :author => @person) + post = FactoryBot.create(:status_message, :author => @person) expect(@stream.can_comment?(post)).to be false end end diff --git a/spec/lib/stream/multi_spec.rb b/spec/lib/stream/multi_spec.rb index 3ef7e604a..c38637e2e 100644 --- a/spec/lib/stream/multi_spec.rb +++ b/spec/lib/stream/multi_spec.rb @@ -55,7 +55,7 @@ describe Stream::Multi do context 'when invited by another user' do before do - @user = FactoryGirl.create(:user, :invited_by => alice) + @user = FactoryBot.create(:user, :invited_by => alice) @inviter = alice.person @stream = Stream::Multi.new(@user) diff --git a/spec/lib/stream/tag_spec.rb b/spec/lib/stream/tag_spec.rb index c126e7d83..476bc8a1b 100644 --- a/spec/lib/stream/tag_spec.rb +++ b/spec/lib/stream/tag_spec.rb @@ -29,7 +29,7 @@ describe Stream::Tag do end it 'displays a public post that was sent to no one' do - stranger = FactoryGirl.create(:user_with_aspect) + stranger = FactoryBot.create(:user_with_aspect) stranger_post = stranger.post(:status_message, :text => "#what", :public => true, :to => 'all') expect(@stream.posts).to eq([stranger_post]) end @@ -81,14 +81,14 @@ describe Stream::Tag do describe 'shared behaviors' do before do - @stream = Stream::Tag.new(FactoryGirl.create(:user), FactoryGirl.create(:tag).name) + @stream = Stream::Tag.new(FactoryBot.create(:user), FactoryBot.create(:tag).name) end it_should_behave_like 'it is a stream' end describe '#stream_posts' do it "returns an empty array if the tag does not exist" do - stream = Stream::Tag.new(FactoryGirl.create(:user), "test") + stream = Stream::Tag.new(FactoryBot.create(:user), "test") expect(stream.stream_posts).to eq([]) end @@ -100,7 +100,7 @@ describe Stream::Tag do it "returns the post containing the tag" do post = alice.post(:status_message, text: "#what", public: true) - stream = Stream::Tag.new(FactoryGirl.create(:user), "what") + stream = Stream::Tag.new(FactoryBot.create(:user), "what") expect(stream.stream_posts).to eq([post]) end end diff --git a/spec/mailers/maintenance_spec.rb b/spec/mailers/maintenance_spec.rb index 71955bbb7..8b12365f9 100644 --- a/spec/mailers/maintenance_spec.rb +++ b/spec/mailers/maintenance_spec.rb @@ -8,7 +8,7 @@ describe Maintenance, :type => :mailer do describe 'create warning' do before do @removal_timestamp = Time.now + 3.days - @user = FactoryGirl.create(:user_with_aspect, :username => "local", :remove_after => @removal_timestamp) + @user = FactoryBot.create(:user_with_aspect, :username => "local", :remove_after => @removal_timestamp) end it "#should deliver successfully" do diff --git a/spec/mailers/notifier_spec.rb b/spec/mailers/notifier_spec.rb index d86d7ef79..1337d105b 100644 --- a/spec/mailers/notifier_spec.rb +++ b/spec/mailers/notifier_spec.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true describe Notifier, type: :mailer do - let(:person) { FactoryGirl.create(:person) } + let(:person) { FactoryBot.create(:person) } let(:pod_name) { AppConfig.settings.pod_name } @@ -23,7 +23,7 @@ describe Notifier, type: :mailer do before do @users = [] 5.times do - @users << FactoryGirl.create(:user) + @users << FactoryBot.create(:user) end end it "has a body" do @@ -99,7 +99,7 @@ describe Notifier, type: :mailer do describe ".mentioned" do before do @user = alice - @post = FactoryGirl.create(:status_message, public: true) + @post = FactoryBot.create(:status_message, public: true) @mention = Mention.create(person: @user.person, mentions_container: @post) @mail = Notifier.send_notification("mentioned", @user.id, @post.author.id, @mention.id) @@ -129,7 +129,7 @@ describe Notifier, type: :mailer do describe ".mentioned_in_comment" do let(:user) { alice } - let(:comment) { FactoryGirl.create(:comment) } + let(:comment) { FactoryBot.create(:comment) } let(:mention) { Mention.create(person: user.person, mentions_container: comment) } let(:mail) { Notifier.send_notification("mentioned_in_comment", user.id, comment.author.id, mention.id) } @@ -163,7 +163,7 @@ describe Notifier, type: :mailer do describe ".mentioned limited" do before do @user = alice - @post = FactoryGirl.create(:status_message, public: false) + @post = FactoryBot.create(:status_message, public: false) @mention = Mention.create(person: @user.person, mentions_container: @post) @mail = Notifier.send_notification("mentioned", @user.id, @post.author.id, @mention.id) @@ -188,7 +188,7 @@ describe Notifier, type: :mailer do describe ".liked" do before do - @post = FactoryGirl.create(:status_message, author: alice.person, public: true) + @post = FactoryBot.create(:status_message, author: alice.person, public: true) @like = @post.likes.create!(author: bob.person) @mail = Notifier.send_notification("liked", alice.id, @like.author.id, @like.id) end @@ -210,14 +210,14 @@ describe Notifier, type: :mailer do end it "can handle a reshare" do - reshare = FactoryGirl.create(:reshare) + reshare = FactoryBot.create(:reshare) like = reshare.likes.create!(author: bob.person) Notifier.send_notification("liked", alice.id, like.author.id, like.id) end it "can handle status_messages without text" do - photo = FactoryGirl.create(:photo, public: true) - status = FactoryGirl.create(:status_message, author: alice.person, text: nil, photos: [photo], public: true) + photo = FactoryBot.create(:photo, public: true) + status = FactoryBot.create(:status_message, author: alice.person, text: nil, photos: [photo], public: true) like = status.likes.create!(author: bob.person) mail = Notifier.send_notification("liked", alice.id, like.author.id, like.id) expect(mail.body.encoded).to include(I18n.t("posts.show.photos_by", count: 1, author: alice.name)) @@ -226,8 +226,8 @@ describe Notifier, type: :mailer do describe ".reshared" do before do - @post = FactoryGirl.create(:status_message, author: alice.person, public: true) - @reshare = FactoryGirl.create(:reshare, root: @post, author: bob.person) + @post = FactoryBot.create(:status_message, author: alice.person, public: true) + @reshare = FactoryBot.create(:reshare, root: @post, author: bob.person) @mail = Notifier.send_notification("reshared", alice.id, @reshare.author.id, @reshare.id) end @@ -342,7 +342,7 @@ describe Notifier, type: :mailer do [:reshare].each do |post_type| context post_type.to_s do - let(:commented_post) { FactoryGirl.create(post_type, author: bob.person) } + let(:commented_post) { FactoryBot.create(post_type, author: bob.person) } it "succeeds" do expect { comment_mail @@ -387,7 +387,7 @@ describe Notifier, type: :mailer do end [:reshare].each do |post_type| context post_type.to_s do - let(:commented_post) { FactoryGirl.create(post_type, author: bob.person) } + let(:commented_post) { FactoryBot.create(post_type, author: bob.person) } it "succeeds" do expect { comment_mail diff --git a/spec/mailers/report_spec.rb b/spec/mailers/report_spec.rb index 4770a8000..4d4af9d94 100644 --- a/spec/mailers/report_spec.rb +++ b/spec/mailers/report_spec.rb @@ -18,9 +18,9 @@ describe Report, type: :mailer do item_id: @comment.id, item_type: "Comment", text: "offensive comment" ) - @remote = FactoryGirl.create(:person, diaspora_handle: "remote@remote.net") - @user = FactoryGirl.create(:user_with_aspect, username: "local", language: "de") - @user2 = FactoryGirl.create(:user_with_aspect, username: "locally") + @remote = FactoryBot.create(:person, diaspora_handle: "remote@remote.net") + @user = FactoryBot.create(:user_with_aspect, username: "local", language: "de") + @user2 = FactoryBot.create(:user_with_aspect, username: "locally") Role.add_admin(@user.person) Role.add_moderator(@user2.person) end diff --git a/spec/models/account_deletion_spec.rb b/spec/models/account_deletion_spec.rb index 996eb29ef..82a4220da 100644 --- a/spec/models/account_deletion_spec.rb +++ b/spec/models/account_deletion_spec.rb @@ -51,9 +51,9 @@ describe AccountDeletion, type: :model do end it "includes remote resharers" do - status_message = FactoryGirl.create(:status_message, public: true, author: alice.person) - FactoryGirl.create(:reshare, author: remote_raphael, root: status_message) - FactoryGirl.create(:reshare, author: local_luke.person, root: status_message) + status_message = FactoryBot.create(:status_message, public: true, author: alice.person) + FactoryBot.create(:reshare, author: remote_raphael, root: status_message) + FactoryBot.create(:reshare, author: local_luke.person, root: status_message) expect(account_deletion.subscribers).to eq([remote_raphael]) end diff --git a/spec/models/account_migration_spec.rb b/spec/models/account_migration_spec.rb index b0b304afb..68fe01436 100644 --- a/spec/models/account_migration_spec.rb +++ b/spec/models/account_migration_spec.rb @@ -4,18 +4,18 @@ require "integration/federation/federation_helper" describe AccountMigration, type: :model do describe "create!" do - let(:old_user) { FactoryGirl.create(:user) } + let(:old_user) { FactoryBot.create(:user) } let(:old_person) { old_user.person } it "locks old local user after creation" do expect { - AccountMigration.create!(old_person: old_person, new_person: FactoryGirl.create(:person)) + AccountMigration.create!(old_person: old_person, new_person: FactoryBot.create(:person)) }.to change { old_user.reload.access_locked? }.to be_truthy end end - let(:old_person) { FactoryGirl.create(:person) } - let(:new_person) { FactoryGirl.create(:person) } + let(:old_person) { FactoryBot.create(:person) } + let(:new_person) { FactoryBot.create(:person) } let(:account_migration) { AccountMigration.create!(old_person: old_person, new_person: new_person) } @@ -48,7 +48,7 @@ describe AccountMigration, type: :model do end context "with local old user" do - let(:old_user) { FactoryGirl.create(:user) } + let(:old_user) { FactoryBot.create(:user) } let(:old_person) { old_user.person } it "matches the old user" do @@ -65,18 +65,18 @@ describe AccountMigration, type: :model do end it "is truthy when completed_at is set" do - expect(FactoryGirl.create(:account_migration, completed_at: Time.zone.now).performed?).to be_truthy + expect(FactoryBot.create(:account_migration, completed_at: Time.zone.now).performed?).to be_truthy end it "is falsey when completed_at is null" do - account_migration = FactoryGirl.create(:account_migration, completed_at: nil) + account_migration = FactoryBot.create(:account_migration, completed_at: nil) account_migration.old_person.lock_access! expect(account_migration.performed?).to be_falsey end end context "with local new user" do - let(:new_user) { FactoryGirl.create(:user) } + let(:new_user) { FactoryBot.create(:user) } let(:new_person) { new_user.person } describe "subscribers" do @@ -87,7 +87,7 @@ describe AccountMigration, type: :model do end context "with local old user" do - let(:old_person) { FactoryGirl.create(:user).person } + let(:old_person) { FactoryBot.create(:user).person } it "doesn't include old person" do expect(account_migration.subscribers).to be_empty @@ -117,7 +117,7 @@ describe AccountMigration, type: :model do end context "with local old and remote new users" do - let(:old_person) { FactoryGirl.create(:user).person } + let(:old_person) { FactoryBot.create(:user).person } it "calls AccountDeleter#close_user" do expect(embedded_account_deleter).to receive(:close_user) @@ -125,7 +125,7 @@ describe AccountMigration, type: :model do end it "resends contacts to the remote pod" do - contact = FactoryGirl.create(:contact, person: old_person, sharing: true) + contact = FactoryBot.create(:contact, person: old_person, sharing: true) expect(Diaspora::Federation::Dispatcher).to receive(:defer_dispatch).with(contact.user, contact) account_migration.perform! end @@ -134,7 +134,7 @@ describe AccountMigration, type: :model do context "with local new and remote old users" do let(:old_user) { remote_user_on_pod_c } let(:old_person) { old_user.person } - let(:new_person) { FactoryGirl.create(:user).person } + let(:new_person) { FactoryBot.create(:user).person } it "dispatches account migration message" do expect(account_migration).to receive(:sender).twice.and_return(old_user) @@ -156,8 +156,8 @@ describe AccountMigration, type: :model do end context "with local old and new users" do - let(:old_person) { FactoryGirl.create(:user).person } - let(:new_person) { FactoryGirl.create(:user).person } + let(:old_person) { FactoryBot.create(:user).person } + let(:new_person) { FactoryBot.create(:user).person } it "calls AccountDeleter#tombstone_user" do expect(embedded_account_deleter).to receive(:tombstone_user) @@ -167,25 +167,25 @@ describe AccountMigration, type: :model do context "with remote account merging (non-empty new person)" do before do - FactoryGirl.create( + FactoryBot.create( :contact, person: new_person, - user: FactoryGirl.create(:contact, person: old_person).user + user: FactoryBot.create(:contact, person: old_person).user ) - FactoryGirl.create( + FactoryBot.create( :like, author: new_person, - target: FactoryGirl.create(:like, author: old_person).target + target: FactoryBot.create(:like, author: old_person).target ) - FactoryGirl.create( + FactoryBot.create( :participation, author: new_person, - target: FactoryGirl.create(:participation, author: old_person).target + target: FactoryBot.create(:participation, author: old_person).target ) - FactoryGirl.create( + FactoryBot.create( :poll_participation, author: new_person, - poll_answer: FactoryGirl.create(:poll_participation, author: old_person).poll_answer + poll_answer: FactoryBot.create(:poll_participation, author: old_person).poll_answer ) end @@ -201,26 +201,26 @@ describe AccountMigration, type: :model do end context "with local account merging (non-empty new user)" do - let(:old_user) { FactoryGirl.create(:user) } + let(:old_user) { FactoryBot.create(:user) } let(:old_person) { old_user.person } - let(:new_user) { FactoryGirl.create(:user) } + let(:new_user) { FactoryBot.create(:user) } let(:new_person) { new_user.person } before do - FactoryGirl.create( + FactoryBot.create( :aspect, user: new_user, - name: FactoryGirl.create(:aspect, user: old_user).name + name: FactoryBot.create(:aspect, user: old_user).name ) - FactoryGirl.create( + FactoryBot.create( :contact, user: new_user, - person: FactoryGirl.create(:contact, user: old_user).person + person: FactoryBot.create(:contact, user: old_user).person ) - FactoryGirl.create( + FactoryBot.create( :tag_following, user: new_user, - tag: FactoryGirl.create(:tag_following, user: old_user).tag + tag: FactoryBot.create(:tag_following, user: old_user).tag ) end @@ -236,7 +236,7 @@ describe AccountMigration, type: :model do describe "#newest_person" do let!(:second_migration) { - FactoryGirl.create(:account_migration, old_person: account_migration.new_person) + FactoryBot.create(:account_migration, old_person: account_migration.new_person) } it "returns the newest account in the migration chain" do diff --git a/spec/models/api/openid_connect/id_token_spec.rb b/spec/models/api/openid_connect/id_token_spec.rb index 2409d78a6..1c60430c8 100644 --- a/spec/models/api/openid_connect/id_token_spec.rb +++ b/spec/models/api/openid_connect/id_token_spec.rb @@ -2,7 +2,7 @@ describe Api::OpenidConnect::IdToken, type: :model do describe "#to_jwt" do - let(:auth) { FactoryGirl.create(:auth_with_default_scopes) } + let(:auth) { FactoryBot.create(:auth_with_default_scopes) } let(:id_token) { Api::OpenidConnect::IdToken.new(auth, "nonce") } describe "decoded data" do diff --git a/spec/models/aspect_visibility_spec.rb b/spec/models/aspect_visibility_spec.rb index 7689799bc..3db52546a 100644 --- a/spec/models/aspect_visibility_spec.rb +++ b/spec/models/aspect_visibility_spec.rb @@ -1,11 +1,11 @@ # frozen_string_literal: true describe AspectVisibility, type: :model do - let(:status_message) { FactoryGirl.create(:status_message) } - let(:aspect) { FactoryGirl.create(:aspect) } - let(:status_message_in_aspect) { FactoryGirl.create(:status_message_in_aspect) } + let(:status_message) { FactoryBot.create(:status_message) } + let(:aspect) { FactoryBot.create(:aspect) } + let(:status_message_in_aspect) { FactoryBot.create(:status_message_in_aspect) } let(:photo_with_same_id) { - Photo.find_by_id(status_message_in_aspect.id) || FactoryGirl.create(:photo, id: status_message_in_aspect.id) + Photo.find_by_id(status_message_in_aspect.id) || FactoryBot.create(:photo, id: status_message_in_aspect.id) } describe ".create" do diff --git a/spec/models/comment_spec.rb b/spec/models/comment_spec.rb index 5f57e4884..a457a9886 100644 --- a/spec/models/comment_spec.rb +++ b/spec/models/comment_spec.rb @@ -27,9 +27,9 @@ describe Comment, type: :model do end describe "#subscribers" do - let(:status_bob) { FactoryGirl.create(:status_message, public: true, author: bob.person) } + let(:status_bob) { FactoryBot.create(:status_message, public: true, author: bob.person) } let(:comment_alice) { - FactoryGirl.create( + FactoryBot.create( :comment, text: text_mentioning(remote_raphael, local_luke), post: status_bob, @@ -48,7 +48,7 @@ describe Comment, type: :model do end context "on a non parent post pod" do - let(:status_bob) { FactoryGirl.create(:status_message) } # make the message remote + let(:status_bob) { FactoryBot.create(:status_message) } # make the message remote it "doesn't include mentioned people to subscribers list" do expect(comment_alice.subscribers).not_to include(remote_raphael) @@ -110,11 +110,11 @@ describe Comment, type: :model do end it_behaves_like "it is relayable" do - let(:remote_parent) { FactoryGirl.create(:status_message, author: remote_raphael) } + let(:remote_parent) { FactoryBot.create(:status_message, author: remote_raphael) } let(:local_parent) { local_luke.post(:status_message, text: "hi", to: local_luke.aspects.first) } let(:object_on_local_parent) { local_luke.comment!(local_parent, "yo!") } let(:object_on_remote_parent) { local_luke.comment!(remote_parent, "Yeah, it was great") } - let(:remote_object_on_local_parent) { FactoryGirl.create(:comment, post: local_parent, author: remote_raphael) } + let(:remote_object_on_local_parent) { FactoryBot.create(:comment, post: local_parent, author: remote_raphael) } let(:relayable) { Comment::Generator.new(alice, status_bob, "why so formal?").build } end diff --git a/spec/models/contact_spec.rb b/spec/models/contact_spec.rb index dc5be39b8..cefa4503b 100644 --- a/spec/models/contact_spec.rb +++ b/spec/models/contact_spec.rb @@ -31,7 +31,7 @@ describe Contact, type: :model do end it "validates uniqueness" do - person = FactoryGirl.create(:person) + person = FactoryBot.create(:person) contact1 = alice.contacts.create(person: person) expect(contact1).to be_valid @@ -42,7 +42,7 @@ describe Contact, type: :model do describe "#not_contact_with_closed_account" do it "adds error if the person's account is closed" do - person = FactoryGirl.create(:person, closed_account: true) + person = FactoryBot.create(:person, closed_account: true) bad_contact = alice.contacts.create(person: person) expect(bad_contact).not_to be_valid @@ -84,13 +84,13 @@ describe Contact, type: :model do describe "sharing" do it "returns contacts with sharing true" do expect { - alice.contacts.create!(sharing: true, person: FactoryGirl.create(:person)) + alice.contacts.create!(sharing: true, person: FactoryBot.create(:person)) }.to change { Contact.sharing.count }.by(1) expect { - alice.contacts.create!(sharing: false, person: FactoryGirl.create(:person)) + alice.contacts.create!(sharing: false, person: FactoryBot.create(:person)) }.to change { Contact.sharing.count }.by(0) @@ -100,13 +100,13 @@ describe Contact, type: :model do describe "receiving" do it "returns contacts with sharing true" do expect { - alice.contacts.create!(receiving: true, person: FactoryGirl.build(:person)) + alice.contacts.create!(receiving: true, person: FactoryBot.build(:person)) }.to change { Contact.receiving.count }.by(1) expect { - alice.contacts.create!(receiving: false, person: FactoryGirl.build(:person)) + alice.contacts.create!(receiving: false, person: FactoryBot.build(:person)) }.to change { Contact.receiving.count }.by(0) @@ -116,14 +116,14 @@ describe Contact, type: :model do describe "mutual" do it "returns contacts with sharing true and receiving true" do expect { - alice.contacts.create!(receiving: true, sharing: true, person: FactoryGirl.build(:person)) + alice.contacts.create!(receiving: true, sharing: true, person: FactoryBot.build(:person)) }.to change { Contact.mutual.count }.by(1) expect { - alice.contacts.create!(receiving: false, sharing: true, person: FactoryGirl.build(:person)) - alice.contacts.create!(receiving: true, sharing: false, person: FactoryGirl.build(:person)) + alice.contacts.create!(receiving: false, sharing: true, person: FactoryBot.build(:person)) + alice.contacts.create!(receiving: true, sharing: false, person: FactoryBot.build(:person)) }.to change { Contact.mutual.count }.by(0) @@ -133,15 +133,15 @@ describe Contact, type: :model do describe "only_sharing" do it "returns contacts with sharing true and receiving false" do expect { - alice.contacts.create!(receiving: false, sharing: true, person: FactoryGirl.build(:person)) - alice.contacts.create!(receiving: false, sharing: true, person: FactoryGirl.build(:person)) + alice.contacts.create!(receiving: false, sharing: true, person: FactoryBot.build(:person)) + alice.contacts.create!(receiving: false, sharing: true, person: FactoryBot.build(:person)) }.to change { Contact.only_sharing.count }.by(2) expect { - alice.contacts.create!(receiving: true, sharing: true, person: FactoryGirl.build(:person)) - alice.contacts.create!(receiving: true, sharing: false, person: FactoryGirl.build(:person)) + alice.contacts.create!(receiving: true, sharing: true, person: FactoryBot.build(:person)) + alice.contacts.create!(receiving: true, sharing: false, person: FactoryBot.build(:person)) }.to change { Contact.only_sharing.count }.by(0) @@ -150,10 +150,10 @@ describe Contact, type: :model do describe "all_contacts_of_person" do it "returns all contacts where the person is the passed in person" do - person = FactoryGirl.create(:person) + person = FactoryBot.create(:person) - contact1 = FactoryGirl.create(:contact, person: person) - FactoryGirl.create(:contact) # contact2 + contact1 = FactoryBot.create(:contact, person: person) + FactoryBot.create(:contact) # contact2 expect(Contact.all_contacts_of_person(person)).to eq([contact1]) end @@ -194,7 +194,7 @@ describe Contact, type: :model do describe "#object_to_receive" do it "returns the contact for the recipient" do - user = FactoryGirl.create(:user) + user = FactoryBot.create(:user) contact = alice.contacts.create(person: user.person) receive = contact.object_to_receive expect(receive.user).to eq(user) diff --git a/spec/models/invitation_code_spec.rb b/spec/models/invitation_code_spec.rb index 3525b3a96..ff632287c 100644 --- a/spec/models/invitation_code_spec.rb +++ b/spec/models/invitation_code_spec.rb @@ -2,17 +2,17 @@ describe InvitationCode, :type => :model do it 'has a valid factory' do - expect(FactoryGirl.build(:invitation_code)).to be_valid + expect(FactoryBot.build(:invitation_code)).to be_valid end it 'sets the count to a default value' do - code = FactoryGirl.create(:invitation_code) + code = FactoryBot.create(:invitation_code) expect(code.count).to be > 0 end describe '#use!' do it 'decrements the count of the code' do - code = FactoryGirl.create(:invitation_code) + code = FactoryBot.create(:invitation_code) expect{ code.use! diff --git a/spec/models/like_spec.rb b/spec/models/like_spec.rb index d96121d78..d8e214eb5 100644 --- a/spec/models/like_spec.rb +++ b/spec/models/like_spec.rb @@ -8,7 +8,7 @@ describe Like, type: :model do let(:status) { bob.post(:status_message, text: "hello", to: bob.aspects.first.id) } it "has a valid factory" do - expect(FactoryGirl.build(:like)).to be_valid + expect(FactoryBot.build(:like)).to be_valid end describe "#destroy" do @@ -36,7 +36,7 @@ describe Like, type: :model do end it "increments the counter cache on its comment" do - comment = FactoryGirl.create(:comment, post: status) + comment = FactoryBot.create(:comment, post: status) expect { alice.like!(comment) }.to change { comment.reload.likes_count }.by(1) @@ -55,23 +55,23 @@ describe Like, type: :model do end it_behaves_like "it is relayable" do - let(:remote_parent) { FactoryGirl.create(:status_message, author: remote_raphael) } + let(:remote_parent) { FactoryBot.create(:status_message, author: remote_raphael) } let(:local_parent) { local_luke.post(:status_message, text: "hi", to: local_luke.aspects.first) } let(:object_on_local_parent) { local_luke.like!(local_parent) } let(:object_on_remote_parent) { local_luke.like!(remote_parent) } - let(:remote_object_on_local_parent) { FactoryGirl.create(:like, target: local_parent, author: remote_raphael) } + let(:remote_object_on_local_parent) { FactoryBot.create(:like, target: local_parent, author: remote_raphael) } let(:relayable) { Like::Generator.new(alice, status).build } end context "like for a comment" do it_behaves_like "it is relayable" do let(:local_parent) { local_luke.post(:status_message, text: "hi", to: local_luke.aspects.first) } - let(:remote_parent) { FactoryGirl.create(:status_message, author: remote_raphael) } - let(:comment_on_local_parent) { FactoryGirl.create(:comment, post: local_parent) } - let(:comment_on_remote_parent) { FactoryGirl.create(:comment, post: remote_parent) } + let(:remote_parent) { FactoryBot.create(:status_message, author: remote_raphael) } + let(:comment_on_local_parent) { FactoryBot.create(:comment, post: local_parent) } + let(:comment_on_remote_parent) { FactoryBot.create(:comment, post: remote_parent) } let(:object_on_local_parent) { local_luke.like!(comment_on_local_parent) } let(:object_on_remote_parent) { local_luke.like!(comment_on_remote_parent) } - let(:remote_object_on_local_parent) { FactoryGirl.create(:like, target: local_parent, author: remote_raphael) } + let(:remote_object_on_local_parent) { FactoryBot.create(:like, target: local_parent, author: remote_raphael) } let(:relayable) { Like::Generator.new(alice, status).build } end end diff --git a/spec/models/location_spec.rb b/spec/models/location_spec.rb index ba7ab17fd..b07abf724 100644 --- a/spec/models/location_spec.rb +++ b/spec/models/location_spec.rb @@ -2,7 +2,7 @@ describe Location, type: :model do describe "before validation" do - let(:status) { FactoryGirl.create(:status_message) } + let(:status) { FactoryBot.create(:status_message) } it "should create new location when it has coordinates" do location = Location.new(coordinates: "1,2", status_message: status) diff --git a/spec/models/notification_spec.rb b/spec/models/notification_spec.rb index 14f5d9b4b..a2ea20f03 100644 --- a/spec/models/notification_spec.rb +++ b/spec/models/notification_spec.rb @@ -6,8 +6,8 @@ describe Notification, :type => :model do before do - @sm = FactoryGirl.create(:status_message) - @person = FactoryGirl.create(:person) + @sm = FactoryBot.create(:status_message) + @person = FactoryBot.create(:person) @user = alice @user2 = eve @aspect = @user.aspects.create(:name => "dudes") @@ -26,7 +26,7 @@ describe Notification, :type => :model do describe '.for' do it 'returns all of a users notifications' do - user2 = FactoryGirl.create(:user) + user2 = FactoryBot.create(:user) 4.times do Notification.create(@opts) end diff --git a/spec/models/notifications/also_commented_spec.rb b/spec/models/notifications/also_commented_spec.rb index dd4039285..cfae3814b 100644 --- a/spec/models/notifications/also_commented_spec.rb +++ b/spec/models/notifications/also_commented_spec.rb @@ -5,8 +5,8 @@ # the COPYRIGHT file. describe Notifications::AlsoCommented, type: :model do - let(:sm) { FactoryGirl.build(:status_message, author: alice.person, public: true) } - let(:comment) { FactoryGirl.create(:comment, commentable: sm) } + let(:sm) { FactoryBot.build(:status_message, author: alice.person, public: true) } + let(:comment) { FactoryBot.create(:comment, commentable: sm) } let(:notification) { Notifications::AlsoCommented.new(recipient: bob) } describe ".notify" do @@ -28,7 +28,7 @@ describe Notifications::AlsoCommented, type: :model do end it "does not notify the a remote participant" do - FactoryGirl.create(:participation, target: sm) + FactoryBot.create(:participation, target: sm) expect(Notifications::AlsoCommented).not_to receive(:concatenate_or_create) @@ -37,7 +37,7 @@ describe Notifications::AlsoCommented, type: :model do it "does not notify the author of the comment" do bob.participate!(sm) - comment = FactoryGirl.create(:comment, commentable: sm, author: bob.person) + comment = FactoryBot.create(:comment, commentable: sm, author: bob.person) expect(Notifications::AlsoCommented).not_to receive(:concatenate_or_create) diff --git a/spec/models/notifications/mentioned_in_post_spec.rb b/spec/models/notifications/mentioned_in_post_spec.rb index bbf6b02b8..e6792cfb0 100644 --- a/spec/models/notifications/mentioned_in_post_spec.rb +++ b/spec/models/notifications/mentioned_in_post_spec.rb @@ -2,7 +2,7 @@ describe Notifications::MentionedInPost, type: :model do let(:sm) { - FactoryGirl.create(:status_message, author: alice.person, text: "hi @{bob; #{bob.diaspora_handle}}", public: true) + FactoryBot.create(:status_message, author: alice.person, text: "hi @{bob; #{bob.diaspora_handle}}", public: true) } let(:mentioned_notification) { Notifications::MentionedInPost.new(recipient: bob) } @@ -23,7 +23,7 @@ describe Notifications::MentionedInPost, type: :model do end it "does nothing if the mentioned person is not local" do - sm = FactoryGirl.create( + sm = FactoryBot.create( :status_message, author: alice.person, text: "hi @{raphael; #{remote_raphael.diaspora_handle}}", @@ -46,7 +46,7 @@ describe Notifications::MentionedInPost, type: :model do context "with private post" do let(:private_sm) { - FactoryGirl.create( + FactoryBot.create( :status_message, author: remote_raphael, text: "hi @{bob; #{bob.diaspora_handle}}", diff --git a/spec/models/notifications/mentioned_spec.rb b/spec/models/notifications/mentioned_spec.rb index ca77f960f..b1567f80d 100644 --- a/spec/models/notifications/mentioned_spec.rb +++ b/spec/models/notifications/mentioned_spec.rb @@ -11,7 +11,7 @@ describe Notifications::Mentioned do describe ".notify" do let(:status_message) { - FactoryGirl.create(:status_message, text: text_mentioning(remote_raphael, alice, bob, eve), author: eve.person) + FactoryBot.create(:status_message, text: text_mentioning(remote_raphael, alice, bob, eve), author: eve.person) } it "calls filter_mentions on self" do @@ -37,7 +37,7 @@ describe Notifications::Mentioned do end it "creates email notification for mention" do - status_message = FactoryGirl.create(:status_message, text: text_mentioning(alice), author: eve.person) + status_message = FactoryBot.create(:status_message, text: text_mentioning(alice), author: eve.person) expect_any_instance_of(TestNotification).to receive(:email_the_user).with( Mention.where(mentions_container: status_message, person: alice.person_id).first, status_message.author @@ -53,7 +53,7 @@ describe Notifications::Mentioned do end it "doesn't create notification if it already exists" do - status_message = FactoryGirl.create(:status_message, text: text_mentioning(alice), author: eve.person) + status_message = FactoryBot.create(:status_message, text: text_mentioning(alice), author: eve.person) TestNotification.create( recipient: alice, target: Mention.where(mentions_container: status_message, person: alice.person_id).first, diff --git a/spec/models/notifications/reshared_spec.rb b/spec/models/notifications/reshared_spec.rb index 739fd79e4..e6c5a6c81 100644 --- a/spec/models/notifications/reshared_spec.rb +++ b/spec/models/notifications/reshared_spec.rb @@ -5,8 +5,8 @@ # the COPYRIGHT file. describe Notifications::Reshared, type: :model do - let(:sm) { FactoryGirl.build(:status_message, author: alice.person, public: true) } - let(:reshare) { FactoryGirl.build(:reshare, root: sm) } + let(:sm) { FactoryBot.build(:status_message, author: alice.person, public: true) } + let(:reshare) { FactoryBot.build(:reshare, root: sm) } let(:reshared_notification) { Notifications::Reshared.new(recipient: alice) } describe ".notify" do diff --git a/spec/models/participation_spec.rb b/spec/models/participation_spec.rb index 8ce158f1e..504ff1991 100644 --- a/spec/models/participation_spec.rb +++ b/spec/models/participation_spec.rb @@ -11,7 +11,7 @@ describe Participation, type: :model do end it "returns the parent author on remote parent" do - remote_parent = FactoryGirl.create(:status_message, author: remote_raphael) + remote_parent = FactoryBot.create(:status_message, author: remote_raphael) participation = local_luke.participate!(remote_parent) expect(participation.subscribers).to match_array([remote_raphael]) end diff --git a/spec/models/person_spec.rb b/spec/models/person_spec.rb index 104d58aa9..25bb3b137 100644 --- a/spec/models/person_spec.rb +++ b/spec/models/person_spec.rb @@ -7,7 +7,7 @@ describe Person, :type => :model do before do @user = bob - @person = FactoryGirl.create(:person) + @person = FactoryBot.create(:person) end it 'always has a profile' do @@ -81,8 +81,8 @@ describe Person, :type => :model do describe ".who_have_reshared a user's posts" do it 'pulls back users who reshared the status message of a user' do - sm = FactoryGirl.create(:status_message, :author => alice.person, :public => true) - reshare = FactoryGirl.create(:reshare, :root => sm) + sm = FactoryBot.create(:status_message, :author => alice.person, :public => true) + reshare = FactoryBot.create(:reshare, :root => sm) expect(Person.who_have_reshared_a_users_posts(alice)).to eq([reshare.author]) end end @@ -97,13 +97,13 @@ describe Person, :type => :model do it "finds a person with a profile name containing the substring" do substring = r_str - person = FactoryGirl.create(:person, first_name: "A#{substring}A") + person = FactoryBot.create(:person, first_name: "A#{substring}A") expect(Person.find_by_substring(substring)).to include(person) end it "finds a person with a diaspora ID starting with the substring" do substring = r_str - person = FactoryGirl.create(:person, diaspora_handle: "#{substring}A@pod.tld") + person = FactoryBot.create(:person, diaspora_handle: "#{substring}A@pod.tld") expect(Person.find_by_substring(substring)).to include(person) end end @@ -112,8 +112,8 @@ describe Person, :type => :model do let(:status_bob) { bob.post(:status_message, text: "hello", to: bob.aspects.first.id) } it "returns the author and people who have commented or liked the private post" do - kate = FactoryGirl.create(:user_with_aspect, friends: [bob]) - olga = FactoryGirl.create(:user_with_aspect, friends: [bob]) + kate = FactoryBot.create(:user_with_aspect, friends: [bob]) + olga = FactoryBot.create(:user_with_aspect, friends: [bob]) alice.comment!(status_bob, "why so formal?") eve.comment!(status_bob, "comment text") kate.like!(status_bob) @@ -138,12 +138,12 @@ describe Person, :type => :model do end describe ".sort_for_mention_suggestion" do - let(:status_message) { FactoryGirl.create(:status_message) } + let(:status_message) { FactoryBot.create(:status_message) } it "returns people sorted in the order: post author > commenters > likers > contacts" do - like = FactoryGirl.create(:like, target: status_message) - comment = FactoryGirl.create(:comment, post: status_message) - current_user = FactoryGirl.create(:user_with_aspect, friends: [alice]) + like = FactoryBot.create(:like, target: status_message) + comment = FactoryBot.create(:comment, post: status_message) + current_user = FactoryBot.create(:user_with_aspect, friends: [alice]) result = Person.select(:id, :guid).sort_for_mention_suggestion(status_message, current_user) expect(result[0]).to eq(status_message.author) expect(result[1]).to eq(comment.author) @@ -152,9 +152,9 @@ describe Person, :type => :model do end it "sorts people of the same priority by profile name" do - current_user = FactoryGirl.create(:user_with_aspect) - person1 = FactoryGirl.create(:person, first_name: "x2") - person2 = FactoryGirl.create(:person, first_name: "x1") + current_user = FactoryBot.create(:user_with_aspect) + person1 = FactoryBot.create(:person, first_name: "x2") + person2 = FactoryBot.create(:person, first_name: "x1") result = Person .select(:id, :guid) .where(id: [person1.id, person2.id]) @@ -164,10 +164,10 @@ describe Person, :type => :model do end it "sorts people of the same priority and same names by diaspora ID" do - current_user = FactoryGirl.create(:user_with_aspect) - person1 = FactoryGirl.create(:person, diaspora_handle: "x2@pod.tld") + current_user = FactoryBot.create(:user_with_aspect) + person1 = FactoryBot.create(:person, diaspora_handle: "x2@pod.tld") person1.profile.update(first_name: "John", last_name: "Doe") - person2 = FactoryGirl.create(:person, diaspora_handle: "x1@pod.tld") + person2 = FactoryBot.create(:person, diaspora_handle: "x1@pod.tld") person2.profile.update(first_name: "John", last_name: "Doe") result = Person .select(:id, :guid) @@ -180,17 +180,17 @@ describe Person, :type => :model do describe ".in_aspects" do it "returns person that is in the aspect" do - aspect = FactoryGirl.create(:aspect) - contact = FactoryGirl.create(:contact, user: aspect.user) + aspect = FactoryBot.create(:aspect) + contact = FactoryBot.create(:contact, user: aspect.user) aspect.contacts << contact expect(Person.in_aspects([aspect.id])).to include(contact.person) end it "returns same person in multiple aspects only once" do user = bob - contact = FactoryGirl.create(:contact, user: user) + contact = FactoryBot.create(:contact, user: user) ids = Array.new(2) do - aspect = FactoryGirl.create(:aspect, user: user, name: r_str) + aspect = FactoryBot.create(:aspect, user: user, name: r_str) aspect.contacts << contact aspect.id end @@ -210,7 +210,7 @@ describe Person, :type => :model do describe "valid url" do context "https urls" do - let(:person) { FactoryGirl.build(:person, pod: Pod.find_or_create_by(url: "https://example.com")) } + let(:person) { FactoryBot.build(:person, pod: Pod.find_or_create_by(url: "https://example.com")) } it "should add trailing slash" do expect(person.url).to eq("https://example.com/") @@ -231,7 +231,7 @@ describe Person, :type => :model do context "messed up urls" do let(:person) { - FactoryGirl.build(:person, pod: Pod.find_or_create_by(url: "https://example.com/a/bit/messed/up")) + FactoryBot.build(:person, pod: Pod.find_or_create_by(url: "https://example.com/a/bit/messed/up")) } it "should return the correct url" do @@ -252,12 +252,12 @@ describe Person, :type => :model do end it "should allow ports in the url" do - person = FactoryGirl.build(:person, pod: Pod.find_or_create_by(url: "https://example.com:3000/")) + person = FactoryBot.build(:person, pod: Pod.find_or_create_by(url: "https://example.com:3000/")) expect(person.url).to eq("https://example.com:3000/") end it "should remove https port in the url" do - person = FactoryGirl.build(:person, pod: Pod.find_or_create_by(url: "https://example.com:443/")) + person = FactoryBot.build(:person, pod: Pod.find_or_create_by(url: "https://example.com:443/")) expect(person.url).to eq("https://example.com/") end end @@ -284,12 +284,12 @@ describe Person, :type => :model do describe 'validation' do it 'is unique' do - person_two = FactoryGirl.build(:person, :diaspora_handle => @person.diaspora_handle) + person_two = FactoryBot.build(:person, :diaspora_handle => @person.diaspora_handle) expect(person_two).not_to be_valid end it 'is case insensitive' do - person_two = FactoryGirl.build(:person, :diaspora_handle => @person.diaspora_handle.upcase) + person_two = FactoryBot.build(:person, :diaspora_handle => @person.diaspora_handle.upcase) expect(person_two).not_to be_valid end end @@ -342,8 +342,8 @@ describe Person, :type => :model do end it '#owns? posts' do - person_message = FactoryGirl.create(:status_message, :author => @person) - person_two = FactoryGirl.create(:person) + person_message = FactoryBot.create(:status_message, :author => @person) + person_two = FactoryBot.create(:person) expect(@person.owns?(person_message)).to be true expect(person_two.owns?(person_message)).to be false @@ -351,7 +351,7 @@ describe Person, :type => :model do describe "disconnecting" do before do - @user2 = FactoryGirl.create(:user) + @user2 = FactoryBot.create(:user) @aspect = @user.aspects.create(:name => "Dudes") @aspect2 = @user2.aspects.create(:name => "Abscence of Babes") end @@ -389,18 +389,18 @@ describe Person, :type => :model do describe '.search' do before do Person.delete_all - @user = FactoryGirl.create(:user_with_aspect) + @user = FactoryBot.create(:user_with_aspect) user_profile = @user.person.profile user_profile.first_name = "aiofj" user_profile.last_name = "asdji" user_profile.save - @robert_grimm = FactoryGirl.build(:person) - @eugene_weinstein = FactoryGirl.build(:person) - @yevgeniy_dodis = FactoryGirl.build(:person) - @casey_grippi = FactoryGirl.build(:person) - @invisible_person = FactoryGirl.build(:person) - @closed_account = FactoryGirl.build(:person, closed_account: true) + @robert_grimm = FactoryBot.build(:person) + @eugene_weinstein = FactoryBot.build(:person) + @yevgeniy_dodis = FactoryBot.build(:person) + @casey_grippi = FactoryBot.build(:person) + @invisible_person = FactoryBot.build(:person) + @closed_account = FactoryBot.build(:person, closed_account: true) @robert_grimm.profile.first_name = "Robert" @robert_grimm.profile.last_name = "Grimm" @@ -597,8 +597,8 @@ describe Person, :type => :model do end context 'people finders for webfinger' do - let(:user) { FactoryGirl.create(:user) } - let(:person) { FactoryGirl.create(:person) } + let(:user) { FactoryBot.create(:user) } + let(:person) { FactoryBot.create(:person) } describe '.by_account_identifier' do it 'should find a local users person' do @@ -617,27 +617,27 @@ describe Person, :type => :model do end it "finds a local person with a mixed-case username" do - user = FactoryGirl.create(:user, :username => "SaMaNtHa") + user = FactoryBot.create(:user, :username => "SaMaNtHa") person = Person.by_account_identifier(user.person.diaspora_handle) expect(person).to eq(user.person) end it "is case insensitive" do - user1 = FactoryGirl.create(:user, :username => "SaMaNtHa") + user1 = FactoryBot.create(:user, :username => "SaMaNtHa") person = Person.by_account_identifier(user1.person.diaspora_handle.upcase) expect(person).to eq(user1.person) end it "should only find people who are exact matches (1/2)" do - FactoryGirl.create(:person, diaspora_handle: "tomtom@tom.joindiaspora.com") - FactoryGirl.create(:person, diaspora_handle: "tom@tom.joindiaspora.com") + FactoryBot.create(:person, diaspora_handle: "tomtom@tom.joindiaspora.com") + FactoryBot.create(:person, diaspora_handle: "tom@tom.joindiaspora.com") expect(Person.by_account_identifier("tom@tom.joindiaspora.com").diaspora_handle) .to eq("tom@tom.joindiaspora.com") end it "should only find people who are exact matches (2/2)" do - FactoryGirl.create(:person, diaspora_handle: "tomtom@tom.joindiaspora.com") - FactoryGirl.create(:person, diaspora_handle: "tom@tom.joindiaspora.comm") + FactoryBot.create(:person, diaspora_handle: "tomtom@tom.joindiaspora.com") + FactoryBot.create(:person, diaspora_handle: "tom@tom.joindiaspora.comm") expect(Person.by_account_identifier("tom@tom.joindiaspora.com")).to be_nil end end @@ -694,7 +694,7 @@ describe Person, :type => :model do describe "#clear_profile!!" do before do - @person = FactoryGirl.build(:person) + @person = FactoryBot.build(:person) end it 'calls Profile#tombstone!' do @@ -705,7 +705,7 @@ describe Person, :type => :model do context "validation" do it "validates that no other person with same guid exists" do - person = FactoryGirl.build(:person) + person = FactoryBot.build(:person) person.guid = alice.guid expect(person.valid?).to be_falsey diff --git a/spec/models/pod_spec.rb b/spec/models/pod_spec.rb index a8001d3a8..b7386f7a6 100644 --- a/spec/models/pod_spec.rb +++ b/spec/models/pod_spec.rb @@ -84,8 +84,8 @@ describe Pod, type: :model do describe ".check_scheduled!" do it "calls #test_connection! on all scheduled pods" do - (0..4).map { FactoryGirl.create(:pod) } - FactoryGirl.create(:pod, scheduled_check: true) + (0..4).map { FactoryBot.create(:pod) } + FactoryBot.create(:pod, scheduled_check: true) expect_any_instance_of(Pod).to receive(:test_connection!) Pod.check_scheduled! @@ -94,47 +94,47 @@ describe Pod, type: :model do describe "#active?" do it "returns true for an unchecked pod" do - pod = FactoryGirl.create(:pod) + pod = FactoryBot.create(:pod) expect(pod.active?).to be_truthy end it "returns true for an online pod" do - pod = FactoryGirl.create(:pod, status: :no_errors) + pod = FactoryBot.create(:pod, status: :no_errors) expect(pod.reload.active?).to be_truthy end it "returns true for a pod that is offline for less than 14 days" do - pod = FactoryGirl.create(:pod, status: :net_failed, offline_since: DateTime.now.utc - 13.days) + pod = FactoryBot.create(:pod, status: :net_failed, offline_since: DateTime.now.utc - 13.days) expect(pod.active?).to be_truthy end it "returns false for a pod that is offline for less than 14 days" do - pod = FactoryGirl.create(:pod, status: :net_failed, offline_since: DateTime.now.utc - 15.days) + pod = FactoryBot.create(:pod, status: :net_failed, offline_since: DateTime.now.utc - 15.days) expect(pod.active?).to be_falsey end end describe "#schedule_check_if_needed" do it "schedules the pod for the next check if it is offline" do - pod = FactoryGirl.create(:pod, status: :net_failed) + pod = FactoryBot.create(:pod, status: :net_failed) pod.schedule_check_if_needed expect(pod.scheduled_check).to be_truthy end it "does nothing if the pod unchecked" do - pod = FactoryGirl.create(:pod) + pod = FactoryBot.create(:pod) pod.schedule_check_if_needed expect(pod.scheduled_check).to be_falsey end it "does nothing if the pod is online" do - pod = FactoryGirl.create(:pod, status: :no_errors) + pod = FactoryBot.create(:pod, status: :no_errors) pod.schedule_check_if_needed expect(pod.scheduled_check).to be_falsey end it "does nothing if the pod is scheduled for the next check" do - pod = FactoryGirl.create(:pod, status: :no_errors, scheduled_check: true) + pod = FactoryBot.create(:pod, status: :no_errors, scheduled_check: true) expect(pod).not_to receive(:update_column) pod.schedule_check_if_needed end @@ -142,7 +142,7 @@ describe Pod, type: :model do describe "#test_connection!" do before do - @pod = FactoryGirl.create(:pod) + @pod = FactoryBot.create(:pod) @result = double("result") @now = Time.zone.now @@ -200,13 +200,13 @@ describe Pod, type: :model do describe "#url_to" do it "appends the path to the pod-url" do - pod = FactoryGirl.create(:pod) + pod = FactoryBot.create(:pod) expect(pod.url_to("/receive/public")).to eq("https://#{pod.host}/receive/public") end end describe "#update_offline_since" do - let(:pod) { FactoryGirl.create(:pod) } + let(:pod) { FactoryBot.create(:pod) } it "handles a successful status" do pod.status = :no_errors diff --git a/spec/models/poll_answer_spec.rb b/spec/models/poll_answer_spec.rb index b670cb09d..809fbe66e 100644 --- a/spec/models/poll_answer_spec.rb +++ b/spec/models/poll_answer_spec.rb @@ -2,7 +2,7 @@ describe PollAnswer, :type => :model do before do - @status = FactoryGirl.create(:status_message_with_poll) + @status = FactoryBot.create(:status_message_with_poll) @user = alice @answer = @status.poll.poll_answers.first end diff --git a/spec/models/poll_participation_spec.rb b/spec/models/poll_participation_spec.rb index bf3d54537..46dbb9d2f 100644 --- a/spec/models/poll_participation_spec.rb +++ b/spec/models/poll_participation_spec.rb @@ -26,8 +26,8 @@ describe PollParticipation, type: :model do end it "has unique DB index for author-person" do - pp = FactoryGirl.create(:poll_participation) - pp2 = FactoryGirl.create(:poll_participation, author: pp.author) + pp = FactoryBot.create(:poll_participation) + pp2 = FactoryBot.create(:poll_participation, author: pp.author) expect { # rubocop:disable Rails/SkipsModelValidations pp2.update_attribute(:poll_id, pp.poll_id) @@ -37,9 +37,9 @@ describe PollParticipation, type: :model do end it_behaves_like "it is relayable" do - let(:remote_parent) { FactoryGirl.create(:status_message_with_poll, author: remote_raphael) } + let(:remote_parent) { FactoryBot.create(:status_message_with_poll, author: remote_raphael) } let(:local_parent) { - FactoryGirl.create(:status_message_with_poll, author: local_luke.person).tap do |status_message| + FactoryBot.create(:status_message_with_poll, author: local_luke.person).tap do |status_message| local_luke.add_to_streams(status_message, [local_luke.aspects.first]) end } @@ -48,7 +48,7 @@ describe PollParticipation, type: :model do local_luke.participate_in_poll!(remote_parent, remote_parent.poll.poll_answers.first) } let(:remote_object_on_local_parent) { - FactoryGirl.create(:poll_participation, poll_answer: local_parent.poll.poll_answers.first, author: remote_raphael) + FactoryBot.create(:poll_participation, poll_answer: local_parent.poll.poll_answers.first, author: remote_raphael) } let(:relayable) { PollParticipation::Generator.new(alice, status, poll.poll_answers.first).build } end diff --git a/spec/models/poll_spec.rb b/spec/models/poll_spec.rb index 382fae7f7..1c039db99 100644 --- a/spec/models/poll_spec.rb +++ b/spec/models/poll_spec.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true describe Poll, type: :model do - let(:status) { FactoryGirl.create(:status_message) } + let(:status) { FactoryBot.create(:status_message) } let(:poll) { Poll.new(question: "What do you think about apples?", status_message: status) } describe "validation" do diff --git a/spec/models/post_spec.rb b/spec/models/post_spec.rb index 98f38ff6f..601d4b69e 100644 --- a/spec/models/post_spec.rb +++ b/spec/models/post_spec.rb @@ -9,10 +9,10 @@ describe Post, :type => :model do describe '.owned_or_visible_by_user' do before do @you = bob - @public_post = FactoryGirl.create(:status_message, :public => true) - @your_post = FactoryGirl.create(:status_message, :author => @you.person) + @public_post = FactoryBot.create(:status_message, :public => true) + @your_post = FactoryBot.create(:status_message, :author => @you.person) @post_from_contact = eve.post(:status_message, :text => 'wooo', :to => eve.aspects.where(:name => 'generic').first) - @post_from_stranger = FactoryGirl.create(:status_message, :public => false) + @post_from_stranger = FactoryBot.create(:status_message, :public => false) end it 'returns post from your contacts' do @@ -28,7 +28,7 @@ describe Post, :type => :model do end it 'returns public post from your contact' do - sm = FactoryGirl.create(:status_message, :author => eve.person, :public => true) + sm = FactoryBot.create(:status_message, :author => eve.person, :public => true) expect(StatusMessage.owned_or_visible_by_user(@you)).to include(sm) end @@ -44,16 +44,16 @@ describe Post, :type => :model do describe ".all_public" do it "includes all public posts" do - post1 = FactoryGirl.create(:status_message, author: alice.person, public: true) - post2 = FactoryGirl.create(:status_message, author: bob.person, public: true) - post3 = FactoryGirl.create(:status_message, author: eve.person, public: true) + post1 = FactoryBot.create(:status_message, author: alice.person, public: true) + post2 = FactoryBot.create(:status_message, author: bob.person, public: true) + post3 = FactoryBot.create(:status_message, author: eve.person, public: true) expect(Post.all_public.ids).to match_array([post1.id, post2.id, post3.id]) end it "doesn't include any private posts" do - FactoryGirl.create(:status_message, author: alice.person, public: false) - FactoryGirl.create(:status_message, author: bob.person, public: false) - FactoryGirl.create(:status_message, author: eve.person, public: false) + FactoryBot.create(:status_message, author: alice.person, public: false) + FactoryBot.create(:status_message, author: bob.person, public: false) + FactoryBot.create(:status_message, author: eve.person, public: false) expect(Post.all_public.ids).to eq([]) end end @@ -78,8 +78,8 @@ describe Post, :type => :model do describe '.excluding_blocks' do before do - @post = FactoryGirl.create(:status_message, :author => alice.person) - @other_post = FactoryGirl.create(:status_message, :author => eve.person) + @post = FactoryBot.create(:status_message, :author => alice.person) + @other_post = FactoryBot.create(:status_message, :author => eve.person) bob.blocks.create(:person => alice.person) end @@ -99,8 +99,8 @@ describe Post, :type => :model do describe '.excluding_hidden_shareables' do before do - @post = FactoryGirl.create(:status_message, :author => alice.person) - @other_post = FactoryGirl.create(:status_message, :author => eve.person) + @post = FactoryBot.create(:status_message, :author => alice.person) + @other_post = FactoryBot.create(:status_message, :author => eve.person) bob.toggle_hidden_shareable(@post) end it 'excludes posts the user has hidden' do @@ -178,10 +178,10 @@ describe Post, :type => :model do end describe ".subscribed_by" do - let(:user) { FactoryGirl.create(:user) } + let(:user) { FactoryBot.create(:user) } context "when the user has a participation on a post" do - let(:post) { FactoryGirl.create(:status_message_with_participations, participants: [user]) } + let(:post) { FactoryBot.create(:status_message_with_participations, participants: [user]) } it "includes the post to the result set" do expect(Post.subscribed_by(user)).to eq([post]) @@ -190,7 +190,7 @@ describe Post, :type => :model do context "when the user doens't have a participation on a post" do before do - FactoryGirl.create(:status_message) + FactoryBot.create(:status_message) end it "returns empty result set" do @@ -200,10 +200,10 @@ describe Post, :type => :model do end describe ".reshared_by" do - let(:person) { FactoryGirl.create(:person) } + let(:person) { FactoryBot.create(:person) } context "when the person has a reshare for a post" do - let(:post) { FactoryGirl.create(:reshare, author: person).root } + let(:post) { FactoryBot.create(:reshare, author: person).root } it "includes the post to the result set" do expect(Post.reshared_by(person)).to eq([post]) @@ -212,7 +212,7 @@ describe Post, :type => :model do context "when the person has no reshare for a post" do before do - FactoryGirl.create(:status_message) + FactoryBot.create(:status_message) end it "returns empty result set" do @@ -224,21 +224,21 @@ describe Post, :type => :model do describe 'validations' do it 'validates uniqueness of guid and does not throw a db error' do - message = FactoryGirl.create(:status_message) - expect(FactoryGirl.build(:status_message, :guid => message.guid)).not_to be_valid + message = FactoryBot.create(:status_message) + expect(FactoryBot.build(:status_message, :guid => message.guid)).not_to be_valid end end describe 'post_type' do it 'returns the class constant' do - status_message = FactoryGirl.create(:status_message) + status_message = FactoryBot.create(:status_message) expect(status_message.post_type).to eq("StatusMessage") end end describe 'deletion' do it 'should delete a posts comments on delete' do - post = FactoryGirl.create(:status_message, author: alice.person) + post = FactoryBot.create(:status_message, author: alice.person) alice.comment!(post, "hey") post.destroy expect(Post.where(:id => post.id).empty?).to eq(true) @@ -248,13 +248,13 @@ describe Post, :type => :model do describe '.diaspora_initialize' do it 'takes provider_display_name' do - sm = FactoryGirl.create(:status_message, :provider_display_name => 'mobile') + sm = FactoryBot.create(:status_message, :provider_display_name => 'mobile') expect(StatusMessage.diaspora_initialize(sm.attributes.merge(:author => bob.person)).provider_display_name).to eq('mobile') end end describe "#subscribers" do - let(:user) { FactoryGirl.create(:user_with_aspect) } + let(:user) { FactoryBot.create(:user_with_aspect) } before do user.share_with(alice.person, user.aspects.first) @@ -280,7 +280,7 @@ describe Post, :type => :model do let(:post) { user.post(:status_message, text: "hello", public: true) } it "returns the author to ensure local delivery" do - lonely_user = FactoryGirl.create(:user) + lonely_user = FactoryBot.create(:user) lonely_post = lonely_user.post(:status_message, text: "anyone?", public: true) expect(lonely_post.subscribers).to match_array([lonely_user.person]) end @@ -293,7 +293,7 @@ describe Post, :type => :model do end it "adds resharers to subscribers" do - FactoryGirl.create(:reshare, root: post, author: eve.person) + FactoryBot.create(:reshare, root: post, author: eve.person) expect(post.subscribers).to match_array([alice.person, eve.person, user.person]) end @@ -324,19 +324,19 @@ describe Post, :type => :model do describe "#receive" do it "creates a share visibility for the user" do user_ids = [alice.id, eve.id] - post = FactoryGirl.create(:status_message, author: bob.person) + post = FactoryBot.create(:status_message, author: bob.person) expect(ShareVisibility).to receive(:batch_import).with(user_ids, post) post.receive(user_ids) end it "does nothing for public post" do - post = FactoryGirl.create(:status_message, author: bob.person, public: true) + post = FactoryBot.create(:status_message, author: bob.person, public: true) expect(ShareVisibility).not_to receive(:batch_import) post.receive([alice.id]) end it "does nothing if no recipients provided" do - post = FactoryGirl.create(:status_message, author: bob.person) + post = FactoryBot.create(:status_message, author: bob.person) expect(ShareVisibility).not_to receive(:batch_import) post.receive([]) end @@ -357,7 +357,7 @@ describe Post, :type => :model do describe 'when post has been reshared exactly 1 time' do before :each do expect(@post.reshares.size).to eq(0) - @reshare = FactoryGirl.create(:reshare, :root => @post) + @reshare = FactoryBot.create(:reshare, :root => @post) @post.reload expect(@post.reshares.size).to eq(1) end @@ -370,9 +370,9 @@ describe Post, :type => :model do describe 'when post has been reshared more than once' do before :each do expect(@post.reshares.size).to eq(0) - FactoryGirl.create(:reshare, :root => @post) - FactoryGirl.create(:reshare, :root => @post) - FactoryGirl.create(:reshare, :root => @post) + FactoryBot.create(:reshare, :root => @post) + FactoryBot.create(:reshare, :root => @post) + FactoryBot.create(:reshare, :root => @post) @post.reload expect(@post.reshares.size).to eq(3) end @@ -385,15 +385,15 @@ describe Post, :type => :model do describe "#after_create" do it "sets #interacted_at" do - post = FactoryGirl.create(:status_message) + post = FactoryBot.create(:status_message) expect(post.interacted_at).not_to be_blank end end describe "#before_destroy" do it "removes root_guid from reshares" do - post = FactoryGirl.create(:status_message, author: alice.person, public: true) - reshare = FactoryGirl.create(:reshare, author: bob.person, root: post) + post = FactoryBot.create(:status_message, author: alice.person, public: true) + reshare = FactoryBot.create(:reshare, author: bob.person, root: post) post.destroy! expect(reshare.reload.root_guid).to be_nil end diff --git a/spec/models/profile_spec.rb b/spec/models/profile_spec.rb index cec968c88..aa2b6891a 100644 --- a/spec/models/profile_spec.rb +++ b/spec/models/profile_spec.rb @@ -8,23 +8,23 @@ describe Profile, :type => :model do describe 'validation' do describe "of first_name" do it "strips leading and trailing whitespace" do - profile = FactoryGirl.build(:profile, :first_name => " Shelly ") + profile = FactoryBot.build(:profile, :first_name => " Shelly ") expect(profile).to be_valid expect(profile.first_name).to eq("Shelly") end it "can be 32 characters long" do - profile = FactoryGirl.build(:profile, :first_name => "Hexagoooooooooooooooooooooooooon") + profile = FactoryBot.build(:profile, :first_name => "Hexagoooooooooooooooooooooooooon") expect(profile).to be_valid end it "cannot be 33 characters" do - profile = FactoryGirl.build(:profile, :first_name => "Hexagooooooooooooooooooooooooooon") + profile = FactoryBot.build(:profile, :first_name => "Hexagooooooooooooooooooooooooooon") expect(profile).not_to be_valid end it 'cannot have ;' do - profile = FactoryGirl.build(:profile, :first_name => "Hex;agon") + profile = FactoryBot.build(:profile, :first_name => "Hex;agon") expect(profile).not_to be_valid end end @@ -54,7 +54,7 @@ describe Profile, :type => :model do describe '#contruct_full_name' do it 'generates a full name given only first name' do - profile = FactoryGirl.build(:person).profile + profile = FactoryBot.build(:person).profile profile.first_name = "casimiro" profile.last_name = nil @@ -64,7 +64,7 @@ describe Profile, :type => :model do end it 'generates a full name given only last name' do - profile = FactoryGirl.build(:person).profile + profile = FactoryBot.build(:person).profile profile.first_name = nil profile.last_name = "grippi" @@ -74,7 +74,7 @@ describe Profile, :type => :model do end it 'generates a full name given first and last names' do - profile = FactoryGirl.build(:person).profile + profile = FactoryBot.build(:person).profile profile.first_name = "casimiro" profile.last_name = "grippi" @@ -86,27 +86,27 @@ describe Profile, :type => :model do describe "of last_name" do it "strips leading and trailing whitespace" do - profile = FactoryGirl.build(:profile, :last_name => " Ohba ") + profile = FactoryBot.build(:profile, :last_name => " Ohba ") expect(profile).to be_valid expect(profile.last_name).to eq("Ohba") end it "can be 32 characters long" do - profile = FactoryGirl.build(:profile, :last_name => "Hexagoooooooooooooooooooooooooon") + profile = FactoryBot.build(:profile, :last_name => "Hexagoooooooooooooooooooooooooon") expect(profile).to be_valid end it "cannot be 33 characters" do - profile = FactoryGirl.build(:profile, :last_name => "Hexagooooooooooooooooooooooooooon") + profile = FactoryBot.build(:profile, :last_name => "Hexagooooooooooooooooooooooooooon") expect(profile).not_to be_valid end it 'cannot have ;' do - profile = FactoryGirl.build(:profile, :last_name => "Hex;agon") + profile = FactoryBot.build(:profile, :last_name => "Hex;agon") expect(profile).not_to be_valid end it 'disallows ; with a newline in the string' do - profile = FactoryGirl.build(:profile, :last_name => "H\nex;agon") + profile = FactoryBot.build(:profile, :last_name => "H\nex;agon") expect(profile).not_to be_valid end end @@ -114,24 +114,24 @@ describe Profile, :type => :model do describe "of location" do it "can be 255 characters long" do - profile = FactoryGirl.build(:profile, :location => "a"*255) + profile = FactoryBot.build(:profile, :location => "a"*255) expect(profile).to be_valid end it "cannot be 256 characters" do - profile = FactoryGirl.build(:profile, :location => "a"*256) + profile = FactoryBot.build(:profile, :location => "a"*256) expect(profile).not_to be_valid end end describe "of gender" do it "can be 255 characters long" do - profile = FactoryGirl.build(:profile, gender: "a" * 255) + profile = FactoryBot.build(:profile, gender: "a" * 255) expect(profile).to be_valid end it "cannot be 256 characters" do - profile = FactoryGirl.build(:profile, gender: "a" * 256) + profile = FactoryBot.build(:profile, gender: "a" * 256) expect(profile).not_to be_valid end end @@ -140,7 +140,7 @@ describe Profile, :type => :model do %i(image_url image_url_small image_url_medium).each do |method| describe "##{method}=" do before do - @profile = FactoryGirl.build(:profile) + @profile = FactoryBot.build(:profile) @profile.public_send("#{method}=", "http://tom.joindiaspora.com/images/user/tom.jpg") @pod_url = AppConfig.pod_uri.to_s.chomp("/") end @@ -175,7 +175,7 @@ describe Profile, :type => :model do describe '#image_url' do before do - @profile = FactoryGirl.build(:profile) + @profile = FactoryBot.build(:profile) end it 'returns a default rather than nil' do @@ -201,18 +201,18 @@ describe Profile, :type => :model do describe "public?" do it "is public if public_details is true" do - profile = FactoryGirl.build(:profile, public_details: true) + profile = FactoryBot.build(:profile, public_details: true) expect(profile.public?).to be_truthy end it "is not public if public_details is false" do - profile = FactoryGirl.build(:profile, public_details: false) + profile = FactoryBot.build(:profile, public_details: false) expect(profile.public?).to be_falsey end end describe 'date=' do - let(:profile) { FactoryGirl.build(:profile) } + let(:profile) { FactoryBot.build(:profile) } it 'accepts form data' do profile.birthday = nil @@ -258,7 +258,7 @@ describe Profile, :type => :model do end describe "tags" do - let(:object) { FactoryGirl.build(:person).profile } + let(:object) { FactoryBot.build(:person).profile } it "allows 5 tags" do object.tag_string = "#one #two #three #four #five" @@ -323,7 +323,7 @@ describe Profile, :type => :model do describe "#clearable_fields" do it 'returns the current profile fields' do - profile = FactoryGirl.build :profile + profile = FactoryBot.build :profile expect(profile.send(:clearable_fields).sort).to eq( ["diaspora_handle", "first_name", diff --git a/spec/models/reference_spec.rb b/spec/models/reference_spec.rb index 6d5514e32..216d69f41 100644 --- a/spec/models/reference_spec.rb +++ b/spec/models/reference_spec.rb @@ -3,20 +3,20 @@ describe Reference, type: :model do context "validation" do it "validates a valid reference" do - expect(FactoryGirl.build(:reference)).to be_valid + expect(FactoryBot.build(:reference)).to be_valid end it "requires a source" do - expect(FactoryGirl.build(:reference, source: nil)).not_to be_valid + expect(FactoryBot.build(:reference, source: nil)).not_to be_valid end it "requires a target" do - expect(FactoryGirl.build(:reference, target: nil)).not_to be_valid + expect(FactoryBot.build(:reference, target: nil)).not_to be_valid end it "disallows to link the same target twice from one source" do - reference = FactoryGirl.create(:reference) - expect(FactoryGirl.build(:reference, source: reference.source, target: reference.target)).not_to be_valid + reference = FactoryBot.create(:reference) + expect(FactoryBot.build(:reference, source: reference.source, target: reference.target)).not_to be_valid end end end diff --git a/spec/models/reshare_spec.rb b/spec/models/reshare_spec.rb index 39cbbcbf2..fea4dc53d 100644 --- a/spec/models/reshare_spec.rb +++ b/spec/models/reshare_spec.rb @@ -2,29 +2,29 @@ describe Reshare, type: :model do it "has a valid Factory" do - expect(FactoryGirl.build(:reshare)).to be_valid + expect(FactoryBot.build(:reshare)).to be_valid end context "validation" do it "requires root when the author is local" do - reshare = FactoryGirl.build(:reshare, root: nil, author: alice.person) + reshare = FactoryBot.build(:reshare, root: nil, author: alice.person) expect(reshare).not_to be_valid end it "doesn't require root when the author is remote" do - reshare = FactoryGirl.build(:reshare, root: nil, author: remote_raphael) + reshare = FactoryBot.build(:reshare, root: nil, author: remote_raphael) expect(reshare).to be_valid end it "require public root" do - reshare = FactoryGirl.build(:reshare, root: FactoryGirl.create(:status_message, public: false)) + reshare = FactoryBot.build(:reshare, root: FactoryBot.create(:status_message, public: false)) expect(reshare).not_to be_valid expect(reshare.errors[:base]).to include("Only posts which are public may be reshared.") end it "allows two reshares without a root" do - reshare1 = FactoryGirl.create(:reshare, author: alice.person) - reshare2 = FactoryGirl.create(:reshare, author: alice.person) + reshare1 = FactoryBot.create(:reshare, author: alice.person) + reshare2 = FactoryBot.create(:reshare, author: alice.person) reshare1.update_attributes(root_guid: nil) @@ -33,26 +33,26 @@ describe Reshare, type: :model do end it "doesn't allow to reshare the same post twice" do - post = FactoryGirl.create(:status_message, public: true) - FactoryGirl.create(:reshare, author: alice.person, root: post) + post = FactoryBot.create(:status_message, public: true) + FactoryBot.create(:reshare, author: alice.person, root: post) - expect(FactoryGirl.build(:reshare, author: alice.person, root: post)).not_to be_valid + expect(FactoryBot.build(:reshare, author: alice.person, root: post)).not_to be_valid end it "allows to reshare the same post with different people" do - post = FactoryGirl.create(:status_message, public: true) - FactoryGirl.create(:reshare, author: alice.person, root: post) + post = FactoryBot.create(:status_message, public: true) + FactoryBot.create(:reshare, author: alice.person, root: post) - expect(FactoryGirl.build(:reshare, author: bob.person, root: post)).to be_valid + expect(FactoryBot.build(:reshare, author: bob.person, root: post)).to be_valid end end it "forces public" do - expect(FactoryGirl.create(:reshare, public: false).public).to be true + expect(FactoryBot.create(:reshare, public: false).public).to be true end describe "#root_diaspora_id" do - let(:reshare) { create(:reshare, root: FactoryGirl.build(:status_message, author: bob.person, public: true)) } + let(:reshare) { create(:reshare, root: FactoryBot.build(:status_message, author: bob.person, public: true)) } it "should return the root diaspora id" do expect(reshare.root_diaspora_id).to eq(bob.person.diaspora_handle) @@ -65,7 +65,7 @@ describe Reshare, type: :model do end describe "#receive" do - let(:reshare) { create(:reshare, root: FactoryGirl.build(:status_message, author: bob.person, public: true)) } + let(:reshare) { create(:reshare, root: FactoryBot.build(:status_message, author: bob.person, public: true)) } it "participates root author in the reshare" do reshare.receive([]) @@ -96,14 +96,14 @@ describe Reshare, type: :model do describe "#absolute_root" do before do - @status_message = FactoryGirl.build(:status_message, author: alice.person, public: true) - reshare_1 = FactoryGirl.build(:reshare, root: @status_message) - reshare_2 = FactoryGirl.build(:reshare, root: reshare_1) - @reshare_3 = FactoryGirl.build(:reshare, root: reshare_2) + @status_message = FactoryBot.build(:status_message, author: alice.person, public: true) + reshare_1 = FactoryBot.build(:reshare, root: @status_message) + reshare_2 = FactoryBot.build(:reshare, root: reshare_1) + @reshare_3 = FactoryBot.build(:reshare, root: reshare_2) - status_message = FactoryGirl.create(:status_message, author: alice.person, public: true) - reshare_1 = FactoryGirl.create(:reshare, root: status_message) - @of_deleted = FactoryGirl.build(:reshare, root: reshare_1) + status_message = FactoryBot.create(:status_message, author: alice.person, public: true) + reshare_1 = FactoryBot.create(:reshare, root: status_message) + @of_deleted = FactoryBot.build(:reshare, root: reshare_1) status_message.destroy reshare_1.reload end @@ -158,21 +158,21 @@ describe Reshare, type: :model do describe "#subscribers" do it "adds root author to subscribers" do - user = FactoryGirl.create(:user_with_aspect) + user = FactoryBot.create(:user_with_aspect) user.share_with(alice.person, user.aspects.first) post = eve.post(:status_message, text: "hello", public: true) - reshare = FactoryGirl.create(:reshare, root: post, author: user.person) + reshare = FactoryBot.create(:reshare, root: post, author: user.person) expect(reshare.subscribers).to match_array([alice.person, eve.person, user.person]) end it "does not add the root author if the root post was deleted" do - user = FactoryGirl.create(:user_with_aspect) + user = FactoryBot.create(:user_with_aspect) user.share_with(alice.person, user.aspects.first) post = eve.post(:status_message, text: "hello", public: true) - reshare = FactoryGirl.create(:reshare, root: post, author: user.person) + reshare = FactoryBot.create(:reshare, root: post, author: user.person) post.destroy expect(reshare.reload.subscribers).to match_array([alice.person, user.person]) diff --git a/spec/models/share_visibility_spec.rb b/spec/models/share_visibility_spec.rb index 0efc50820..7ca6bca14 100644 --- a/spec/models/share_visibility_spec.rb +++ b/spec/models/share_visibility_spec.rb @@ -6,7 +6,7 @@ describe ShareVisibility, type: :model do describe ".batch_import" do - let(:post) { FactoryGirl.create(:status_message, author: alice.person) } + let(:post) { FactoryBot.create(:status_message, author: alice.person) } it "returns false if share is public" do post.public = true @@ -30,7 +30,7 @@ describe ShareVisibility, type: :model do end it "does not create visibilities for a public shareable" do - public_post = FactoryGirl.create(:status_message, author: alice.person, public: true) + public_post = FactoryBot.create(:status_message, author: alice.person, public: true) ShareVisibility.batch_import([bob.id], public_post) expect(ShareVisibility.where(user_id: bob.id, shareable_id: post.id, shareable_type: "Post")).not_to exist diff --git a/spec/models/status_message_spec.rb b/spec/models/status_message_spec.rb index 05520de32..da19bf5fa 100644 --- a/spec/models/status_message_spec.rb +++ b/spec/models/status_message_spec.rb @@ -20,10 +20,10 @@ describe StatusMessage, type: :model do it "returns status messages where the given person is mentioned" do @bob = bob.person @test_string = "@{Daniel; #{@bob.diaspora_handle}} can mention people like Raph" - post1 = FactoryGirl.create(:status_message, text: @test_string, public: true) - post2 = FactoryGirl.create(:status_message, text: @test_string, public: true) - FactoryGirl.create(:status_message, text: @test_string) - FactoryGirl.create(:status_message, public: true) + post1 = FactoryBot.create(:status_message, text: @test_string, public: true) + post2 = FactoryBot.create(:status_message, text: @test_string, public: true) + FactoryBot.create(:status_message, text: @test_string) + FactoryBot.create(:status_message, public: true) expect(StatusMessage.where_person_is_mentioned(@bob).ids).to match_array([post1.id, post2.id]) end @@ -31,10 +31,10 @@ describe StatusMessage, type: :model do context "tag_streams" do before do - @status_message_1 = FactoryGirl.create(:status_message, text: "#hashtag", public: true) - @status_message_2 = FactoryGirl.create(:status_message, text: "#hashtag") - @status_message_3 = FactoryGirl.create(:status_message, text: "hashtags are #awesome", public: true) - @status_message_4 = FactoryGirl.create(:status_message, text: "hashtags are #awesome") + @status_message_1 = FactoryBot.create(:status_message, text: "#hashtag", public: true) + @status_message_2 = FactoryBot.create(:status_message, text: "#hashtag") + @status_message_3 = FactoryBot.create(:status_message, text: "hashtags are #awesome", public: true) + @status_message_4 = FactoryBot.create(:status_message, text: "hashtags are #awesome") @tag_id = ActsAsTaggableOn::Tag.where(name: "hashtag").first.id end @@ -53,7 +53,7 @@ describe StatusMessage, type: :model do end it "returns a post with two tags only once" do - status_message = FactoryGirl.create(:status_message, text: "#hashtag #test", public: true) + status_message = FactoryBot.create(:status_message, text: "#hashtag #test", public: true) test_tag_id = ActsAsTaggableOn::Tag.where(name: "test").first.id expect(StatusMessage.public_tag_stream([@tag_id, test_tag_id])) @@ -75,8 +75,8 @@ describe StatusMessage, type: :model do describe ".guids_for_author" do it "returns an array of the status_message guids" do - status_message_1 = FactoryGirl.create(:status_message, author: alice.person) - FactoryGirl.create(:status_message, author: bob.person) + status_message_1 = FactoryBot.create(:status_message, author: alice.person) + FactoryBot.create(:status_message, author: bob.person) guids = StatusMessage.guids_for_author(alice.person) expect(guids).to eq([status_message_1.guid]) end @@ -120,7 +120,7 @@ describe StatusMessage, type: :model do end it "also checks for content when author is remote" do - post = FactoryGirl.build(:status_message, text: nil) + post = FactoryBot.build(:status_message, text: nil) expect(post).not_to be_valid end end @@ -134,7 +134,7 @@ describe StatusMessage, type: :model do it "should require status messages not be more than 65535 characters long" do message = "a" * (65_535 + 1) - status_message = FactoryGirl.build(:status_message, text: message) + status_message = FactoryBot.build(:status_message, text: message) expect(status_message).not_to be_valid end @@ -142,7 +142,7 @@ describe StatusMessage, type: :model do describe "#people_allowed_to_be_mentioned" do it "returns only aspects members for private posts" do - sm = FactoryGirl.build(:status_message_in_aspect) + sm = FactoryBot.build(:status_message_in_aspect) sm.author.owner.share_with(alice.person, sm.author.owner.aspects.first) sm.author.owner.share_with(eve.person, sm.author.owner.aspects.first) sm.save! @@ -151,7 +151,7 @@ describe StatusMessage, type: :model do end it "returns :all for public posts" do - expect(FactoryGirl.create(:status_message, public: true).people_allowed_to_be_mentioned).to eq(:all) + expect(FactoryBot.create(:status_message, public: true).people_allowed_to_be_mentioned).to eq(:all) end end @@ -160,12 +160,12 @@ describe StatusMessage, type: :model do describe "#nsfw" do it "returns MatchObject (true) if the post contains #nsfw (however capitalised)" do - status = FactoryGirl.build(:status_message, text: "This message is #nSFw") + status = FactoryBot.build(:status_message, text: "This message is #nSFw") expect(status.nsfw).to be_truthy end it "returns nil (false) if the post does not contain #nsfw" do - status = FactoryGirl.build(:status_message, text: "This message is #sFW") + status = FactoryBot.build(:status_message, text: "This message is #sFW") expect(status.nsfw).to be false end end @@ -176,8 +176,8 @@ describe StatusMessage, type: :model do end it "includes the photos count if there are photos without text" do - photo = FactoryGirl.build(:photo, public: true) - status = FactoryGirl.build(:status_message, author: photo.author, text: nil, photos: [photo], public: true) + photo = FactoryBot.build(:photo, public: true) + status = FactoryBot.build(:status_message, author: photo.author, text: nil, photos: [photo], public: true) expect(status.comment_email_subject).to eq(I18n.t("posts.show.photos_by", count: 1, author: status.author_name)) end end @@ -190,9 +190,9 @@ describe StatusMessage, type: :model do it "associates different-case tags to the same tag entry" do assert_equal ActsAsTaggableOn.force_lowercase, true - msg_lc = FactoryGirl.build(:status_message, text: "#newhere") - msg_uc = FactoryGirl.build(:status_message, text: "#NewHere") - msg_cp = FactoryGirl.build(:status_message, text: "#NEWHERE") + msg_lc = FactoryBot.build(:status_message, text: "#newhere") + msg_uc = FactoryBot.build(:status_message, text: "#NewHere") + msg_cp = FactoryBot.build(:status_message, text: "#NEWHERE") msg_lc.save msg_uc.save @@ -205,7 +205,7 @@ describe StatusMessage, type: :model do it "should require tag name not be more than 255 characters long" do message = "##{'a' * (255 + 1)}" - status_message = FactoryGirl.build(:status_message, text: message) + status_message = FactoryBot.build(:status_message, text: message) expect(status_message).not_to be_valid end end @@ -213,7 +213,7 @@ describe StatusMessage, type: :model do describe "oembed" do let(:youtube_url) { "https://www.youtube.com/watch?v=3PtFwlKfvHI" } let(:message_text) { "#{youtube_url} is so cool. so is this link -> https://joindiaspora.com" } - let(:status_message) { FactoryGirl.build(:status_message, text: message_text) } + let(:status_message) { FactoryBot.build(:status_message, text: message_text) } it "should queue a GatherOembedData if it includes a link" do status_message @@ -248,7 +248,7 @@ describe StatusMessage, type: :model do expect(status_message.open_graph_url).to eq(ninegag_url) end it "returns nil if the link is from trusted oembed provider" do - status_message = FactoryGirl.build(:status_message, text: oemessage_text) + status_message = FactoryBot.build(:status_message, text: oemessage_text) expect(status_message.contains_open_graph_url_in_text?).to be_nil expect(status_message.open_graph_url).to be_nil end @@ -257,7 +257,7 @@ describe StatusMessage, type: :model do describe "poll" do it "destroys the poll (with all answers and participations) when the status message is destroyed" do - poll = FactoryGirl.create(:poll_participation).poll + poll = FactoryBot.create(:poll_participation).poll status_message = poll.status_message poll_id = poll.id @@ -303,10 +303,10 @@ describe StatusMessage, type: :model do end describe "#receive" do - let(:post) { FactoryGirl.create(:status_message, author: alice.person) } + let(:post) { FactoryBot.create(:status_message, author: alice.person) } it "receives attached photos" do - photo = FactoryGirl.create(:photo, status_message: post) + photo = FactoryBot.create(:photo, status_message: post) post.receive([bob.id]) @@ -321,7 +321,7 @@ describe StatusMessage, type: :model do end it "works with already received attached photos" do - photo = FactoryGirl.create(:photo, status_message: post) + photo = FactoryBot.create(:photo, status_message: post) photo.receive([bob.id]) post.receive([bob.id]) diff --git a/spec/models/tag_following_spec.rb b/spec/models/tag_following_spec.rb index ee5fa80b0..fbd0f3318 100644 --- a/spec/models/tag_following_spec.rb +++ b/spec/models/tag_following_spec.rb @@ -2,7 +2,7 @@ describe TagFollowing, :type => :model do before do - @tag = FactoryGirl.build(:tag) + @tag = FactoryBot.build(:tag) TagFollowing.create!(:tag => @tag, :user => alice) end diff --git a/spec/models/user/connecting_spec.rb b/spec/models/user/connecting_spec.rb index c31ce1004..e93b6936f 100644 --- a/spec/models/user/connecting_spec.rb +++ b/spec/models/user/connecting_spec.rb @@ -8,7 +8,7 @@ describe User::Connecting, type: :model do let(:aspect1) { alice.aspects.first } let(:aspect2) { alice.aspects.create(name: "other") } - let(:person) { FactoryGirl.create(:person) } + let(:person) { FactoryBot.create(:person) } describe "disconnecting" do describe "#disconnected_by" do @@ -200,7 +200,7 @@ describe User::Connecting, type: :model do end it "should mark the corresponding notification as 'read'" do - FactoryGirl.create(:notification, target: eve.person, recipient: alice, type: "Notifications::StartedSharing") + FactoryBot.create(:notification, target: eve.person, recipient: alice, type: "Notifications::StartedSharing") expect(Notifications::StartedSharing.find_by(recipient_id: alice.id, target: eve.person).unread).to be_truthy alice.share_with(eve.person, aspect1) diff --git a/spec/models/user/querying_spec.rb b/spec/models/user/querying_spec.rb index 53843a7bc..32c609961 100644 --- a/spec/models/user/querying_spec.rb +++ b/spec/models/user/querying_spec.rb @@ -98,7 +98,7 @@ describe User::Querying, :type => :model do describe "#visible_shareables" do it 'never contains posts from people not in your aspects' do - FactoryGirl.create(:status_message, :public => true) + FactoryBot.create(:status_message, :public => true) expect(bob.visible_shareables(Post).count(:all)).to eq(0) end @@ -176,9 +176,9 @@ describe User::Querying, :type => :model do end it "returns local/remote people objects for a users contact in each aspect" do - local_user1 = FactoryGirl.create(:user) - local_user2 = FactoryGirl.create(:user) - remote_person = FactoryGirl.create(:person) + local_user1 = FactoryBot.create(:user) + local_user2 = FactoryBot.create(:user) + remote_person = FactoryBot.create(:person) asp1 = local_user1.aspects.create(name: "lol") asp2 = local_user2.aspects.create(name: "brb") @@ -193,7 +193,7 @@ describe User::Querying, :type => :model do end it 'does not return people not connected to user on same pod' do - 3.times { FactoryGirl.create(:user) } + 3.times { FactoryBot.create(:user) } expect(alice.people_in_aspects([@alices_aspect]).count).to eq(1) end @@ -208,9 +208,9 @@ describe User::Querying, :type => :model do end context 'contact querying' do - let(:person_one) { FactoryGirl.create :person } - let(:person_two) { FactoryGirl.create :person } - let(:person_three) { FactoryGirl.create :person } + let(:person_one) { FactoryBot.create :person } + let(:person_two) { FactoryBot.create :person } + let(:person_three) { FactoryBot.create :person } let(:aspect) { alice.aspects.create(:name => 'heroes') } describe '#contact_for_person_id' do @@ -275,7 +275,7 @@ describe User::Querying, :type => :model do end describe "#block_for" do - let(:person) { FactoryGirl.create :person } + let(:person) { FactoryBot.create :person } before do eve.blocks.create({person: person}) @@ -290,7 +290,7 @@ describe User::Querying, :type => :model do describe '#posts_from' do before do - @user3 = FactoryGirl.create(:user) + @user3 = FactoryBot.create(:user) @aspect3 = @user3.aspects.create(:name => "bros") @public_message = @user3.post(:status_message, :text => "hey there", :to => 'all', :public => true) diff --git a/spec/models/user/social_actions_spec.rb b/spec/models/user/social_actions_spec.rb index 43065ef62..89df32e8a 100644 --- a/spec/models/user/social_actions_spec.rb +++ b/spec/models/user/social_actions_spec.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true describe User::SocialActions, type: :model do - let(:status) { FactoryGirl.create(:status_message, public: true, author: bob.person) } + let(:status) { FactoryBot.create(:status_message, public: true, author: bob.person) } describe "User#comment!" do it "sets the comment text" do @@ -69,7 +69,7 @@ describe User::SocialActions, type: :model do end describe "User#participate_in_poll!" do - let(:poll) { FactoryGirl.create(:poll, status_message: status) } + let(:poll) { FactoryBot.create(:poll, status_message: status) } let(:answer) { poll.poll_answers.first } it "federates" do diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 560432927..8bb4c350a 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -8,20 +8,20 @@ describe User, :type => :model do context "relations" do context "#conversations" do it "doesn't find anything when there is nothing to find" do - u = FactoryGirl.create(:user) + u = FactoryBot.create(:user) expect(u.conversations).to be_empty end it "finds the users conversations" do - c = FactoryGirl.create(:conversation, { author: alice.person }) + c = FactoryBot.create(:conversation, { author: alice.person }) expect(alice.conversations).to include c end it "doesn't find other users conversations" do - c1 = FactoryGirl.create(:conversation) - c2 = FactoryGirl.create(:conversation) - c_own = FactoryGirl.create(:conversation, { author: alice.person }) + c1 = FactoryBot.create(:conversation) + c2 = FactoryBot.create(:conversation) + c_own = FactoryBot.create(:conversation, { author: alice.person }) expect(alice.conversations).to include c_own expect(alice.conversations).not_to include c1 @@ -49,14 +49,14 @@ describe User, :type => :model do describe 'yearly_actives' do it 'returns list which includes users within last year' do - user = FactoryGirl.build(:user) + user = FactoryBot.build(:user) user.last_seen = Time.now - 1.month user.save expect(User.yearly_actives).to include user end it 'returns list which does not include users seen within last year' do - user = FactoryGirl.build(:user) + user = FactoryBot.build(:user) user.last_seen = Time.now - 2.year user.save expect(User.yearly_actives).not_to include user @@ -65,14 +65,14 @@ describe User, :type => :model do describe 'monthly_actives' do it 'returns list which includes users seen within last month' do - user = FactoryGirl.build(:user) + user = FactoryBot.build(:user) user.last_seen = Time.now - 1.day user.save expect(User.monthly_actives).to include user end it 'returns list which does not include users seen within last month' do - user = FactoryGirl.build(:user) + user = FactoryBot.build(:user) user.last_seen = Time.now - 2.month user.save expect(User.monthly_actives).not_to include user @@ -81,14 +81,14 @@ describe User, :type => :model do describe 'daily_actives' do it 'returns list which includes users seen within last day' do - user = FactoryGirl.build(:user) + user = FactoryBot.build(:user) user.last_seen = Time.now - 1.hour user.save expect(User.daily_actives).to include(user) end it 'returns list which does not include users seen within last day' do - user = FactoryGirl.build(:user) + user = FactoryBot.build(:user) user.last_seen = Time.now - 2.day user.save expect(User.daily_actives).not_to include(user) @@ -97,14 +97,14 @@ describe User, :type => :model do describe 'halfyear_actives' do it 'returns list which includes users seen within half a year' do - user = FactoryGirl.build(:user) + user = FactoryBot.build(:user) user.last_seen = Time.now - 4.month user.save expect(User.halfyear_actives).to include user end it 'returns list which does not include users seen within the last half a year' do - user = FactoryGirl.build(:user) + user = FactoryBot.build(:user) user.last_seen = Time.now - 7.month user.save expect(User.halfyear_actives).not_to include user @@ -113,7 +113,7 @@ describe User, :type => :model do describe 'hidden_shareables' do before do - @sm = FactoryGirl.create(:status_message) + @sm = FactoryBot.create(:status_message) @sm_id = @sm.id.to_s @sm_class = @sm.class.base_class.to_s end @@ -129,7 +129,7 @@ describe User, :type => :model do end it 'handles having multiple posts' do - sm2 = FactoryGirl.build(:status_message) + sm2 = FactoryBot.build(:status_message) alice.add_hidden_shareable(@sm_class, @sm_id) alice.add_hidden_shareable(sm2.class.base_class.to_s, sm2.id.to_s) @@ -137,7 +137,7 @@ describe User, :type => :model do end it 'handles having multiple shareable types' do - photo = FactoryGirl.create(:photo) + photo = FactoryBot.create(:photo) alice.add_hidden_shareable(photo.class.base_class.to_s, photo.id.to_s) alice.add_hidden_shareable(@sm_class, @sm_id) @@ -168,13 +168,13 @@ describe User, :type => :model do describe '#is_shareable_hidden?' do it 'returns true if the shareable is hidden' do - post = FactoryGirl.create(:status_message) + post = FactoryBot.create(:status_message) bob.toggle_hidden_shareable(post) expect(bob.is_shareable_hidden?(post)).to be true end it 'returns false if the shareable is not present' do - post = FactoryGirl.create(:status_message) + post = FactoryBot.create(:status_message) expect(bob.is_shareable_hidden?(post)).to be false end end @@ -184,7 +184,7 @@ describe User, :type => :model do describe 'overwriting people' do it 'does not overwrite old users with factory' do expect { - new_user = FactoryGirl.create(:user, :id => alice.id) + new_user = FactoryBot.create(:user, :id => alice.id) }.to raise_error ActiveRecord::StatementInvalid end @@ -234,14 +234,14 @@ describe User, :type => :model do end it 'requires uniqueness also amount Person objects with diaspora handle' do - p = FactoryGirl.create(:person, :diaspora_handle => "jimmy#{User.diaspora_id_host}") + p = FactoryBot.create(:person, :diaspora_handle => "jimmy#{User.diaspora_id_host}") alice.username = 'jimmy' expect(alice).not_to be_valid end it "downcases username" do - user = FactoryGirl.build(:user, :username => "WeIrDcAsE") + user = FactoryBot.build(:user, :username => "WeIrDcAsE") expect(user).to be_valid expect(user.username).to eq("weirdcase") end @@ -252,7 +252,7 @@ describe User, :type => :model do end it "strips leading and trailing whitespace" do - user = FactoryGirl.build(:user, :username => " janie ") + user = FactoryBot.build(:user, :username => " janie ") expect(user).to be_valid expect(user.username).to eq("janie") end @@ -432,7 +432,7 @@ describe User, :type => :model do end describe "with malicious params" do - let(:person) {FactoryGirl.create :person} + let(:person) {FactoryBot.create :person} before do @invalid_params = {:username => "ohai", :email => "ohai@example.com", @@ -456,7 +456,7 @@ describe User, :type => :model do describe '#process_invite_acceptence' do it 'sets the inviter on user' do inv = InvitationCode.create(:user => bob) - user = FactoryGirl.build(:user) + user = FactoryBot.build(:user) user.process_invite_acceptence(inv) expect(user.invited_by_id).to eq(bob.id) end @@ -771,7 +771,7 @@ describe User, :type => :model do describe "#retract" do let(:retraction) { double } - let(:post) { FactoryGirl.build(:status_message, author: bob.person, public: true) } + let(:post) { FactoryBot.build(:status_message, author: bob.person, public: true) } context "posts" do it "sends a retraction" do @@ -786,7 +786,7 @@ describe User, :type => :model do describe "#send_reset_password_instructions" do it "queues up a job to send the reset password instructions" do - user = FactoryGirl.create :user + user = FactoryBot.create :user expect(Workers::ResetPassword).to receive(:perform_async).with(user.id) user.send_reset_password_instructions end @@ -795,7 +795,7 @@ describe User, :type => :model do describe "#seed_aspects" do describe "create aspects" do let(:user) { - user = FactoryGirl.create(:user) + user = FactoryBot.create(:user) user.seed_aspects user } @@ -810,7 +810,7 @@ describe User, :type => :model do describe "autofollow sharing" do let(:user) { - FactoryGirl.create(:user) + FactoryBot.create(:user) } context "with autofollow sharing enabled" do @@ -837,8 +837,8 @@ describe User, :type => :model do end describe "#send_welcome_message" do - let(:user) { FactoryGirl.create(:user) } - let(:podmin) { FactoryGirl.create(:user) } + let(:user) { FactoryBot.create(:user) } + let(:podmin) { FactoryBot.create(:user) } context "with welcome message enabled" do before do @@ -959,7 +959,7 @@ describe User, :type => :model do describe "#clearable_attributes" do it "returns the clearable fields" do - user = FactoryGirl.create :user + user = FactoryBot.create :user expect(user.send(:clearable_fields)).to match_array( %w( language @@ -996,7 +996,7 @@ describe User, :type => :model do describe "#export" do it "doesn't change the filename when the user is saved" do - user = FactoryGirl.create(:user) + user = FactoryBot.create(:user) filename = user.export.filename user.save! @@ -1007,7 +1007,7 @@ describe User, :type => :model do describe "queue_export" do it "queues up a job to perform the export" do - user = FactoryGirl.create(:user) + user = FactoryBot.create(:user) user.update export: Tempfile.new([user.username, ".json.gz"]), exported_at: Time.zone.now expect(Workers::ExportUser).to receive(:perform_async).with(user.id) user.queue_export @@ -1018,7 +1018,7 @@ describe User, :type => :model do end describe "perform_export!" do - let(:user) { FactoryGirl.create(:user, exporting: true) } + let(:user) { FactoryBot.create(:user, exporting: true) } it "saves a json export to the user" do user.perform_export! @@ -1044,7 +1044,7 @@ describe User, :type => :model do describe "queue_export_photos" do it "queues up a job to perform the export photos" do - user = FactoryGirl.create(:user) + user = FactoryBot.create(:user) user.update exported_photos_file: Tempfile.new([user.username, ".zip"]), exported_photos_at: Time.zone.now expect(Workers::ExportPhotos).to receive(:perform_async).with(user.id) user.queue_export_photos @@ -1055,7 +1055,7 @@ describe User, :type => :model do end describe "perform_export_photos!" do - let(:user) { FactoryGirl.create(:user_with_aspect, exporting: true) } + let(:user) { FactoryBot.create(:user_with_aspect, exporting: true) } before do image = File.join(File.dirname(__FILE__), "..", "fixtures", "button.png") @@ -1146,7 +1146,7 @@ describe User, :type => :model do describe "active" do before do - closed_account = FactoryGirl.create(:user) + closed_account = FactoryBot.create(:user) closed_account.person.lock_access! end diff --git a/spec/presenters/avatar_presenter_spec.rb b/spec/presenters/avatar_presenter_spec.rb index a2269b9bc..bbf7d0348 100644 --- a/spec/presenters/avatar_presenter_spec.rb +++ b/spec/presenters/avatar_presenter_spec.rb @@ -3,20 +3,20 @@ describe AvatarPresenter do describe "#base_hash" do it "calls image_url() for the avatars" do - profile = FactoryGirl.create(:profile_with_image_url, person: alice.person) + profile = FactoryBot.create(:profile_with_image_url, person: alice.person) presenter = AvatarPresenter.new(profile) expect(profile).to receive(:image_url).exactly(4).times.and_call_original expect(presenter.base_hash).to be_present end it "returns nothing if no images set" do - profile = FactoryGirl.create(:profile, person: alice.person) + profile = FactoryBot.create(:profile, person: alice.person) presenter = AvatarPresenter.new(profile) expect(presenter.base_hash).to be_nil end it "returns all relevant sizes" do - profile = FactoryGirl.create(:profile_with_image_url, person: alice.person) + profile = FactoryBot.create(:profile_with_image_url, person: alice.person) base_hash = AvatarPresenter.new(profile).base_hash expect(base_hash[:small]).to be_truthy diff --git a/spec/presenters/conversation_presenter_spec.rb b/spec/presenters/conversation_presenter_spec.rb index 0cc1f14c4..0c5269b59 100644 --- a/spec/presenters/conversation_presenter_spec.rb +++ b/spec/presenters/conversation_presenter_spec.rb @@ -2,7 +2,7 @@ describe ConversationPresenter do before do - @conversation = FactoryGirl.create(:conversation) + @conversation = FactoryBot.create(:conversation) @presenter = ConversationPresenter.new(@conversation) end diff --git a/spec/presenters/likes_presenter_spec.rb b/spec/presenters/likes_presenter_spec.rb index cb80dd1f5..314c91d08 100644 --- a/spec/presenters/likes_presenter_spec.rb +++ b/spec/presenters/likes_presenter_spec.rb @@ -2,7 +2,7 @@ describe LikesPresenter do before do - bob.person.profile = FactoryGirl.create(:profile_with_image_url) + bob.person.profile = FactoryBot.create(:profile_with_image_url) @status = alice.post( :status_message, text: "This is a status message from alice", diff --git a/spec/presenters/notification_presenter_spec.rb b/spec/presenters/notification_presenter_spec.rb index ce760aed8..5d22396ff 100644 --- a/spec/presenters/notification_presenter_spec.rb +++ b/spec/presenters/notification_presenter_spec.rb @@ -2,8 +2,8 @@ describe NotificationPresenter do it "makes json with target" do - post = FactoryGirl.create(:status_message) - notification = FactoryGirl.create(:notification, recipient: alice, target: post) + post = FactoryBot.create(:status_message) + notification = FactoryBot.create(:notification, recipient: alice, target: post) json = NotificationPresenter.new(notification).as_api_json expect(json[:guid]).to eq(notification.guid) expect(json[:type]).to eq("also_commented") @@ -14,7 +14,7 @@ describe NotificationPresenter do end it "returns target on mentioned" do - mentioned_post = FactoryGirl.create(:status_message_in_aspect, author: alice.person, text: text_mentioning(bob)) + mentioned_post = FactoryBot.create(:status_message_in_aspect, author: alice.person, text: text_mentioning(bob)) Notifications::MentionedInPost.notify(mentioned_post, [bob.id]) notification = Notifications::MentionedInPost.last json = NotificationPresenter.new(notification).as_api_json @@ -22,8 +22,8 @@ describe NotificationPresenter do end it "returns target on mentioned in comment" do - post = FactoryGirl.create(:status_message, public: true) - mentioned_comment = FactoryGirl.create(:comment, post: post, author: alice.person, text: text_mentioning(bob)) + post = FactoryBot.create(:status_message, public: true) + mentioned_comment = FactoryBot.create(:comment, post: post, author: alice.person, text: text_mentioning(bob)) Notifications::MentionedInComment.notify(mentioned_comment, [bob.id]) notification = Notifications::MentionedInComment.last json = NotificationPresenter.new(notification).as_api_json @@ -31,9 +31,9 @@ describe NotificationPresenter do end it "returns target on also_commented" do - post = FactoryGirl.create(:status_message) + post = FactoryBot.create(:status_message) bob.comment!(post, "cool") - comment2 = FactoryGirl.create(:comment, post: post) + comment2 = FactoryBot.create(:comment, post: post) Notifications::AlsoCommented.notify(comment2, []) notification = Notifications::AlsoCommented.last json = NotificationPresenter.new(notification).as_api_json @@ -41,7 +41,7 @@ describe NotificationPresenter do end it "returns no target on started_sharing" do - contact = FactoryGirl.create(:contact) + contact = FactoryBot.create(:contact) Notifications::StartedSharing.notify(contact, [bob.id]) notification = Notifications::StartedSharing.last json = NotificationPresenter.new(notification).as_api_json @@ -49,7 +49,7 @@ describe NotificationPresenter do end it "returns no target on contacts_birthday" do - contact = FactoryGirl.create(:contact) + contact = FactoryBot.create(:contact) Notifications::ContactsBirthday.notify(contact, [bob.id]) notification = Notifications::ContactsBirthday.last json = NotificationPresenter.new(notification).as_api_json diff --git a/spec/presenters/o_embed_presenter_spec.rb b/spec/presenters/o_embed_presenter_spec.rb index 355598a71..bddf7d97f 100644 --- a/spec/presenters/o_embed_presenter_spec.rb +++ b/spec/presenters/o_embed_presenter_spec.rb @@ -2,7 +2,7 @@ describe OEmbedPresenter do before do - @oembed = OEmbedPresenter.new(FactoryGirl.create(:status_message)) + @oembed = OEmbedPresenter.new(FactoryBot.create(:status_message)) end it 'is a hash' do @@ -11,7 +11,7 @@ describe OEmbedPresenter do context 'required options from oembed spec' do it 'supports maxheight + maxwidth(required)' do - oembed = OEmbedPresenter.new(FactoryGirl.create(:status_message), :maxwidth => 200, :maxheight => 300).as_json + oembed = OEmbedPresenter.new(FactoryBot.create(:status_message), :maxwidth => 200, :maxheight => 300).as_json expect(oembed[:width]).to eq(200) expect(oembed[:height]).to eq(300) end diff --git a/spec/presenters/person_presenter_spec.rb b/spec/presenters/person_presenter_spec.rb index 5a8796661..73183accd 100644 --- a/spec/presenters/person_presenter_spec.rb +++ b/spec/presenters/person_presenter_spec.rb @@ -2,22 +2,22 @@ describe PersonPresenter do let(:profile_user) { - FactoryGirl.create(:user_with_aspect, - profile: FactoryGirl.create(:profile_with_image_url)) + FactoryBot.create(:user_with_aspect, + profile: FactoryBot.create(:profile_with_image_url)) } let(:person) { profile_user.person } let(:mutual_contact) { - FactoryGirl.create(:contact, user: current_user, person: person, sharing: true, receiving: true) + FactoryBot.create(:contact, user: current_user, person: person, sharing: true, receiving: true) } let(:receiving_contact) { - FactoryGirl.create(:contact, user: current_user, person: person, sharing: false, receiving: true) + FactoryBot.create(:contact, user: current_user, person: person, sharing: false, receiving: true) } let(:sharing_contact) { - FactoryGirl.create(:contact, user: current_user, person: person, sharing: true, receiving: false) + FactoryBot.create(:contact, user: current_user, person: person, sharing: true, receiving: false) } let(:non_contact) { - FactoryGirl.create(:contact, user: current_user, person: person, sharing: false, receiving: false) + FactoryBot.create(:contact, user: current_user, person: person, sharing: false, receiving: false) } describe "#as_json" do @@ -38,7 +38,7 @@ describe PersonPresenter do end context "with a current_user" do - let(:current_user) { FactoryGirl.create(:user) } + let(:current_user) { FactoryBot.create(:user) } let(:presenter){ PersonPresenter.new(person, current_user) } # here private information == addtional user profile, because additional profile by default is private @@ -90,7 +90,7 @@ describe PersonPresenter do end describe "#full_hash" do - let(:current_user) { FactoryGirl.create(:user) } + let(:current_user) { FactoryBot.create(:user) } before do @p = PersonPresenter.new(person, current_user) @@ -133,7 +133,7 @@ describe PersonPresenter do end describe "#hovercard" do - let(:current_user) { FactoryGirl.create(:user) } + let(:current_user) { FactoryBot.create(:user) } let(:presenter) { PersonPresenter.new(person, current_user) } it "contains data required for hovercard" do @@ -148,12 +148,12 @@ describe PersonPresenter do describe "#profile_hash_as_api_json" do let(:current_user) { - FactoryGirl.create(:user, - profile: FactoryGirl.create(:profile_with_image_url)) + FactoryBot.create(:user, + profile: FactoryBot.create(:profile_with_image_url)) } before do - alice.person.profile = FactoryGirl.create(:profile_with_image_url) + alice.person.profile = FactoryBot.create(:profile_with_image_url) end it "contains internal profile if self" do diff --git a/spec/presenters/poll_presenter_spec.rb b/spec/presenters/poll_presenter_spec.rb index 014df4362..025250ade 100644 --- a/spec/presenters/poll_presenter_spec.rb +++ b/spec/presenters/poll_presenter_spec.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true describe PollPresenter do - let(:poll) { FactoryGirl.create(:status_message_with_poll, public: true).poll } + let(:poll) { FactoryBot.create(:status_message_with_poll, public: true).poll } let(:poll_answer) { poll.poll_answers.first } describe "#poll" do diff --git a/spec/presenters/post_interaction_presenter_spec.rb b/spec/presenters/post_interaction_presenter_spec.rb index 4623493fd..b0b5ee373 100644 --- a/spec/presenters/post_interaction_presenter_spec.rb +++ b/spec/presenters/post_interaction_presenter_spec.rb @@ -2,10 +2,10 @@ describe PostInteractionPresenter do let(:status_message_without_participation) { - FactoryGirl.create(:status_message_without_participation) + FactoryBot.create(:status_message_without_participation) } let(:status_message_with_participations) { - FactoryGirl.create(:status_message_with_participations, participants: [alice, bob]) + FactoryBot.create(:status_message_with_participations, participants: [alice, bob]) } context "with an user" do diff --git a/spec/presenters/post_presenter_spec.rb b/spec/presenters/post_presenter_spec.rb index f886a153c..1bb488794 100644 --- a/spec/presenters/post_presenter_spec.rb +++ b/spec/presenters/post_presenter_spec.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true describe PostPresenter do - let(:status_message) { FactoryGirl.create(:status_message, public: true) } - let(:status_message_with_poll) { FactoryGirl.create(:status_message_with_poll, public: true) } + let(:status_message) { FactoryBot.create(:status_message, public: true) } + let(:status_message_with_poll) { FactoryBot.create(:status_message_with_poll, public: true) } let(:presenter) { PostPresenter.new(status_message, bob) } let(:unauthenticated_presenter) { PostPresenter.new(status_message) } @@ -95,9 +95,9 @@ describe PostPresenter do describe "#root" do it "does not raise if the absolute_root does not exists" do - first_reshare = FactoryGirl.create :reshare + first_reshare = FactoryBot.create :reshare first_reshare.root = nil - reshare = FactoryGirl.create :reshare, root: first_reshare + reshare = FactoryBot.create :reshare, root: first_reshare expect { PostPresenter.new(reshare).send(:root) @@ -105,7 +105,7 @@ describe PostPresenter do end it "does not raise if the root does not exists" do - reshare = FactoryGirl.create :reshare + reshare = FactoryBot.create :reshare reshare.root = nil expect { PostPresenter.new(reshare).send(:root) @@ -154,21 +154,21 @@ describe PostPresenter do describe "#tags" do it "returns the tag of the post" do - post = FactoryGirl.create(:status_message, text: "#hello #world", public: true) + post = FactoryBot.create(:status_message, text: "#hello #world", public: true) expect(PostPresenter.new(post).send(:tags)).to match_array(%w(hello world)) end it "returns the tag of the absolute_root of a Reshare" do - post = FactoryGirl.create(:status_message, text: "#hello #world", public: true) - first_reshare = FactoryGirl.create(:reshare, root: post) - second_reshare = FactoryGirl.create(:reshare, root: first_reshare) + post = FactoryBot.create(:status_message, text: "#hello #world", public: true) + first_reshare = FactoryBot.create(:reshare, root: post) + second_reshare = FactoryBot.create(:reshare, root: first_reshare) expect(PostPresenter.new(second_reshare).send(:tags)).to match_array(%w(hello world)) end it "does not raise if the root of a reshare does not exist anymore" do - reshare = FactoryGirl.create(:reshare) + reshare = FactoryBot.create(:reshare) reshare.root = nil expect(PostPresenter.new(reshare).send(:tags)).to eq([]) @@ -177,19 +177,19 @@ describe PostPresenter do describe "#description" do it "returns the first 1000 chars of the text" do - post = FactoryGirl.create(:status_message, text: "a" * 1001, public: true) + post = FactoryBot.create(:status_message, text: "a" * 1001, public: true) expect(PostPresenter.new(post).send(:description)).to eq("#{'a' * 997}...") end it "does not change the message if less or equal 1000 chars" do - post = FactoryGirl.create(:status_message, text: "a" * 1000, public: true) + post = FactoryBot.create(:status_message, text: "a" * 1000, public: true) expect(PostPresenter.new(post).send(:description)).to eq("a" * 1000) end it "does not raise if the root of a reshare does not exist anymore" do - reshare = FactoryGirl.create(:reshare) + reshare = FactoryBot.create(:reshare) reshare.update(root: nil) expect(PostPresenter.new(Post.find(reshare.id)).send(:description)).to eq(nil) @@ -210,14 +210,14 @@ describe PostPresenter do end it "returns the open graph cache data" do - open_graph_cache = FactoryGirl.create(:open_graph_cache) - post = FactoryGirl.create(:status_message, public: true, open_graph_cache: open_graph_cache) + open_graph_cache = FactoryBot.create(:open_graph_cache) + post = FactoryBot.create(:status_message, public: true, open_graph_cache: open_graph_cache) expect(PostPresenter.new(post).send(:build_open_graph_cache)).to eq(open_graph_cache.as_api_response(:backbone)) end it "returns the open graph data in the api" do - open_graph_cache = FactoryGirl.create(:open_graph_cache) - post = FactoryGirl.create(:status_message, public: true, open_graph_cache: open_graph_cache) + open_graph_cache = FactoryBot.create(:open_graph_cache) + post = FactoryBot.create(:status_message, public: true, open_graph_cache: open_graph_cache) expect(PostPresenter.new(post).as_api_response[:open_graph_object][:url]).to eq(open_graph_cache.url) end end diff --git a/spec/presenters/profile_presenter_spec.rb b/spec/presenters/profile_presenter_spec.rb index 44167a150..43eca5d3d 100644 --- a/spec/presenters/profile_presenter_spec.rb +++ b/spec/presenters/profile_presenter_spec.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true describe ProfilePresenter do - let(:profile) { FactoryGirl.create(:profile_with_image_url, person: alice.person) } + let(:profile) { FactoryBot.create(:profile_with_image_url, person: alice.person) } describe "#for_hovercard" do it "contains tags and avatar" do diff --git a/spec/presenters/social_relay_presenter_spec.rb b/spec/presenters/social_relay_presenter_spec.rb index 3e8215f9c..bcec75695 100644 --- a/spec/presenters/social_relay_presenter_spec.rb +++ b/spec/presenters/social_relay_presenter_spec.rb @@ -42,10 +42,10 @@ describe SocialRelayPresenter do before do AppConfig.relay.inbound.pod_tags = "" AppConfig.relay.inbound.include_user_tags = true - ceetag = FactoryGirl.create(:tag, name: "cee") - lootag = FactoryGirl.create(:tag, name: "loo") - FactoryGirl.create(:tag_following, user: alice, tag: ceetag) - FactoryGirl.create(:tag_following, user: alice, tag: lootag) + ceetag = FactoryBot.create(:tag, name: "cee") + lootag = FactoryBot.create(:tag, name: "loo") + FactoryBot.create(:tag_following, user: alice, tag: ceetag) + FactoryBot.create(:tag_following, user: alice, tag: lootag) alice.last_seen = Time.zone.now - 2.months alice.save end @@ -63,10 +63,10 @@ describe SocialRelayPresenter do before do AppConfig.relay.inbound.pod_tags = "foo, bar" AppConfig.relay.inbound.include_user_tags = true - ceetag = FactoryGirl.create(:tag, name: "cee") - lootag = FactoryGirl.create(:tag, name: "loo") - FactoryGirl.create(:tag_following, user: alice, tag: ceetag) - FactoryGirl.create(:tag_following, user: alice, tag: lootag) + ceetag = FactoryBot.create(:tag, name: "cee") + lootag = FactoryBot.create(:tag, name: "loo") + FactoryBot.create(:tag_following, user: alice, tag: ceetag) + FactoryBot.create(:tag_following, user: alice, tag: lootag) alice.last_seen = Time.zone.now - 2.months alice.save end @@ -84,10 +84,10 @@ describe SocialRelayPresenter do before do AppConfig.relay.inbound.pod_tags = "" AppConfig.relay.inbound.include_user_tags = true - ceetag = FactoryGirl.create(:tag, name: "cee") - lootag = FactoryGirl.create(:tag, name: "loo") - FactoryGirl.create(:tag_following, user: alice, tag: ceetag) - FactoryGirl.create(:tag_following, user: alice, tag: lootag) + ceetag = FactoryBot.create(:tag, name: "cee") + lootag = FactoryBot.create(:tag, name: "loo") + FactoryBot.create(:tag_following, user: alice, tag: ceetag) + FactoryBot.create(:tag_following, user: alice, tag: lootag) alice.last_seen = Time.zone.now - 8.months alice.save end @@ -106,8 +106,8 @@ describe SocialRelayPresenter do AppConfig.relay.inbound.scope = "all" AppConfig.relay.inbound.pod_tags = "foo,bar" AppConfig.relay.inbound.include_user_tags = true - ceetag = FactoryGirl.create(:tag, name: "cee") - FactoryGirl.create(:tag_following, user: alice, tag: ceetag) + ceetag = FactoryBot.create(:tag, name: "cee") + FactoryBot.create(:tag_following, user: alice, tag: ceetag) end it "provides empty tags list" do diff --git a/spec/serializers/export/aspect_serializer_spec.rb b/spec/serializers/export/aspect_serializer_spec.rb index 41ea5e874..43b265c03 100644 --- a/spec/serializers/export/aspect_serializer_spec.rb +++ b/spec/serializers/export/aspect_serializer_spec.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true describe Export::AspectSerializer do - let(:aspect) { FactoryGirl.create(:aspect) } + let(:aspect) { FactoryBot.create(:aspect) } let(:serializer) { Export::AspectSerializer.new(aspect) } it "has aspect attributes" do diff --git a/spec/serializers/export/contact_serializer_spec.rb b/spec/serializers/export/contact_serializer_spec.rb index 53be08f27..f19f82af6 100644 --- a/spec/serializers/export/contact_serializer_spec.rb +++ b/spec/serializers/export/contact_serializer_spec.rb @@ -1,9 +1,9 @@ # frozen_string_literal: true describe Export::ContactSerializer do - let(:contact) { FactoryGirl.create(:contact) } + let(:contact) { FactoryBot.create(:contact) } let(:serializer) { Export::ContactSerializer.new(contact) } - let(:aspect) { FactoryGirl.create(:aspect) } + let(:aspect) { FactoryBot.create(:aspect) } it "has contact attributes" do expect(serializer.attributes).to eq( diff --git a/spec/serializers/export/others_data_serializer_spec.rb b/spec/serializers/export/others_data_serializer_spec.rb index 2c40adfb8..55423b3f8 100644 --- a/spec/serializers/export/others_data_serializer_spec.rb +++ b/spec/serializers/export/others_data_serializer_spec.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true describe Export::OthersDataSerializer do - let(:user) { FactoryGirl.create(:user) } + let(:user) { FactoryBot.create(:user) } let(:serializer) { Export::OthersDataSerializer.new(user.id) } it "uses FederationEntitySerializer for array serializing relayables" do diff --git a/spec/serializers/export/own_post_serializer_spec.rb b/spec/serializers/export/own_post_serializer_spec.rb index b9580785f..81a194df3 100644 --- a/spec/serializers/export/own_post_serializer_spec.rb +++ b/spec/serializers/export/own_post_serializer_spec.rb @@ -1,10 +1,10 @@ # frozen_string_literal: true describe Export::OwnPostSerializer do - let(:author) { FactoryGirl.create(:user_with_aspect).person } + let(:author) { FactoryBot.create(:user_with_aspect).person } before do - author.owner.share_with(FactoryGirl.create(:person), author.owner.aspects.first) + author.owner.share_with(FactoryBot.create(:person), author.owner.aspects.first) end it_behaves_like "a federation entity serializer" do @@ -28,10 +28,10 @@ describe Export::OwnPostSerializer do context "with public post" do let(:post) { - FactoryGirl.create( + FactoryBot.create( :status_message_with_participations, author: author, - participants: Array.new(2) { FactoryGirl.create(:person) }, + participants: Array.new(2) { FactoryBot.create(:person) }, public: true ) } diff --git a/spec/serializers/export/own_relayables_serializer_spec.rb b/spec/serializers/export/own_relayables_serializer_spec.rb index d11dee61d..9d9e43e93 100644 --- a/spec/serializers/export/own_relayables_serializer_spec.rb +++ b/spec/serializers/export/own_relayables_serializer_spec.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true describe Export::OwnRelayablesSerializer do - let(:comment) { FactoryGirl.create(:comment) } - let!(:signature) { FactoryGirl.create(:comment_signature, comment: comment) } + let(:comment) { FactoryBot.create(:comment) } + let!(:signature) { FactoryBot.create(:comment_signature, comment: comment) } let(:instance) { Export::OwnRelayablesSerializer.new(comment, root: false) } it "doesn't include author signature to the entity data" do diff --git a/spec/serializers/export/user_serializer_spec.rb b/spec/serializers/export/user_serializer_spec.rb index a316ef3d9..52fa11e43 100644 --- a/spec/serializers/export/user_serializer_spec.rb +++ b/spec/serializers/export/user_serializer_spec.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true describe Export::UserSerializer do - let(:user) { FactoryGirl.create(:user) } + let(:user) { FactoryBot.create(:user) } let(:serializer) { Export::UserSerializer.new(user.id, root: false) } it "has basic user's attributes" do diff --git a/spec/serializers/notification_serializer_spec.rb b/spec/serializers/notification_serializer_spec.rb index 3a5b5f914..9610b946c 100644 --- a/spec/serializers/notification_serializer_spec.rb +++ b/spec/serializers/notification_serializer_spec.rb @@ -8,7 +8,7 @@ describe NotificationSerializer do notifications_controller.request = ActionDispatch::TestRequest.new(host: AppConfig.pod_uri) end - let(:notification) { FactoryGirl.create(:notification) } + let(:notification) { FactoryBot.create(:notification) } let(:json_output) { NotificationSerializer.new(notification, context: notifications_controller).to_json } diff --git a/spec/services/diaspora_link_service_spec.rb b/spec/services/diaspora_link_service_spec.rb index c65004e31..19723c687 100644 --- a/spec/services/diaspora_link_service_spec.rb +++ b/spec/services/diaspora_link_service_spec.rb @@ -5,7 +5,7 @@ describe DiasporaLinkService do describe "#find_or_fetch_entity" do context "when entity is known" do - let(:post) { FactoryGirl.create(:status_message) } + let(:post) { FactoryBot.create(:status_message) } let(:link) { "diaspora://#{post.author.diaspora_handle}/post/#{post.guid}" } it "returns the entity" do @@ -14,7 +14,7 @@ describe DiasporaLinkService do end context "when entity is unknown" do - let(:remote_person) { FactoryGirl.create(:person) } + let(:remote_person) { FactoryBot.create(:person) } let(:guid) { "1234567890abcdef" } let(:link) { "diaspora://#{remote_person.diaspora_handle}/post/#{guid}" } @@ -22,7 +22,7 @@ describe DiasporaLinkService do expect(DiasporaFederation::Federation::Fetcher) .to receive(:fetch_public) .with(remote_person.diaspora_handle, "post", guid) { - FactoryGirl.create(:status_message, author: remote_person, guid: guid) + FactoryBot.create(:status_message, author: remote_person, guid: guid) } entity = service.find_or_fetch_entity @@ -54,7 +54,7 @@ describe DiasporaLinkService do end context "with only a diaspora ID" do - let(:person) { FactoryGirl.create(:person) } + let(:person) { FactoryBot.create(:person) } let(:link) { "diaspora://#{person.diaspora_handle}" } it "returns the person" do diff --git a/spec/services/notification_service_spec.rb b/spec/services/notification_service_spec.rb index 59c72b74f..ce80937fc 100644 --- a/spec/services/notification_service_spec.rb +++ b/spec/services/notification_service_spec.rb @@ -4,13 +4,13 @@ describe NotificationService do describe "notification interrelation" do context "with mention in comment" do let(:status_message) { - FactoryGirl.create(:status_message, public: true, author: alice.person).tap {|status_message| + FactoryBot.create(:status_message, public: true, author: alice.person).tap {|status_message| eve.comment!(status_message, "whatever") } } let(:comment) { - FactoryGirl.create( + FactoryBot.create( :comment, author: bob.person, text: text_mentioning(alice, eve), @@ -82,7 +82,7 @@ describe NotificationService do public: true, to: "all" ) - @notification = FactoryGirl.create(:notification, recipient: alice, target: @post) + @notification = FactoryBot.create(:notification, recipient: alice, target: @post) @service = NotificationService.new(alice) end diff --git a/spec/services/poll_participation_service_spec.rb b/spec/services/poll_participation_service_spec.rb index d9b0e7b6c..c52f7fa75 100644 --- a/spec/services/poll_participation_service_spec.rb +++ b/spec/services/poll_participation_service_spec.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true describe PollParticipationService do - let(:poll_post) { FactoryGirl.create(:status_message_with_poll, public: true) } + let(:poll_post) { FactoryBot.create(:status_message_with_poll, public: true) } let(:poll_answer) { poll_post.poll.poll_answers.first } describe "voting on poll" do diff --git a/spec/services/post_service_spec.rb b/spec/services/post_service_spec.rb index c7c21e83b..491c9a7e4 100644 --- a/spec/services/post_service_spec.rb +++ b/spec/services/post_service_spec.rb @@ -116,8 +116,8 @@ describe PostService do let(:status_text) { text_mentioning(alice) } it "marks a corresponding notifications as read" do - FactoryGirl.create(:notification, recipient: alice, target: post, unread: true) - FactoryGirl.create(:notification, recipient: alice, target: post, unread: true) + FactoryBot.create(:notification, recipient: alice, target: post, unread: true) + FactoryBot.create(:notification, recipient: alice, target: post, unread: true) expect { PostService.new(alice).mark_user_notifications(post.id) @@ -133,7 +133,7 @@ describe PostService do end it "marks a corresponding mention in comment notification as read" do - notification = FactoryGirl.create(:notification_mentioned_in_comment) + notification = FactoryBot.create(:notification_mentioned_in_comment) status_message = notification.target.mentions_container.parent user = notification.recipient @@ -144,7 +144,7 @@ describe PostService do it "does not change the update_at date/time for post notifications" do notification = Timecop.travel(1.minute.ago) do - FactoryGirl.create(:notification, recipient: alice, target: post, unread: true) + FactoryBot.create(:notification, recipient: alice, target: post, unread: true) end expect { @@ -206,8 +206,8 @@ describe PostService do describe "#mentionable_in_comment" do describe "semi-integration test" do let(:post_author_attributes) { {first_name: "Ro#{r_str}"} } - let(:post_author) { FactoryGirl.create(:person, post_author_attributes) } - let(:current_user) { FactoryGirl.create(:user_with_aspect) } + let(:post_author) { FactoryBot.create(:person, post_author_attributes) } + let(:current_user) { FactoryBot.create(:user_with_aspect) } let(:post_service) { PostService.new(current_user) } shared_context "with commenters and likers" do @@ -222,33 +222,33 @@ describe PostService do end let!(:commenter1) { - FactoryGirl.create(:person, id: ids.shift, first_name: "Ro1#{r_str}").tap {|person| - FactoryGirl.create(:comment, author: person, post: post) + FactoryBot.create(:person, id: ids.shift, first_name: "Ro1#{r_str}").tap {|person| + FactoryBot.create(:comment, author: person, post: post) } } let!(:commenter2) { - FactoryGirl.create(:person, id: ids.shift, first_name: "Ro2#{r_str}").tap {|person| - FactoryGirl.create(:comment, author: person, post: post) + FactoryBot.create(:person, id: ids.shift, first_name: "Ro2#{r_str}").tap {|person| + FactoryBot.create(:comment, author: person, post: post) } } let!(:liker1) { - FactoryGirl.create(:person, id: ids.shift, first_name: "Ro1#{r_str}").tap {|person| - FactoryGirl.create(:like, author: person, target: post) + FactoryBot.create(:person, id: ids.shift, first_name: "Ro1#{r_str}").tap {|person| + FactoryBot.create(:like, author: person, target: post) } } let!(:liker2) { - FactoryGirl.create(:person, id: ids.shift, first_name: "Ro2#{r_str}").tap {|person| - FactoryGirl.create(:like, author: person, target: post) + FactoryBot.create(:person, id: ids.shift, first_name: "Ro2#{r_str}").tap {|person| + FactoryBot.create(:like, author: person, target: post) } } end shared_context "with a current user's friend" do let!(:current_users_friend) { - FactoryGirl.create(:person).tap {|friend| + FactoryBot.create(:person).tap {|friend| current_user.contacts.create!( person: friend, aspects: [current_user.aspects.first], @@ -260,7 +260,7 @@ describe PostService do end context "with private post" do - let(:post) { FactoryGirl.create(:status_message, text: "ohai", author: post_author) } + let(:post) { FactoryBot.create(:status_message, text: "ohai", author: post_author) } context "when the post doesn't have a visibility for the current user" do it "doesn't find a post and raises an exception" do @@ -301,7 +301,7 @@ describe PostService do end context "with public post" do - let(:post) { FactoryGirl.create(:status_message, text: "ohai", public: true, author: post_author) } + let(:post) { FactoryBot.create(:status_message, text: "ohai", public: true, author: post_author) } context "with commenters and likers and with a current user's friend" do include_context "with commenters and likers" @@ -322,11 +322,11 @@ describe PostService do end it "doesn't include people with non-matching names" do - commenter = FactoryGirl.create(:person, first_name: "RRR#{r_str}") - FactoryGirl.create(:comment, author: commenter) - liker = FactoryGirl.create(:person, first_name: "RRR#{r_str}") - FactoryGirl.create(:like, author: liker) - friend = FactoryGirl.create(:person, first_name: "RRR#{r_str}") + commenter = FactoryBot.create(:person, first_name: "RRR#{r_str}") + FactoryBot.create(:comment, author: commenter) + liker = FactoryBot.create(:person, first_name: "RRR#{r_str}") + FactoryBot.create(:like, author: liker) + friend = FactoryBot.create(:person, first_name: "RRR#{r_str}") current_user.contacts.create!( person: friend, aspects: [current_user.aspects.first], @@ -375,8 +375,8 @@ describe PostService do end it "renders a commenter with multiple comments only once" do - person = FactoryGirl.create(:person, first_name: "Ro2#{r_str}") - 2.times { FactoryGirl.create(:comment, author: person, post: post) } + person = FactoryBot.create(:person, first_name: "Ro2#{r_str}") + 2.times { FactoryBot.create(:comment, author: person, post: post) } expect(post_service.mentionable_in_comment(post.id, person.first_name).length).to eq(1) end end @@ -406,7 +406,7 @@ describe PostService do it "calls Person.limit" do 16.times { - FactoryGirl.create(:comment, author: FactoryGirl.create(:person, first_name: "Ro#{r_str}"), post: post) + FactoryBot.create(:comment, author: FactoryBot.create(:person, first_name: "Ro#{r_str}"), post: post) } expect(post_service.mentionable_in_comment(post.id, "Ro").length).to eq(15) end diff --git a/spec/shared_behaviors/mentions_container.rb b/spec/shared_behaviors/mentions_container.rb index cfc71452c..97ed5b663 100644 --- a/spec/shared_behaviors/mentions_container.rb +++ b/spec/shared_behaviors/mentions_container.rb @@ -6,7 +6,7 @@ shared_examples_for "it is mentions container" do "@{Raphael; #{people[0].diaspora_handle}} can mention people like @{Ilya; #{people[1].diaspora_handle}}"\ "can mention people like @{Daniel; #{people[2].diaspora_handle}}" } - let(:target) { FactoryGirl.build(described_class.to_s.underscore.to_sym, text: test_string, author: alice.person) } + let(:target) { FactoryBot.build(described_class.to_s.underscore.to_sym, text: test_string, author: alice.person) } let(:target_persisted) { target.save! target diff --git a/spec/shared_behaviors/receiving.rb b/spec/shared_behaviors/receiving.rb index 8c2c8da65..306622324 100644 --- a/spec/shared_behaviors/receiving.rb +++ b/spec/shared_behaviors/receiving.rb @@ -117,7 +117,7 @@ shared_examples_for "it sends a participation to the author" do it "uses the first user with an admin role if no admin is configured in the config" do AppConfig.admins.account = nil - admin_role = FactoryGirl.create(:role, name: "admin") + admin_role = FactoryBot.create(:role, name: "admin") expect(Diaspora::Federation::Dispatcher).to receive(:build) do |user, _participation, _opts| expect(user.username).to eq(admin_role.person.owner.username) diff --git a/spec/shared_behaviors/references.rb b/spec/shared_behaviors/references.rb index f744069c3..b9f65c13c 100644 --- a/spec/shared_behaviors/references.rb +++ b/spec/shared_behaviors/references.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true shared_examples_for "a reference source" do - let!(:source) { FactoryGirl.create(described_class.to_s.underscore.to_sym) } - let!(:reference) { FactoryGirl.create(:reference, source: source) } + let!(:source) { FactoryBot.create(described_class.to_s.underscore.to_sym) } + let!(:reference) { FactoryBot.create(:reference, source: source) } describe "references" do it "returns the references" do @@ -17,12 +17,12 @@ shared_examples_for "a reference source" do describe "#create_references" do it "creates a reference for every referenced post after create" do - target1 = FactoryGirl.create(:status_message) - target2 = FactoryGirl.create(:status_message) + target1 = FactoryBot.create(:status_message) + target2 = FactoryBot.create(:status_message) text = "Have a look at [this post](diaspora://#{target1.diaspora_handle}/post/#{target1.guid}) and " \ "this one too diaspora://#{target2.diaspora_handle}/post/#{target2.guid}." - post = FactoryGirl.build(described_class.to_s.underscore.to_sym, text: text) + post = FactoryBot.build(described_class.to_s.underscore.to_sym, text: text) post.save expect(post.references.map(&:target).map(&:guid)).to match_array([target1, target2].map(&:guid)) @@ -31,41 +31,41 @@ shared_examples_for "a reference source" do it "ignores a reference with a unknown guid" do text = "Try this: `diaspora://unknown@localhost:3000/post/thislookslikeavalidguid123456789`" - post = FactoryGirl.build(described_class.to_s.underscore.to_sym, text: text) + post = FactoryBot.build(described_class.to_s.underscore.to_sym, text: text) post.save expect(post.references).to be_empty end it "ignores a reference with an invalid entity type" do - target = FactoryGirl.create(:status_message) + target = FactoryBot.create(:status_message) text = "Try this: `diaspora://#{target.diaspora_handle}/posts/#{target.guid}`" - post = FactoryGirl.build(described_class.to_s.underscore.to_sym, text: text) + post = FactoryBot.build(described_class.to_s.underscore.to_sym, text: text) post.save expect(post.references).to be_empty end it "only creates one reference, even when it is referenced twice" do - target = FactoryGirl.create(:status_message) + target = FactoryBot.create(:status_message) text = "Have a look at [this post](diaspora://#{target.diaspora_handle}/post/#{target.guid}) and " \ "this one too diaspora://#{target.diaspora_handle}/post/#{target.guid}." - post = FactoryGirl.build(described_class.to_s.underscore.to_sym, text: text) + post = FactoryBot.build(described_class.to_s.underscore.to_sym, text: text) post.save expect(post.references.map(&:target).map(&:guid)).to match_array([target.guid]) end it "only creates references, when the author of the known entity matches" do - target1 = FactoryGirl.create(:status_message) - target2 = FactoryGirl.create(:status_message) + target1 = FactoryBot.create(:status_message) + target2 = FactoryBot.create(:status_message) text = "Have a look at [this post](diaspora://#{target1.diaspora_handle}/post/#{target1.guid}) and " \ "this one too diaspora://#{target1.diaspora_handle}/post/#{target2.guid}." - post = FactoryGirl.build(described_class.to_s.underscore.to_sym, text: text) + post = FactoryBot.build(described_class.to_s.underscore.to_sym, text: text) post.save expect(post.references.map(&:target).map(&:guid)).to match_array([target1.guid]) @@ -74,8 +74,8 @@ shared_examples_for "a reference source" do end shared_examples_for "a reference target" do - let!(:target) { FactoryGirl.create(described_class.to_s.underscore.to_sym) } - let!(:reference) { FactoryGirl.create(:reference, target: target) } + let!(:target) { FactoryBot.create(described_class.to_s.underscore.to_sym) } + let!(:reference) { FactoryBot.create(:reference, target: target) } describe "referenced_by" do it "returns the references where the target is referenced" do diff --git a/spec/shared_behaviors/relayable.rb b/spec/shared_behaviors/relayable.rb index a80476c28..013323391 100644 --- a/spec/shared_behaviors/relayable.rb +++ b/spec/shared_behaviors/relayable.rb @@ -41,8 +41,8 @@ shared_examples_for "it is relayable" do end it "returns remote persons of the parents original audience not on same pod as the author, if author is remote" do - person1 = FactoryGirl.create(:person, pod: remote_raphael.pod) - person2 = FactoryGirl.create(:person, pod: FactoryGirl.create(:pod)) + person1 = FactoryBot.create(:person, pod: remote_raphael.pod) + person2 = FactoryBot.create(:person, pod: FactoryBot.create(:pod)) local_luke.share_with(person1, local_luke.aspects.first) local_luke.share_with(person2, local_luke.aspects.first) @@ -65,7 +65,7 @@ shared_examples_for "it is relayable" do remote_object_on_local_parent.signature = signature_class.new( author_signature: "signature", additional_data: {"new_property" => "some text"}, - signature_order: FactoryGirl.create(:signature_order) + signature_order: FactoryBot.create(:signature_order) ) end diff --git a/spec/shared_behaviors/shareable.rb b/spec/shared_behaviors/shareable.rb index fba7aaeae..aeac6021b 100644 --- a/spec/shared_behaviors/shareable.rb +++ b/spec/shared_behaviors/shareable.rb @@ -2,10 +2,10 @@ shared_examples_for "a shareable" do describe "#subscribed_pods_uris" do - let(:pods) { Array.new(3) { FactoryGirl.create(:pod) } } + let(:pods) { Array.new(3) { FactoryBot.create(:pod) } } let(:subscribers) { pods.map {|pod| - FactoryGirl.create(:person, pod: pod) + FactoryBot.create(:person, pod: pod) } } let(:pods_uris) { diff --git a/spec/shared_behaviors/signature.rb b/spec/shared_behaviors/signature.rb index 61b1d87d5..1bcc5cec3 100644 --- a/spec/shared_behaviors/signature.rb +++ b/spec/shared_behaviors/signature.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true shared_examples_for "signature data" do - let(:relayable) { FactoryGirl.create(relayable_type) } + let(:relayable) { FactoryBot.create(relayable_type) } let(:signature) { described_class.new( relayable_type => relayable, diff --git a/spec/spec/data_generator_spec.rb b/spec/spec/data_generator_spec.rb index 5c6b46db6..0f8da2052 100644 --- a/spec/spec/data_generator_spec.rb +++ b/spec/spec/data_generator_spec.rb @@ -8,7 +8,7 @@ end # verifications of data generation (protect us from possible false positives in case of poor data preset) describe DataGenerator do - let(:user) { FactoryGirl.create(:user) } + let(:user) { FactoryBot.create(:user) } let(:generator) { DataGenerator.new(user) } describe "#generic_user_data" do @@ -21,7 +21,7 @@ describe DataGenerator do end describe "#status_messages_flavours" do - let(:user) { FactoryGirl.create(:user_with_aspect) } + let(:user) { FactoryBot.create(:user_with_aspect) } it "creates posts of different types" do expect(generator).to receive(:status_message_with_activity).and_call_original diff --git a/spec/spec/misc_spec.rb b/spec/spec/misc_spec.rb index 3690af955..b81fc6923 100644 --- a/spec/spec/misc_spec.rb +++ b/spec/spec/misc_spec.rb @@ -6,7 +6,7 @@ describe "making sure the spec runner works" do it "factory creates a user with a person saved" do - user = FactoryGirl.create(:user) + user = FactoryBot.create(:user) loaded_user = User.find(user.id) expect(loaded_user.person.owner_id).to eq(user.id) end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 5f33d9133..8a6b9d585 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -10,7 +10,6 @@ require File.join(File.dirname(__FILE__), "..", "config", "environment") require Rails.root.join("spec", "helper_methods") require "rspec/rails" require "webmock/rspec" -require "factory_girl" require "sidekiq/testing" require "shoulda/matchers" require "diaspora_federation/schemas" @@ -139,7 +138,7 @@ RSpec.configure do |config| RequestStore.store[:gon].gon.clear unless RequestStore.store[:gon].nil? end - config.include FactoryGirl::Syntax::Methods + config.include FactoryBot::Syntax::Methods config.include JSON::SchemaMatchers config.json_schemas[:archive_schema] = ArchiveValidator::SchemaValidator::JSON_SCHEMA diff --git a/spec/support/data_generator.rb b/spec/support/data_generator.rb index 16f7d877b..619c9ee74 100644 --- a/spec/support/data_generator.rb +++ b/spec/support/data_generator.rb @@ -59,12 +59,12 @@ class DataGenerator end def notifications - FactoryGirl.create(:notification, recipient: user) + FactoryBot.create(:notification, recipient: user) end def conversations - a_friend = FactoryGirl.create(:contact, person: person).user.person - FactoryGirl.create(:contact, user: user, person: a_friend) unless user.nil? + a_friend = FactoryBot.create(:contact, person: person).user.person + FactoryBot.create(:contact, user: user, person: a_friend) unless user.nil? create_conversation_with_message(a_friend, person, "Subject", "Hey #{person.name}") create_conversation_with_message(person, a_friend, "Subject", "Hey #{a_friend.name}") end @@ -75,7 +75,7 @@ class DataGenerator end def service - FactoryGirl.create(:service, user: user) + FactoryBot.create(:service, user: user) end def private_post_as_receipient @@ -96,25 +96,25 @@ class DataGenerator end def mutual_friend - FactoryGirl.create(:user_with_aspect).tap {|friend| + FactoryBot.create(:user_with_aspect).tap {|friend| connect_users(user, first_aspect, friend, friend.aspects.first) } end def remote_mutual_friend - FactoryGirl.create(:contact, user: user, sharing: true, receiving: true) + FactoryBot.create(:contact, user: user, sharing: true, receiving: true) end def first_aspect - user.aspects.first || FactoryGirl.create(:aspect, user: user) + user.aspects.first || FactoryBot.create(:aspect, user: user) end def public_status_message - FactoryGirl.create(:status_message, author: person, public: true) + FactoryBot.create(:status_message, author: person, public: true) end def private_status_message - post = FactoryGirl.create(:status_message, author: person) + post = FactoryBot.create(:status_message, author: person) person.contacts.each do |contact| ShareVisibility.create!(user_id: contact.user_id, shareable: post) @@ -124,7 +124,7 @@ class DataGenerator %i[photo participation status_message_with_location status_message_with_poll status_message_with_photo status_message status_message_in_aspect reshare like comment poll_participation].each do |factory| define_method factory do - FactoryGirl.create(factory, author: person) + FactoryBot.create(factory, author: person) end end @@ -132,7 +132,7 @@ class DataGenerator %i[mention role].each do |factory| define_method factory do - FactoryGirl.create(factory, person: person) + FactoryBot.create(factory, person: person) end end diff --git a/spec/support/fixture_builder.rb b/spec/support/fixture_builder.rb index 242ebb03b..33082869b 100644 --- a/spec/support/fixture_builder.rb +++ b/spec/support/fixture_builder.rb @@ -2,27 +2,27 @@ def create_basic_users # Users - alice = FactoryGirl.create(:user_with_aspect, username: "alice", strip_exif: false) + alice = FactoryBot.create(:user_with_aspect, username: "alice", strip_exif: false) alices_aspect = alice.aspects.where(name: "generic").first - eve = FactoryGirl.create(:user_with_aspect, username: "eve") + eve = FactoryBot.create(:user_with_aspect, username: "eve") eves_aspect = eve.aspects.where(name: "generic").first - bob = FactoryGirl.create(:user_with_aspect, username: "bob") + bob = FactoryBot.create(:user_with_aspect, username: "bob") bobs_aspect = bob.aspects.where(name: "generic").first - FactoryGirl.create(:aspect, name: "empty", user: bob) + FactoryBot.create(:aspect, name: "empty", user: bob) connect_users(bob, bobs_aspect, alice, alices_aspect) connect_users(bob, bobs_aspect, eve, eves_aspect) # Set up friends - 2 local, 1 remote - local_luke = FactoryGirl.create(:user_with_aspect, username: "luke") + local_luke = FactoryBot.create(:user_with_aspect, username: "luke") lukes_aspect = local_luke.aspects.where(name: "generic").first - local_leia = FactoryGirl.create(:user_with_aspect, username: "leia") + local_leia = FactoryBot.create(:user_with_aspect, username: "leia") leias_aspect = local_leia.aspects.where(name: "generic").first - remote_raphael = FactoryGirl.create(:person, diaspora_handle: "raphael@remote.net") + remote_raphael = FactoryBot.create(:person, diaspora_handle: "raphael@remote.net") connect_users_with_aspects(local_luke, local_leia) @@ -30,7 +30,7 @@ def create_basic_users local_luke.contacts.create(person: remote_raphael, aspects: [lukes_aspect]) # Set up a follower - peter = FactoryGirl.create(:user_with_aspect, username: "peter") + peter = FactoryBot.create(:user_with_aspect, username: "peter") peters_aspect = peter.aspects.where(name: "generic").first peter.contacts.create!(person: alice.person, aspects: [peters_aspect], sharing: false, receiving: true) diff --git a/spec/views/status_messages/_status_message.mobile.haml_spec.rb b/spec/views/status_messages/_status_message.mobile.haml_spec.rb index 5487d6a55..c72af47f0 100644 --- a/spec/views/status_messages/_status_message.mobile.haml_spec.rb +++ b/spec/views/status_messages/_status_message.mobile.haml_spec.rb @@ -8,7 +8,7 @@ describe "status_messages/_status_message.mobile.haml" do image: "https://example.org/\">", description: "" ) - post = FactoryGirl.create(:status_message, public: true, open_graph_cache: open_graph_cache) + post = FactoryBot.create(:status_message, public: true, open_graph_cache: open_graph_cache) render file: "status_messages/_status_message.mobile.haml", locals: {post: post, photos: post.photos} diff --git a/spec/workers/cleanup_old_exports_spec.rb b/spec/workers/cleanup_old_exports_spec.rb index 9c5df7ea0..85cd686d0 100644 --- a/spec/workers/cleanup_old_exports_spec.rb +++ b/spec/workers/cleanup_old_exports_spec.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true describe Workers::CleanupOldExports do - let(:user) { FactoryGirl.create(:user) } + let(:user) { FactoryBot.create(:user) } context "with profile data" do before do diff --git a/spec/workers/cleanup_pending_photos_spec.rb b/spec/workers/cleanup_pending_photos_spec.rb index 1a92cac96..ec993c89e 100644 --- a/spec/workers/cleanup_pending_photos_spec.rb +++ b/spec/workers/cleanup_pending_photos_spec.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true describe Workers::CleanupPendingPhotos do - let!(:photo) { FactoryGirl.create(:photo, author: alice.person, pending: true) } + let!(:photo) { FactoryBot.create(:photo, author: alice.person, pending: true) } it "removes pending photos" do Timecop.travel(25.hours) do diff --git a/spec/workers/fetch_profile_photo_spec.rb b/spec/workers/fetch_profile_photo_spec.rb index ab99e6b20..59a4f239d 100644 --- a/spec/workers/fetch_profile_photo_spec.rb +++ b/spec/workers/fetch_profile_photo_spec.rb @@ -3,7 +3,7 @@ describe Workers::FetchProfilePhoto do before do @user = alice - @service = FactoryGirl.build(:service, :user => alice) + @service = FactoryBot.build(:service, :user => alice) @url = "https://service.com/user/profile_image" diff --git a/spec/workers/fetch_webfinger_spec.rb b/spec/workers/fetch_webfinger_spec.rb index 234c7d215..02382e9b4 100644 --- a/spec/workers/fetch_webfinger_spec.rb +++ b/spec/workers/fetch_webfinger_spec.rb @@ -2,7 +2,7 @@ describe Workers::FetchWebfinger do it "should webfinger and queue a job to fetch public posts" do - @person = FactoryGirl.create(:person) + @person = FactoryBot.create(:person) allow(Person).to receive(:find_or_fetch_by_identifier).and_return(@person) expect(Diaspora::Fetcher::Public).to receive(:queue_for).exactly(1).times diff --git a/spec/workers/gather_o_embed_data_spec.rb b/spec/workers/gather_o_embed_data_spec.rb index 298fd4585..5dae0d662 100644 --- a/spec/workers/gather_o_embed_data_spec.rb +++ b/spec/workers/gather_o_embed_data_spec.rb @@ -24,7 +24,7 @@ describe Workers::GatherOEmbedData do @no_oembed_url = 'http://www.we-do-not-support-oembed.com/index.html' - @status_message = FactoryGirl.create(:status_message) + @status_message = FactoryBot.create(:status_message) stub_request(:get, @flickr_oembed_get_request).to_return(:status => 200, :body => @flickr_oembed_data.to_json) stub_request(:get, @no_oembed_url).to_return(:status => 200, :body => 'hello there') diff --git a/spec/workers/gather_open_graph_data_spec.rb b/spec/workers/gather_open_graph_data_spec.rb index c5a91c058..2c2ac72cd 100644 --- a/spec/workers/gather_open_graph_data_spec.rb +++ b/spec/workers/gather_open_graph_data_spec.rb @@ -30,7 +30,7 @@ describe Workers::GatherOpenGraphData do @no_open_graph_url = 'http://www.we-do-not-support-open-graph.com/index.html' - @status_message = FactoryGirl.create(:status_message) + @status_message = FactoryBot.create(:status_message) stub_request(:head, @ogsite_url).to_return(status: 200, body: "", headers: {'Content-Type' => 'text/html; utf-8'}) stub_request(:get, @ogsite_url).to_return(status: 200, body: @ogsite_body, headers: {'Content-Type' => 'text/html; utf-8'}) diff --git a/spec/workers/mail/liked_spec.rb b/spec/workers/mail/liked_spec.rb index 565305937..9f19a7516 100644 --- a/spec/workers/mail/liked_spec.rb +++ b/spec/workers/mail/liked_spec.rb @@ -3,8 +3,8 @@ describe Workers::Mail::Liked do describe "#perform" do it "should call .deliver_now on the notifier object" do - sm = FactoryGirl.build(:status_message, author: bob.person, public: true) - like = FactoryGirl.build(:like, author: alice.person, target: sm) + sm = FactoryBot.build(:status_message, author: bob.person, public: true) + like = FactoryBot.build(:like, author: alice.person, target: sm) mail_double = double expect(mail_double).to receive(:deliver_now) @@ -15,8 +15,8 @@ describe Workers::Mail::Liked do end it "should not fail if the like is not found" do - sm = FactoryGirl.build(:status_message, author: bob.person, public: true) - like = FactoryGirl.build(:like, author: alice.person, target: sm) + sm = FactoryBot.build(:status_message, author: bob.person, public: true) + like = FactoryBot.build(:like, author: alice.person, target: sm) expect(Notifier).to receive(:send_notification).with("liked", bob.id, like.author.id, like.id) .and_raise(ActiveRecord::RecordNotFound.new("Couldn't find Like with 'id'=42")) @@ -25,8 +25,8 @@ describe Workers::Mail::Liked do end it "should fail if the sender is not found" do - sm = FactoryGirl.build(:status_message, author: bob.person, public: true) - like = FactoryGirl.build(:like, author: alice.person, target: sm) + sm = FactoryBot.build(:status_message, author: bob.person, public: true) + like = FactoryBot.build(:like, author: alice.person, target: sm) expect(Notifier).to receive(:send_notification).with("liked", bob.id, like.author.id, like.id) .and_raise(ActiveRecord::RecordNotFound.new("Couldn't find Person with 'id'=42")) diff --git a/spec/workers/mail/mentioned_spec.rb b/spec/workers/mail/mentioned_spec.rb index a96c6b966..4f68d8794 100644 --- a/spec/workers/mail/mentioned_spec.rb +++ b/spec/workers/mail/mentioned_spec.rb @@ -8,7 +8,7 @@ describe Workers::Mail::Mentioned do describe "#perform" do it "should call .deliver on the notifier object" do user = alice - sm = FactoryGirl.build(:status_message) + sm = FactoryBot.build(:status_message) m = Mention.new(person: user.person, mentions_container: sm) mail_double = double() diff --git a/spec/workers/mail/reshared_spec.rb b/spec/workers/mail/reshared_spec.rb index 595f1b78b..df67660d5 100644 --- a/spec/workers/mail/reshared_spec.rb +++ b/spec/workers/mail/reshared_spec.rb @@ -7,8 +7,8 @@ describe Workers::Mail::Reshared do describe "#perform" do it "should call .deliver on the notifier object" do - sm = FactoryGirl.build(:status_message, :author => bob.person, :public => true) - reshare = FactoryGirl.build(:reshare, :author => alice.person, :root=> sm) + sm = FactoryBot.build(:status_message, :author => bob.person, :public => true) + reshare = FactoryBot.build(:reshare, :author => alice.person, :root=> sm) mail_double = double() expect(mail_double).to receive(:deliver_now) diff --git a/spec/workers/process_photo_spec.rb b/spec/workers/process_photo_spec.rb index e9c7e645e..b744808c4 100644 --- a/spec/workers/process_photo_spec.rb +++ b/spec/workers/process_photo_spec.rb @@ -56,7 +56,7 @@ describe Workers::ProcessPhoto do end it 'does not throw an error if it is called on a remote photo' do - p = FactoryGirl.create(:remote_photo) + p = FactoryBot.create(:remote_photo) p.unprocessed_image = nil expect{ result = Workers::ProcessPhoto.new.perform(p.id) diff --git a/spec/workers/queue_users_for_removal_spec.rb b/spec/workers/queue_users_for_removal_spec.rb index a87d4664f..66687ee69 100644 --- a/spec/workers/queue_users_for_removal_spec.rb +++ b/spec/workers/queue_users_for_removal_spec.rb @@ -10,7 +10,7 @@ describe Workers::QueueUsersForRemoval do end it '#does not queue user that is not inactive' do - user = FactoryGirl.create(:user, :last_seen => Time.now-728.days, :sign_in_count => 5) + user = FactoryBot.create(:user, :last_seen => Time.now-728.days, :sign_in_count => 5) Workers::QueueUsersForRemoval.new.perform user.reload expect(user.remove_after).to eq(nil) @@ -19,7 +19,7 @@ describe Workers::QueueUsersForRemoval do it '#queues user that is inactive' do removal_date = Time.now + (AppConfig.settings.maintenance.remove_old_users.warn_days.to_i).days - user = FactoryGirl.create(:user, :last_seen => Time.now-732.days, :sign_in_count => 5) + user = FactoryBot.create(:user, :last_seen => Time.now-732.days, :sign_in_count => 5) Workers::QueueUsersForRemoval.new.perform user.reload expect(user.remove_after.to_i).to eq(removal_date.utc.to_i) @@ -28,7 +28,7 @@ describe Workers::QueueUsersForRemoval do it '#queues user that is inactive and has not logged in' do removal_date = Time.now - user = FactoryGirl.create(:user, :last_seen => Time.now-735.days, :sign_in_count => 0) + user = FactoryBot.create(:user, :last_seen => Time.now-735.days, :sign_in_count => 0) Workers::QueueUsersForRemoval.new.perform user.reload expect(user.remove_after.to_i).to eq(removal_date.utc.to_i) @@ -36,7 +36,7 @@ describe Workers::QueueUsersForRemoval do end it '#does not queue user that is not inactive and has not logged in' do - user = FactoryGirl.create(:user, :last_seen => Time.now-728.days, :sign_in_count => 0) + user = FactoryBot.create(:user, :last_seen => Time.now-728.days, :sign_in_count => 0) Workers::QueueUsersForRemoval.new.perform user.reload expect(user.remove_after).to eq(nil) @@ -45,7 +45,7 @@ describe Workers::QueueUsersForRemoval do it '#does not queue user that has already been flagged for removal' do removal_date = Date.today + 5.days - user = FactoryGirl.create(:user, :last_seen => Time.now-735.days, :sign_in_count => 5, :remove_after => removal_date) + user = FactoryBot.create(:user, :last_seen => Time.now-735.days, :sign_in_count => 5, :remove_after => removal_date) Workers::QueueUsersForRemoval.new.perform user.reload expect(user.remove_after).to eq(removal_date) @@ -53,8 +53,8 @@ describe Workers::QueueUsersForRemoval do end it '#does not queue more warnings than has been configured as limit' do - FactoryGirl.create(:user, :last_seen => Time.now-735.days, :sign_in_count => 1) - FactoryGirl.create(:user, :last_seen => Time.now-735.days, :sign_in_count => 1) + FactoryBot.create(:user, :last_seen => Time.now-735.days, :sign_in_count => 1) + FactoryBot.create(:user, :last_seen => Time.now-735.days, :sign_in_count => 1) Workers::QueueUsersForRemoval.new.perform expect(ActionMailer::Base.deliveries.count).to eq(1) end @@ -71,7 +71,7 @@ describe Workers::QueueUsersForRemoval do end it '#does not queue user that is not inactive' do - user = FactoryGirl.create(:user, :last_seen => Time.now-728.days, :sign_in_count => 5) + user = FactoryBot.create(:user, :last_seen => Time.now-728.days, :sign_in_count => 5) Workers::QueueUsersForRemoval.new.perform user.reload expect(user.remove_after).to eq(nil) @@ -79,7 +79,7 @@ describe Workers::QueueUsersForRemoval do end it '#does not queue user that is inactive' do - user = FactoryGirl.create(:user, :last_seen => Time.now-735.days, :sign_in_count => 5) + user = FactoryBot.create(:user, :last_seen => Time.now-735.days, :sign_in_count => 5) Workers::QueueUsersForRemoval.new.perform user.reload expect(user.remove_after).to eq(nil) diff --git a/spec/workers/recheck_offline_pods_spec.rb b/spec/workers/recheck_offline_pods_spec.rb index cd1ab90b0..780956f85 100644 --- a/spec/workers/recheck_offline_pods_spec.rb +++ b/spec/workers/recheck_offline_pods_spec.rb @@ -2,8 +2,8 @@ describe Workers::RecheckScheduledPods do it "performs a connection test on all scheduled pods" do - (0..4).map { FactoryGirl.create(:pod) } - FactoryGirl.create(:pod, scheduled_check: true) + (0..4).map { FactoryBot.create(:pod) } + FactoryBot.create(:pod, scheduled_check: true) expect_any_instance_of(Pod).to receive(:test_connection!) Workers::RecheckScheduledPods.new.perform diff --git a/spec/workers/recurring_pod_check_spec.rb b/spec/workers/recurring_pod_check_spec.rb index f5ed5e65a..898877249 100644 --- a/spec/workers/recurring_pod_check_spec.rb +++ b/spec/workers/recurring_pod_check_spec.rb @@ -3,7 +3,7 @@ describe Workers::RecurringPodCheck do before do @pods = (0..4).map do - FactoryGirl.build(:pod).tap { |pod| + FactoryBot.build(:pod).tap { |pod| expect(pod).to receive(:test_connection!) } end