FactoryGirl => FactoryBot (opf/openproject#6304)

pull/6827/head
Oliver Günther 7 years ago
parent 865c249c11
commit dc12e456bd
No known key found for this signature in database
GPG Key ID: 88872239EB414F99
  1. 4
      lib/api/v3/users/user_representer_spec.rb
  2. 2
      spec/controllers/avatars/avatar_controller_spec.rb
  3. 4
      spec/controllers/avatars/users_controller_spec.rb
  4. 2
      spec/factories/avatar_attachment_factory.rb
  5. 2
      spec/features/my_avatar_spec.rb
  6. 12
      spec/features/user_avatar_spec.rb
  7. 4
      spec/helpers/avatar_helper_spec.rb
  8. 2
      spec/models/user_spec.rb
  9. 6
      spec/services/avatars/update_service_spec.rb
  10. 12
      spec/shared_examples.rb

@ -29,8 +29,8 @@
require 'spec_helper'
describe ::API::V3::Users::UserRepresenter do
let(:user) { FactoryGirl.build_stubbed(:user, status: 1) }
let(:current_user) { FactoryGirl.build_stubbed(:user) }
let(:user) { FactoryBot.build_stubbed(:user, status: 1) }
let(:current_user) { FactoryBot.build_stubbed(:user) }
let(:representer) { described_class.new(user, current_user: current_user) }
context 'generation' do

@ -20,7 +20,7 @@ describe ::Avatars::AvatarController, type: :controller do
end
describe 'when logged in' do
let(:user) { FactoryGirl.create :user }
let(:user) { FactoryBot.create :user }
before do
login_as user

@ -4,7 +4,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../../shared_examples')
describe ::Avatars::UsersController, type: :controller do
include_context "there are users with and without avatars"
let(:current_user) { FactoryGirl.create :admin }
let(:current_user) { FactoryBot.create :admin }
let(:enabled) { true }
before do
@ -26,7 +26,7 @@ describe ::Avatars::UsersController, type: :controller do
end
context 'as another user' do
let(:current_user) { FactoryGirl.create :user }
let(:current_user) { FactoryBot.create :user }
before do
get :show, params: { id: target_user.id }
end

@ -1,4 +1,4 @@
FactoryGirl.define do
FactoryBot.define do
factory :avatar_attachment, class: Attachment do
author factory: :user
container factory: :work_package

@ -4,7 +4,7 @@ require_relative './shared_avatar_examples'
describe 'My avatar management', type: :feature, js: true do
include Rails.application.routes.url_helpers
let(:user) { FactoryGirl.create :user }
let(:user) { FactoryBot.create :user }
let(:target_user) { user }
let(:avatar_management_path) { edit_my_avatar_path }

@ -4,7 +4,7 @@ require_relative './shared_avatar_examples'
describe 'User avatar management', type: :feature, js: true do
include Rails.application.routes.url_helpers
let(:user) { FactoryGirl.create :admin }
let(:user) { FactoryBot.create :admin }
let(:avatar_management_path) { edit_user_path(target_user, tab: 'avatar') }
before do
@ -12,12 +12,12 @@ describe 'User avatar management', type: :feature, js: true do
end
context 'when user is admin' do
let(:target_user) { FactoryGirl.create :user }
let(:target_user) { FactoryBot.create :user }
it_behaves_like 'avatar management'
end
context 'when user is self' do
let(:user) { FactoryGirl.create :user }
let(:user) { FactoryBot.create :user }
let(:target_user) { user }
it 'forbids the user to access' do
visit avatar_management_path
@ -26,8 +26,8 @@ describe 'User avatar management', type: :feature, js: true do
end
context 'when user is another user' do
let(:target_user) { FactoryGirl.create :user }
let(:user) { FactoryGirl.create :user }
let(:target_user) { FactoryBot.create :user }
let(:user) { FactoryBot.create :user }
it 'forbids the user to access' do
visit avatar_management_path
@ -36,7 +36,7 @@ describe 'User avatar management', type: :feature, js: true do
end
describe 'none enabled' do
let(:target_user) { FactoryGirl.create :user }
let(:target_user) { FactoryBot.create :user }
before do
allow(Setting)

@ -1,9 +1,9 @@
require 'spec_helper'
describe AvatarHelper, type: :helper, with_settings: { protocol: 'http' } do
let(:user) { FactoryGirl.build_stubbed(:user) }
let(:user) { FactoryBot.build_stubbed(:user) }
let(:mail_digest) { Digest::MD5.hexdigest(user.mail) }
let(:avatar_stub) { FactoryGirl.build_stubbed(:avatar_attachment) }
let(:avatar_stub) { FactoryBot.build_stubbed(:avatar_attachment) }
let(:enable_gravatars) { false }
let(:gravatar_default) { '' }

@ -3,7 +3,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../shared_examples')
describe User, type: :model do
include_examples "there are users with and without avatars"
let(:user) { FactoryGirl.build :user }
let(:user) { FactoryBot.build :user }
specify { expect(user.attachments).to all be_a_kind_of Attachment }

@ -1,10 +1,10 @@
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
describe ::Avatars::UpdateService do
let(:user_without_avatar) { FactoryGirl.build_stubbed :user }
let(:user_without_avatar) { FactoryBot.build_stubbed :user }
let(:user_with_avatar) do
u = FactoryGirl.create :user
u.attachments = [FactoryGirl.create(:avatar_attachment, author: u)]
u = FactoryBot.create :user
u.attachments = [FactoryBot.create(:avatar_attachment, author: u)]
u
end

@ -23,7 +23,7 @@ shared_examples_for "an action checked for required login" do
end
shared_examples_for "an action requiring login" do
let(:current) { FactoryGirl.create(:user) }
let(:current) { FactoryBot.create(:user) }
before do
allow(User).to receive(:current).and_return(current)
@ -49,7 +49,7 @@ shared_examples_for "an action requiring login" do
end
shared_examples_for "an action requiring admin" do
let(:current) { FactoryGirl.create(:admin) }
let(:current) { FactoryBot.create(:admin) }
before do
allow(User).to receive(:current).and_return(current)
@ -67,7 +67,7 @@ shared_examples_for "an action requiring admin" do
describe "with beeing logged in as a normal user" do
before do
allow(User).to receive(:current).and_return FactoryGirl.create(:user)
allow(User).to receive(:current).and_return FactoryBot.create(:user)
action
end
@ -92,10 +92,10 @@ end
#
shared_context "there are users with and without avatars" do
let(:base_path) { File.expand_path '../fixtures/', __FILE__ }
let(:user_without_avatar) { FactoryGirl.create :user }
let(:user_without_avatar) { FactoryBot.create :user }
let(:user_with_avatar) do
u = FactoryGirl.create :user
u.attachments = [FactoryGirl.build(:avatar_attachment, author: u)]
u = FactoryBot.create :user
u.attachments = [FactoryBot.build(:avatar_attachment, author: u)]
u
end
let(:avatar_file) do

Loading…
Cancel
Save