Use factory girl instead of object daddy

pull/3421/head
Stefan Botzenhart 9 years ago committed by Alex Coles
parent 0b12f1b80b
commit 3fccb90c57
  1. 9
      spec/controllers/auth_sources_controller_spec.rb
  2. 33
      spec/factories/issue_priority_factory.rb
  3. 2
      spec/models/journal_notification_mailer_spec.rb
  4. 4
      spec/models/user_spec.rb

@ -74,7 +74,7 @@ describe AuthSourcesController, type: :controller do
describe 'edit' do
before do
@auth_source = AuthSource.generate!(name: 'TestEdit')
@auth_source = FactoryGirl.create(:auth_source, name: 'TestEdit')
get :edit, id: @auth_source.id
end
@ -85,7 +85,7 @@ describe AuthSourcesController, type: :controller do
describe 'update' do
before do
@auth_source = AuthSource.generate!(name: 'TestEdit')
@auth_source = FactoryGirl.create(:auth_source, name: 'TestEdit')
post :update, id: @auth_source.id, auth_source: { name: 'TestUpdate' }
end
@ -96,7 +96,7 @@ describe AuthSourcesController, type: :controller do
describe 'destroy' do
before do
@auth_source = AuthSource.generate!(name: 'TestEdit')
@auth_source = FactoryGirl.create(:auth_source, name: 'TestEdit')
end
context 'without users' do
@ -111,11 +111,12 @@ describe AuthSourcesController, type: :controller do
context 'with users' do
before do
User.generate!(auth_source: @auth_source)
FactoryGirl.create(:user, auth_source: @auth_source)
post :destroy, id: @auth_source.id
end
it { is_expected.to respond_with :redirect }
it 'doesn not destroy the AuthSource' do
expect(AuthSource.find(@auth_source.id)).not_to be_nil
end

@ -0,0 +1,33 @@
#-- copyright
# OpenProject is a project management system.
# Copyright (C) 2012-2015 the OpenProject Foundation (OPF)
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License version 3.
#
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
# Copyright (C) 2006-2013 Jean-Philippe Lang
# Copyright (C) 2010-2013 the ChiliProject Team
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# See doc/COPYRIGHT.rdoc for more details.
#++
FactoryGirl.define do
factory :issue_priority do
sequence(:name) { |n| "IssuePriority #{n}" }
end
end

@ -165,7 +165,7 @@ describe JournalNotificationMailer do
context 'work_package_priority_updated' do
before do
work_package.add_journal(user)
work_package.priority = IssuePriority.generate!
work_package.priority = FactoryGirl.create(:issue_priority)
work_package.save!(validate: false)
end

@ -233,7 +233,7 @@ describe User, type: :model do
end
context 'for user with an auth source' do
let(:allowed_auth_source) { AuthSource.generate! }
let(:allowed_auth_source) { FactoryGirl.create :auth_source }
context 'that allows password changes' do
before do
@ -247,7 +247,7 @@ describe User, type: :model do
end
context 'that does not allow password changes' do
let(:denied_auth_source) { AuthSource.generate! }
let(:denied_auth_source) { FactoryGirl.create :auth_source }
before do
def denied_auth_source.allow_password_changes?; false; end

Loading…
Cancel
Save