Skip to content

Commit

Permalink
FactoryGirl => FactoryBot (opf/openproject#6304)
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverguenther committed May 7, 2018
1 parent 865c249 commit dc12e45
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 25 deletions.
4 changes: 2 additions & 2 deletions lib/api/v3/users/user_representer_spec.rb
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion spec/controllers/avatars/avatar_controller_spec.rb
Expand Up @@ -20,7 +20,7 @@
end

describe 'when logged in' do
let(:user) { FactoryGirl.create :user }
let(:user) { FactoryBot.create :user }

before do
login_as user
Expand Down
4 changes: 2 additions & 2 deletions spec/controllers/avatars/users_controller_spec.rb
Expand Up @@ -4,7 +4,7 @@
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
Expand All @@ -26,7 +26,7 @@
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
Expand Down
2 changes: 1 addition & 1 deletion spec/factories/avatar_attachment_factory.rb
@@ -1,4 +1,4 @@
FactoryGirl.define do
FactoryBot.define do
factory :avatar_attachment, class: Attachment do
author factory: :user
container factory: :work_package
Expand Down
2 changes: 1 addition & 1 deletion spec/features/my_avatar_spec.rb
Expand Up @@ -4,7 +4,7 @@
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 }

Expand Down
12 changes: 6 additions & 6 deletions spec/features/user_avatar_spec.rb
Expand Up @@ -4,20 +4,20 @@
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
login_as user
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
Expand All @@ -26,8 +26,8 @@
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
Expand All @@ -36,7 +36,7 @@
end

describe 'none enabled' do
let(:target_user) { FactoryGirl.create :user }
let(:target_user) { FactoryBot.create :user }

before do
allow(Setting)
Expand Down
4 changes: 2 additions & 2 deletions spec/helpers/avatar_helper_spec.rb
@@ -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) { '' }
Expand Down
2 changes: 1 addition & 1 deletion spec/models/user_spec.rb
Expand Up @@ -3,7 +3,7 @@

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 }

Expand Down
6 changes: 3 additions & 3 deletions spec/services/avatars/update_service_spec.rb
@@ -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

Expand Down
12 changes: 6 additions & 6 deletions spec/shared_examples.rb
Expand Up @@ -23,7 +23,7 @@
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)
Expand All @@ -49,7 +49,7 @@
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)
Expand All @@ -67,7 +67,7 @@

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
Expand All @@ -92,10 +92,10 @@
#
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
Expand Down

0 comments on commit dc12e45

Please sign in to comment.