diff --git a/changelog.md b/changelog.md index 4d5c1b12ff..1d3d6bf2b1 100644 --- a/changelog.md +++ b/changelog.md @@ -1,3 +1,7 @@ +## 4.0.2 [Unreleased] + +* Renamed FactoryGirl to FactoryBot. [#3324](https://github.com/refinery/refinerycms/pull/3324). [Philip Arndt](https://github.com/parndt) + ## 4.0.1 [24 October 2017] * Always expect to have css and js files precompiled. Remove skip_pipeline option for visual_editor_stylesheets and custom_stylesheets. [#3318](https://github.com/refinery/refinerycms/pull/3318). [Brice Sanchez](https://github.com/bricesanchez) diff --git a/core/lib/generators/refinery/engine/templates/spec/features/refinery/namespace/admin/plural_name_spec.rb.erb b/core/lib/generators/refinery/engine/templates/spec/features/refinery/namespace/admin/plural_name_spec.rb.erb index 75fbba075e..ac6aa4014c 100644 --- a/core/lib/generators/refinery/engine/templates/spec/features/refinery/namespace/admin/plural_name_spec.rb.erb +++ b/core/lib/generators/refinery/engine/templates/spec/features/refinery/namespace/admin/plural_name_spec.rb.erb @@ -9,8 +9,8 @@ describe Refinery do <% if (title = attributes.detect { |a| a.type.to_s == "string" }).present? %> describe "<%= plural_name %> list" do before do - FactoryGirl.create(:<%= singular_name %>, :<%= title.name %> => "UniqueTitleOne") - FactoryGirl.create(:<%= singular_name %>, :<%= title.name %> => "UniqueTitleTwo") + FactoryBot.create(:<%= singular_name %>, :<%= title.name %> => "UniqueTitleOne") + FactoryBot.create(:<%= singular_name %>, :<%= title.name %> => "UniqueTitleTwo") end it "shows two items" do @@ -45,7 +45,7 @@ describe Refinery do end context "duplicate" do - before { FactoryGirl.create(:<%= singular_name %>, :<%= title.name %> => "UniqueTitle") } + before { FactoryBot.create(:<%= singular_name %>, :<%= title.name %> => "UniqueTitle") } it "should fail" do visit refinery.<%= namespacing.underscore %>_admin_<%= plural_name %>_path @@ -161,7 +161,7 @@ describe Refinery do end describe "edit" do - before { FactoryGirl.create(:<%= singular_name %>, :<%= title.name %> => "A <%= title.name %>") } + before { FactoryBot.create(:<%= singular_name %>, :<%= title.name %> => "A <%= title.name %>") } it "should succeed" do visit refinery.<%= namespacing.underscore %>_admin_<%= plural_name %>_path @@ -179,7 +179,7 @@ describe Refinery do end describe "destroy" do - before { FactoryGirl.create(:<%= singular_name %>, :<%= title.name %> => "UniqueTitleOne") } + before { FactoryBot.create(:<%= singular_name %>, :<%= title.name %> => "UniqueTitleOne") } it "should succeed" do visit refinery.<%= namespacing.underscore %>_admin_<%= plural_name %>_path diff --git a/core/lib/generators/refinery/engine/templates/spec/models/refinery/namespace/singular_name_spec.rb.erb b/core/lib/generators/refinery/engine/templates/spec/models/refinery/namespace/singular_name_spec.rb.erb index 40b41ddb45..8adc930fb1 100644 --- a/core/lib/generators/refinery/engine/templates/spec/models/refinery/namespace/singular_name_spec.rb.erb +++ b/core/lib/generators/refinery/engine/templates/spec/models/refinery/namespace/singular_name_spec.rb.erb @@ -5,7 +5,7 @@ module Refinery describe <%= class_name %> do describe "validations", type: :model do subject do - FactoryGirl.create(:<%= singular_name %><% if (title = attributes.detect { |a| a.type.to_s == "string" }).present? -%>, + FactoryBot.create(:<%= singular_name %><% if (title = attributes.detect { |a| a.type.to_s == "string" }).present? -%>, :<%= title.name %> => "Refinery CMS"<% end %>) end diff --git a/core/lib/generators/refinery/engine/templates/spec/support/factories/refinery/plural_name.rb.erb b/core/lib/generators/refinery/engine/templates/spec/support/factories/refinery/plural_name.rb.erb index 065d1e8b2f..35df2aac5b 100644 --- a/core/lib/generators/refinery/engine/templates/spec/support/factories/refinery/plural_name.rb.erb +++ b/core/lib/generators/refinery/engine/templates/spec/support/factories/refinery/plural_name.rb.erb @@ -1,5 +1,5 @@ <% if (title = attributes.detect { |a| a.type.to_s == "string" }).present? %> -FactoryGirl.define do +FactoryBot.define do factory :<%= singular_name %>, :class => Refinery::<%= namespacing %>::<%= class_name %> do sequence(:<%= title.name %>) { |n| "refinery#{n}" } end diff --git a/core/spec/features/refinery/admin/xhr_paging_spec.rb b/core/spec/features/refinery/admin/xhr_paging_spec.rb index 22d21e99cb..068c6c0b11 100644 --- a/core/spec/features/refinery/admin/xhr_paging_spec.rb +++ b/core/spec/features/refinery/admin/xhr_paging_spec.rb @@ -8,8 +8,8 @@ module Refinery # Refinery::Admin::ImagesController specifies :order => 'created_at DESC' in crudify let(:first_image) { Image.order('created_at DESC').first } let(:last_image) { Image.order('created_at DESC').last } - let!(:image_1) { FactoryGirl.create :image } - let!(:image_2) { FactoryGirl.create :image } + let!(:image_1) { FactoryBot.create :image } + let!(:image_2) { FactoryBot.create :image } before do allow(Image).to receive(:per_page).and_return(1) diff --git a/core/spec/features/refinery/application_layout_spec.rb b/core/spec/features/refinery/application_layout_spec.rb index 64d04d776b..7a9b503f53 100644 --- a/core/spec/features/refinery/application_layout_spec.rb +++ b/core/spec/features/refinery/application_layout_spec.rb @@ -5,7 +5,7 @@ module Refinery refinery_login let(:home_page) do - FactoryGirl.create :page, :title => 'Home', :link_url => '/' + FactoryBot.create :page, :title => 'Home', :link_url => '/' end describe 'body' do diff --git a/core/spec/features/refinery/site_bar_spec.rb b/core/spec/features/refinery/site_bar_spec.rb index d2a6553f5e..a11764189f 100644 --- a/core/spec/features/refinery/site_bar_spec.rb +++ b/core/spec/features/refinery/site_bar_spec.rb @@ -47,7 +47,7 @@ module Refinery context "when in frontend" do # make a page in order to avoid 404 - let!(:root_page) { FactoryGirl.create(:page, :link_url => "/") } + let!(:root_page) { FactoryBot.create(:page, :link_url => "/") } before { visit refinery.root_path } it "has a 'switch to your website editor' button" do diff --git a/core/spec/helpers/refinery/translation_helper_spec.rb b/core/spec/helpers/refinery/translation_helper_spec.rb index 7e2bf2052d..1132274a22 100644 --- a/core/spec/helpers/refinery/translation_helper_spec.rb +++ b/core/spec/helpers/refinery/translation_helper_spec.rb @@ -11,7 +11,7 @@ module Refinery end describe "#translated_field" do - let(:page) { FactoryGirl.build(:page) } + let(:page) { FactoryBot.build(:page) } before do Globalize.with_locale(:en) do @@ -40,4 +40,4 @@ module Refinery end end -end \ No newline at end of file +end diff --git a/core/spec/presenters/refinery/translated_field_presenter_spec.rb b/core/spec/presenters/refinery/translated_field_presenter_spec.rb index 0e4c0dbf7e..c0e6132c90 100644 --- a/core/spec/presenters/refinery/translated_field_presenter_spec.rb +++ b/core/spec/presenters/refinery/translated_field_presenter_spec.rb @@ -2,7 +2,7 @@ module Refinery describe TranslatedFieldPresenter do - let(:page) { FactoryGirl.build(:page) } + let(:page) { FactoryBot.build(:page) } before do Globalize.with_locale(:en) do diff --git a/images/spec/factories/image.rb b/images/spec/factories/image.rb index 6c83f4c64f..e4a6a5d5ae 100644 --- a/images/spec/factories/image.rb +++ b/images/spec/factories/image.rb @@ -1,4 +1,4 @@ -FactoryGirl.define do +FactoryBot.define do factory :image, :class => ::Refinery::Image do image Refinery.roots('refinery/images').join("spec/fixtures/beach.jpeg") end diff --git a/images/spec/models/refinery/image_spec.rb b/images/spec/models/refinery/image_spec.rb index a0d5d615ae..e10d4cb236 100644 --- a/images/spec/models/refinery/image_spec.rb +++ b/images/spec/models/refinery/image_spec.rb @@ -4,12 +4,12 @@ module Refinery describe Image, :type => :model do - let(:image) { FactoryGirl.build(:image) } - let(:created_image) { FactoryGirl.create(:image) } - let(:titled_image) { FactoryGirl.create(:image, image_title: 'Image Title')} - let(:image_with_alt_text) { FactoryGirl.create(:image, image_alt: 'Alt Text')} - let(:image_with_sha) {FactoryGirl.create(:image)} - let(:image_without_sha) {FactoryGirl.create(:image)} + let(:image) { FactoryBot.build(:image) } + let(:created_image) { FactoryBot.create(:image) } + let(:titled_image) { FactoryBot.create(:image, image_title: 'Image Title')} + let(:image_with_alt_text) { FactoryBot.create(:image, image_alt: 'Alt Text')} + let(:image_with_sha) {FactoryBot.create(:image)} + let(:image_without_sha) {FactoryBot.create(:image)} describe "validations" do describe "valid #image" do @@ -202,7 +202,7 @@ module Refinery end describe '#thumbnail_dimensions returns correctly with' do - let(:created_alternate_image) { FactoryGirl.create(:alternate_image) } + let(:created_alternate_image) { FactoryBot.create(:alternate_image) } it 'nil' do expect(created_alternate_image.thumbnail_dimensions(nil)).to eq({ :width => 376, :height => 184 }) diff --git a/images/spec/support/shared_contexts/many_images.rb b/images/spec/support/shared_contexts/many_images.rb index bf1696a8c8..466c4a2015 100644 --- a/images/spec/support/shared_contexts/many_images.rb +++ b/images/spec/support/shared_contexts/many_images.rb @@ -1,5 +1,5 @@ shared_context 'many images' do - let!(:image) { FactoryGirl.create(:image) } - let!(:alt_image) { FactoryGirl.create(:alternate_image) } - let!(:another_image) { FactoryGirl.create(:another_image) } + let!(:image) { FactoryBot.create(:image) } + let!(:alt_image) { FactoryBot.create(:alternate_image) } + let!(:another_image) { FactoryBot.create(:another_image) } end diff --git a/images/spec/support/shared_contexts/no_images.rb b/images/spec/support/shared_contexts/no_images.rb index 4d78d27b34..35297b2ad6 100644 --- a/images/spec/support/shared_contexts/no_images.rb +++ b/images/spec/support/shared_contexts/no_images.rb @@ -1,3 +1,3 @@ shared_context "no existing images" do - let(:image) { FactoryGirl.create(:image) } + let(:image) { FactoryBot.create(:image) } end diff --git a/images/spec/support/shared_contexts/one_image.rb b/images/spec/support/shared_contexts/one_image.rb index b5a443eb24..a9cef818d6 100644 --- a/images/spec/support/shared_contexts/one_image.rb +++ b/images/spec/support/shared_contexts/one_image.rb @@ -1,3 +1,3 @@ shared_context "one image" do - let!(:image) { FactoryGirl.create(:image) } + let!(:image) { FactoryBot.create(:image) } end diff --git a/pages/spec/controllers/refinery/pages_controller_spec.rb b/pages/spec/controllers/refinery/pages_controller_spec.rb index 2468d5f59c..cb182c539f 100644 --- a/pages/spec/controllers/refinery/pages_controller_spec.rb +++ b/pages/spec/controllers/refinery/pages_controller_spec.rb @@ -3,8 +3,8 @@ module Refinery describe PagesController, :type => :controller do before do - FactoryGirl.create(:page, :link_url => "/") - FactoryGirl.create(:page, :title => "test") + FactoryBot.create(:page, :link_url => "/") + FactoryBot.create(:page, :title => "test") end describe "#home" do diff --git a/pages/spec/factories/page_parts.rb b/pages/spec/factories/page_parts.rb index 19b1db2629..d8d0b136c1 100644 --- a/pages/spec/factories/page_parts.rb +++ b/pages/spec/factories/page_parts.rb @@ -1,4 +1,4 @@ -FactoryGirl.define do +FactoryBot.define do factory :page_part, class: Refinery::PagePart do title 'Body' slug 'side_body' diff --git a/pages/spec/factories/pages.rb b/pages/spec/factories/pages.rb index 4474645776..8aed49259b 100644 --- a/pages/spec/factories/pages.rb +++ b/pages/spec/factories/pages.rb @@ -1,10 +1,10 @@ -FactoryGirl.define do +FactoryBot.define do factory :page, class: Refinery::Page do sequence(:title, "a") { |n| "Test title #{n}" } factory :page_with_page_part do after(:create) do |page| - page.parts << FactoryGirl.create(:page_part) + page.parts << FactoryBot.create(:page_part) end end end diff --git a/pages/spec/helpers/refinery/pages/admin/pages_helper_spec.rb b/pages/spec/helpers/refinery/pages/admin/pages_helper_spec.rb index ae5810d5b5..cbe89a0392 100644 --- a/pages/spec/helpers/refinery/pages/admin/pages_helper_spec.rb +++ b/pages/spec/helpers/refinery/pages/admin/pages_helper_spec.rb @@ -6,7 +6,7 @@ module Admin describe "#template_options" do context "when page layout/view template is set" do it "returns those templates as selected" do - page = FactoryGirl.create(:page) + page = FactoryBot.create(:page) page.view_template = "rspec_template" expect(helper.template_options(:view_template, page)).to eq(:selected => "rspec_template") @@ -22,7 +22,7 @@ module Admin end it "works as expected" do - page = FactoryGirl.create(:page, :layout_template => "three") + page = FactoryBot.create(:page, :layout_template => "three") expect(helper.template_options(:layout_template, page)).to eq(:selected => 'three') end @@ -31,8 +31,8 @@ module Admin context "when page layout template isn't set" do context "when page has parent and parent has layout_template set" do it "returns parent layout_template as selected" do - parent = FactoryGirl.create(:page, :layout_template => "rspec_layout") - page = FactoryGirl.create(:page, :parent_id => parent.id) + parent = FactoryBot.create(:page, :layout_template => "rspec_layout") + page = FactoryBot.create(:page, :parent_id => parent.id) expected_layout = { :selected => parent.layout_template } expect(helper.template_options(:layout_template, page)).to eq(expected_layout) @@ -41,7 +41,7 @@ module Admin context "when page doesn't have parent page" do it "returns default application template" do - page = FactoryGirl.create(:page) + page = FactoryBot.create(:page) expected_layout = { :selected => "application" } expect(helper.template_options(:layout_template, page)).to eq(expected_layout) @@ -51,7 +51,7 @@ module Admin end describe "#page_meta_information" do - let(:page) { FactoryGirl.build(:page) } + let(:page) { FactoryBot.build(:page) } context "when show_in_menu is false" do it "adds 'hidden' label" do diff --git a/pages/spec/models/refinery/page_finder_spec.rb b/pages/spec/models/refinery/page_finder_spec.rb index 30012294d4..193de0d247 100644 --- a/pages/spec/models/refinery/page_finder_spec.rb +++ b/pages/spec/models/refinery/page_finder_spec.rb @@ -30,7 +30,7 @@ module Refinery end describe ".find_by_path_or_id" do - let!(:market) { FactoryGirl.create(:page, :title => "market") } + let!(:market) { FactoryBot.create(:page, :title => "market") } let(:path) { "market" } let(:id) { market.id } diff --git a/pages/spec/models/refinery/page_url_spec.rb b/pages/spec/models/refinery/page_url_spec.rb index 93c92b567a..0b770e9c24 100644 --- a/pages/spec/models/refinery/page_url_spec.rb +++ b/pages/spec/models/refinery/page_url_spec.rb @@ -270,7 +270,7 @@ def turn_off_custom_slugs context "given a page with a custom_slug exists" do before do - FactoryGirl.create(:page, :custom_slug => custom_page_slug) + FactoryBot.create(:page, :custom_slug => custom_page_slug) end it "fails validation when a new record uses that custom_slug" do diff --git a/pages/spec/presenters/refinery/pages/menu_presenter_spec.rb b/pages/spec/presenters/refinery/pages/menu_presenter_spec.rb index f9ff1f602f..493df5c9b7 100644 --- a/pages/spec/presenters/refinery/pages/menu_presenter_spec.rb +++ b/pages/spec/presenters/refinery/pages/menu_presenter_spec.rb @@ -60,10 +60,10 @@ module Pages describe "#to_html" do let(:menu_items) { - Refinery::Menu.new(FactoryGirl.create(:page, :title => "Refinery CMS")) + Refinery::Menu.new(FactoryBot.create(:page, :title => "Refinery CMS")) } let(:menu_presenter) { MenuPresenter.new(menu_items, view) } - + context "wrapped in html" do it "returns menu items" do expect(menu_presenter.to_html).to xml_eq( @@ -72,7 +72,7 @@ module Pages end context "with role set to navigation" do - let(:menu_presenter_with_role) { + let(:menu_presenter_with_role) { menu_presenter.menu_role = 'navigation' menu_presenter } @@ -96,7 +96,7 @@ module Pages context "when page has a link_url" do let(:menu_items) { - Menu.new(FactoryGirl.create(:page, title: "Home", link_url: "/")) + Menu.new(FactoryBot.create(:page, title: "Home", link_url: "/")) } it "the menu item URL includes the mounted path" do expect(menu_presenter.to_html).to xml_eq( diff --git a/resources/spec/factories/resource.rb b/resources/spec/factories/resource.rb index e011df9cff..24c0421533 100644 --- a/resources/spec/factories/resource.rb +++ b/resources/spec/factories/resource.rb @@ -1,4 +1,4 @@ -FactoryGirl.define do +FactoryBot.define do factory :resource, :class => Refinery::Resource do file Refinery.roots('refinery/resources').join("spec/fixtures/refinery_is_awesome.txt") end diff --git a/resources/spec/features/refinery/admin/resources_spec.rb b/resources/spec/features/refinery/admin/resources_spec.rb index b8f3440213..b28f92ebab 100644 --- a/resources/spec/features/refinery/admin/resources_spec.rb +++ b/resources/spec/features/refinery/admin/resources_spec.rb @@ -74,7 +74,7 @@ module Admin end context "edit/update" do - let!(:resource) { FactoryGirl.create(:resource) } + let!(:resource) { FactoryBot.create(:resource) } it "updates file" do visit refinery.admin_resources_path @@ -119,7 +119,7 @@ module Admin end context "destroy" do - let!(:resource) { FactoryGirl.create(:resource) } + let!(:resource) { FactoryBot.create(:resource) } it "removes file" do visit refinery.admin_resources_path @@ -133,7 +133,7 @@ module Admin end context "download" do - let!(:resource) { FactoryGirl.create(:resource) } + let!(:resource) { FactoryBot.create(:resource) } it "succeeds" do visit refinery.admin_resources_path diff --git a/resources/spec/models/refinery/resource_spec.rb b/resources/spec/models/refinery/resource_spec.rb index 21dca15657..0e0327d241 100644 --- a/resources/spec/models/refinery/resource_spec.rb +++ b/resources/spec/models/refinery/resource_spec.rb @@ -2,8 +2,8 @@ module Refinery describe Resource, :type => :model do - let(:resource) { FactoryGirl.create(:resource) } - let(:titled_resource) { FactoryGirl.create(:resource, resource_title: 'Resource Title')} + let(:resource) { FactoryBot.create(:resource) } + let(:titled_resource) { FactoryBot.create(:resource, resource_title: 'Resource Title')} context "with valid attributes" do it "should create successfully" do diff --git a/testing/lib/refinery/testing.rb b/testing/lib/refinery/testing.rb index e1f9463924..f73bde1dd7 100644 --- a/testing/lib/refinery/testing.rb +++ b/testing/lib/refinery/testing.rb @@ -1,6 +1,6 @@ require 'refinerycms-core' require 'rspec-rails' -require 'factory_girl' +require 'factory_bot' require 'rails-controller-testing' module Refinery @@ -17,11 +17,11 @@ def load_factories Refinery.extensions.each do |extension_const| if extension_const.respond_to?(:factory_paths) extension_const.send(:factory_paths).each do |path| - FactoryGirl.definition_file_paths << path + FactoryBot.definition_file_paths << path end end end - FactoryGirl.find_definitions + FactoryBot.find_definitions end end diff --git a/testing/refinerycms-testing.gemspec b/testing/refinerycms-testing.gemspec index 57569a675e..15fb13c672 100644 --- a/testing/refinerycms-testing.gemspec +++ b/testing/refinerycms-testing.gemspec @@ -20,7 +20,7 @@ Gem::Specification.new do |s| s.add_dependency 'refinerycms-core', version s.add_dependency 'database_cleaner', '~> 1.6' - s.add_dependency 'factory_girl_rails', '~> 4.6' + s.add_dependency 'factory_bot_rails', '~> 4.8' s.add_dependency 'rspec-rails', '~> 3.5' s.add_dependency 'capybara', '~> 2.7' s.add_dependency 'rails-controller-testing', '~> 0.1.1'