diff --git a/.travis.yml b/.travis.yml index 5fe21d010..a0e9488e3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,13 +1,19 @@ language: ruby -sudo: false +sudo: required cache: directories: - bundler - - travis_phantomjs rvm: - 2.5.1 +addons: + chrome: stable + +services: + - mysql + - postgresql + env: - DB=mysql - DB=pg @@ -17,12 +23,6 @@ matrix: - env: DB=pg before_install: - - "export PATH=$PWD/travis_phantomjs/phantomjs-2.1.1-linux-x86_64/bin:$PATH" - - if [ $(phantomjs --version) != '2.1.1' ]; then - rm -rf $PWD/travis_phantomjs; mkdir -p $PWD/travis_phantomjs; - wget https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-linux-x86_64.tar.bz2 -O $PWD/travis_phantomjs/phantomjs-2.1.1-linux-x86_64.tar.bz2; - tar -xvf $PWD/travis_phantomjs/phantomjs-2.1.1-linux-x86_64.tar.bz2 -C $PWD/travis_phantomjs; - fi - 'cp "config.yml.${DB}.travis" "config.yml"' before_script: diff --git a/.versions.conf b/.versions.conf index d8478ba92..cdad183ca 100644 --- a/.versions.conf +++ b/.versions.conf @@ -1 +1 @@ -ruby=ruby-2.5.1 +ruby=ruby-2.6 diff --git a/Gemfile b/Gemfile index cdb2abb9f..401f64211 100644 --- a/Gemfile +++ b/Gemfile @@ -26,7 +26,7 @@ gemspec # gem 'debugger' case config["database"]["type"] when 'mysql' - gem 'mysql2', '< 0.5', platform: :ruby + gem 'mysql2', '~> 0.5', platform: :ruby when 'postgresql' gem 'pg', '~> 0.15' end diff --git a/lib/releaf/rspec/helpers.rb b/lib/releaf/rspec/helpers.rb index fcbffad6a..932c22cd2 100644 --- a/lib/releaf/rspec/helpers.rb +++ b/lib/releaf/rspec/helpers.rb @@ -54,7 +54,7 @@ def update_resource end def create_resource - click_link "Create new resource" unless first("form.new-resource") + click_link "Create new resource" unless first("form.new-resource", minimum: 0) within "form.new-resource" do yield end @@ -89,8 +89,8 @@ def close_dialog def wait_for_all_richtexts # wait for all ckeditors to fully initialize before moving on. # otherwise the page sometimes produces random js errors in fast tests - number_of_normal_richtexts = page.all('.field.type-richtext:not(.i18n)').length - number_of_localized_richtexts = page.all('.field.type-richtext.i18n .localization', visible: false).length + number_of_normal_richtexts = page.all('.field.type-richtext:not(.i18n)', wait: 0).length + number_of_localized_richtexts = page.all('.field.type-richtext.i18n .localization', wait: 0, visible: false).length number_of_richtexts = number_of_normal_richtexts + number_of_localized_richtexts if (number_of_richtexts > 0) expect(page).to have_css(".ckeditor-initialized", visible: false, count: number_of_richtexts) @@ -208,7 +208,7 @@ def fill_in_richtext(locator, options = {} ) textareas = [] richtext_boxes = all(".field.type-richtext:not(.i18n), .field.type-richtext.i18n .localization.active") richtext_boxes.each do |richtext_box| - textarea = richtext_box.first(:field, locator, visible: false) + textarea = richtext_box.first(:field, locator, visible: false, minimum: 0) textareas << textarea if textarea.present? end @@ -254,5 +254,13 @@ def wait_for_nested_item(block_name, item_index) expect(page).to have_css(".item[data-name=\"#{block_name}\"][data-index=\"#{item_index}\"][style=\"opacity: 1; display: block;\"]") end + def download_file(url) + require "open-uri" + file = Tempfile.new + file.binmode + file.write(open(url).read) + file.flush + file + end end end diff --git a/releaf-content/app/assets/javascripts/controllers/releaf/content/nodes.js b/releaf-content/app/assets/javascripts/controllers/releaf/content/nodes.js index 017cfe37b..0de1885b7 100644 --- a/releaf-content/app/assets/javascripts/controllers/releaf/content/nodes.js +++ b/releaf-content/app/assets/javascripts/controllers/releaf/content/nodes.js @@ -76,17 +76,14 @@ jQuery(function() slug_input.trigger('sluggenerate'); }); - if (name_input.val() === '') + // bind onchange slug generation only if starting out with an empty name + name_input.on('change', function() { - // bind onchange slug generation only if starting out with an empty name - name_input.on('change', function() + if(slug_input.val().length === 0) { - if(slug_input.val().length === 0) - { - slug_input.trigger('sluggenerate'); - } - }); - } + slug_input.trigger('sluggenerate'); + } + }); } }); diff --git a/releaf-content/app/controllers/releaf/content/nodes_controller.rb b/releaf-content/app/controllers/releaf/content/nodes_controller.rb index 6c4bfe887..7dde5b40d 100644 --- a/releaf-content/app/controllers/releaf/content/nodes_controller.rb +++ b/releaf-content/app/controllers/releaf/content/nodes_controller.rb @@ -10,7 +10,7 @@ def generate_url tmp_resource.name = params[:name] tmp_resource.reasign_slug - render text: tmp_resource.slug + render plain: tmp_resource.slug end def content_type_dialog diff --git a/releaf-content/lib/releaf/content/node.rb b/releaf-content/lib/releaf/content/node.rb index 09c6ac916..30d3e7c5f 100644 --- a/releaf-content/lib/releaf/content/node.rb +++ b/releaf-content/lib/releaf/content/node.rb @@ -225,7 +225,7 @@ def valid_node_content_classes parent_id=nil validate :validate_parent_node_is_not_self validate :validate_parent_is_not_descendant validate :validate_slug - belongs_to :content, polymorphic: true, dependent: :destroy + belongs_to :content, polymorphic: true, dependent: :destroy, required: false accepts_nested_attributes_for :content after_save :update_settings_timestamp, unless: :prevent_auto_update_settings_timestamp? diff --git a/releaf-content/lib/releaf/content/route.rb b/releaf-content/lib/releaf/content/route.rb index b96fe22d6..587ee705b 100644 --- a/releaf-content/lib/releaf/content/route.rb +++ b/releaf-content/lib/releaf/content/route.rb @@ -57,7 +57,6 @@ def name( route_options ) # @return [Array] array of Content::Route objects def self.for(node_class, node_content_class, default_controller) node_class = node_class.constantize if node_class.is_a? String - Releaf::Content::BuildRouteObjects.call( node_class: node_class, node_content_class: node_content_class, diff --git a/releaf-content/releaf-content.gemspec b/releaf-content/releaf-content.gemspec index 8f189b290..f7dcf8493 100644 --- a/releaf-content/releaf-content.gemspec +++ b/releaf-content/releaf-content.gemspec @@ -17,5 +17,5 @@ Gem::Specification.new do |s| s.add_dependency 'releaf-core', Releaf::VERSION s.add_dependency 'stringex', '~> 2.6' s.add_dependency 'awesome_nested_set', '~> 3.1' - s.add_dependency 'deep_cloneable', '~> 2.2.2' + s.add_dependency 'deep_cloneable', '~> 2.3.0' end diff --git a/releaf-content/spec/features/nodes_services_spec.rb b/releaf-content/spec/features/nodes_services_spec.rb index c34593b56..00bbdaf2d 100644 --- a/releaf-content/spec/features/nodes_services_spec.rb +++ b/releaf-content/spec/features/nodes_services_spec.rb @@ -423,8 +423,8 @@ def expect_different_values original, copy expect_different_values(original_url, copied_file_urls[key]) [original_url, copied_file_urls[key]].each do |file_url| - visit file_url - expect(page.status_code).to eq 200 + tmpfile = download_file(file_url) + expect(Digest::SHA256.file(tmpfile)).to eq(Digest::SHA256.file(dummy_file_path)) end end diff --git a/releaf-content/spec/features/nodes_spec.rb b/releaf-content/spec/features/nodes_spec.rb index 7ddc812c1..6b1166c27 100644 --- a/releaf-content/spec/features/nodes_spec.rb +++ b/releaf-content/spec/features/nodes_spec.rb @@ -284,7 +284,7 @@ open_toolbox_dialog 'Add child', @lv_root, ".view-index .collection li" within_dialog do - click_link("Text page") + click_link("Text page") end fill_in "Slug", with: "some-slug" @@ -293,6 +293,7 @@ fill_in "Slug", with: "" fill_in 'Name', with: "About them" + blur_from "Name" expect(page).to have_field("Slug", with: "about-them") # fill text to allow text page save diff --git a/releaf-content/spec/lib/releaf/content/node_spec.rb b/releaf-content/spec/lib/releaf/content/node_spec.rb index 16da69450..3a9e24a3b 100644 --- a/releaf-content/spec/lib/releaf/content/node_spec.rb +++ b/releaf-content/spec/lib/releaf/content/node_spec.rb @@ -1,6 +1,6 @@ require "rails_helper" -describe Node do +describe Node, type: :model do class PlainNode < ActiveRecord::Base include Releaf::Content::Node self.table_name = "nodes" @@ -9,7 +9,7 @@ class PlainNode < ActiveRecord::Base let(:plain_subject){ PlainNode.new } it { is_expected.to accept_nested_attributes_for(:content) } - it { is_expected.to belong_to(:content) } + it { is_expected.to belong_to(:content).required(false) } it "includes Releaf::Content::Node module" do expect( Node.included_modules ).to include Releaf::Content::Node @@ -31,10 +31,12 @@ class PlainNode < ActiveRecord::Base end end - describe ".active (scope)" do + describe ":active scope" do it "returns active nodes" do - expect( Node ).to receive(:where).with(active: true).and_return('foo') - expect( Node.active ).to eq 'foo' + item_1 = create(:node, active: true, locale: "en") + item_2 = create(:node, active: false, locale: "de") + item_3 = create(:node, active: true, locale: "lv") + expect(Node.active).to eq [item_1, item_3] end end @@ -519,7 +521,7 @@ class PlainNode < ActiveRecord::Base context "when #prevent_auto_update_settings_timestamp? is false" do it "is called after save" do - node = FactoryGirl.build(:node) + node = build(:node) allow( node ).to receive(:prevent_auto_update_settings_timestamp?).and_return(false) expect( node ).to receive(:update_settings_timestamp).and_call_original node.save! @@ -528,7 +530,7 @@ class PlainNode < ActiveRecord::Base context "when #prevent_auto_update_settings_timestamp? is true" do it "is not called after save" do - node = FactoryGirl.build(:node) + node = build(:node) allow( node ).to receive(:prevent_auto_update_settings_timestamp?).and_return(true) expect( node ).to_not receive(:update_settings_timestamp) node.save! diff --git a/releaf-content/spec/lib/releaf/content/route_spec.rb b/releaf-content/spec/lib/releaf/content/route_spec.rb index fc94d79b6..e9d211f40 100644 --- a/releaf-content/spec/lib/releaf/content/route_spec.rb +++ b/releaf-content/spec/lib/releaf/content/route_spec.rb @@ -1,7 +1,7 @@ require "rails_helper" describe Releaf::Content::Route do - let(:node_route) { FactoryGirl.build(:node_route, node_class: Node, node_id: 12, locale: "en", path: "/en") } + let(:node_route) { FactoryBot.build(:node_route, node_class: Node, node_id: 12, locale: "en", path: "/en") } describe ".default_controller" do diff --git a/releaf-content/spec/routing/node_mapper_spec.rb b/releaf-content/spec/routing/node_mapper_spec.rb index c7858830a..c6b060a84 100644 --- a/releaf-content/spec/routing/node_mapper_spec.rb +++ b/releaf-content/spec/routing/node_mapper_spec.rb @@ -165,7 +165,8 @@ it "uses the custom path for public website route" do routes.draw do node_routes_for(TextPage) do |route| - get 'home_pages#show', path: "#{route.path}/abc/:my_id" + route.path += "/abc/:my_id" + get 'home_pages#show' end end diff --git a/releaf-content/spec/validators/content/node/parent_validator_spec.rb b/releaf-content/spec/validators/content/node/parent_validator_spec.rb index 9d3ac2805..a7ae66472 100644 --- a/releaf-content/spec/validators/content/node/parent_validator_spec.rb +++ b/releaf-content/spec/validators/content/node/parent_validator_spec.rb @@ -1,7 +1,7 @@ require 'rails_helper' describe Releaf::Content::Node::ParentValidator do - let!(:root_node) { FactoryGirl.create(:node, content_type: 'HomePage') } + let!(:root_node) { FactoryBot.create(:node, content_type: 'HomePage') } class DummyNodeParentValidatorModel < ActiveRecord::Base acts_as_node @@ -25,8 +25,8 @@ class DummyNodeParentValidatorNode < ActiveRecord::Base context "when parent is valid" do it "doesn't add error" do - parent = DummyNodeParentValidatorNode.create!( FactoryGirl.attributes_for(:node, content_type: 'DummyNodeParentValidator1Controller') ) - child = DummyNodeParentValidatorNode.new( FactoryGirl.attributes_for(:node, content_type: 'DummyNodeParentValidatorModel', parent_id: parent.id) ) + parent = DummyNodeParentValidatorNode.create!( FactoryBot.attributes_for(:node, content_type: 'DummyNodeParentValidator1Controller') ) + child = DummyNodeParentValidatorNode.new( FactoryBot.attributes_for(:node, content_type: 'DummyNodeParentValidatorModel', parent_id: parent.id) ) expect( child ).to be_valid end @@ -34,8 +34,8 @@ class DummyNodeParentValidatorNode < ActiveRecord::Base context "when parent is invalid" do it "adds error on content_type" do - parent = DummyNodeParentValidatorNode.create!( FactoryGirl.attributes_for(:node, content_type: 'DummyNodeParentValidator2Controller') ) - child = DummyNodeParentValidatorNode.new( FactoryGirl.attributes_for(:node, content_type: 'DummyNodeParentValidatorModel', parent_id: parent.id) ) + parent = DummyNodeParentValidatorNode.create!( FactoryBot.attributes_for(:node, content_type: 'DummyNodeParentValidator2Controller') ) + child = DummyNodeParentValidatorNode.new( FactoryBot.attributes_for(:node, content_type: 'DummyNodeParentValidatorModel', parent_id: parent.id) ) expect( child ).to be_invalid expect( child.errors[:content_type].size ).to eq(1) @@ -46,8 +46,8 @@ class DummyNodeParentValidatorNode < ActiveRecord::Base context "when content_type is not in child list" do it "doesn't add error" do - parent = DummyNodeParentValidatorNode.create!( FactoryGirl.attributes_for(:node, content_type: 'DummyNodeParentValidator1Controller') ) - child = DummyNodeParentValidatorNode.new( FactoryGirl.attributes_for(:node, content_type: 'DummyNodeParentValidator2Controller', parent_id: parent.id) ) + parent = DummyNodeParentValidatorNode.create!( FactoryBot.attributes_for(:node, content_type: 'DummyNodeParentValidator1Controller') ) + child = DummyNodeParentValidatorNode.new( FactoryBot.attributes_for(:node, content_type: 'DummyNodeParentValidator2Controller', parent_id: parent.id) ) expect( child ).to be_valid end diff --git a/releaf-content/spec/validators/content/node/root_validator_spec.rb b/releaf-content/spec/validators/content/node/root_validator_spec.rb index 2b216c54c..245e6f982 100644 --- a/releaf-content/spec/validators/content/node/root_validator_spec.rb +++ b/releaf-content/spec/validators/content/node/root_validator_spec.rb @@ -19,11 +19,11 @@ class DummyRootValidatorNode < ActiveRecord::Base def create_node *params - DummyRootValidatorNode.create!( FactoryGirl.attributes_for(:node, *params) ) + DummyRootValidatorNode.create!( FactoryBot.attributes_for(:node, *params) ) end def build_node *params - DummyRootValidatorNode.new( FactoryGirl.attributes_for(:node, *params) ) + DummyRootValidatorNode.new( FactoryBot.attributes_for(:node, *params) ) end context "when node is allowed to be root node" do diff --git a/releaf-content/spec/validators/content/node/singleness_validator_spec.rb b/releaf-content/spec/validators/content/node/singleness_validator_spec.rb index fc538766d..d89f5a339 100644 --- a/releaf-content/spec/validators/content/node/singleness_validator_spec.rb +++ b/releaf-content/spec/validators/content/node/singleness_validator_spec.rb @@ -30,11 +30,11 @@ class DummySinglenessValidatorNode < ActiveRecord::Base def create_node *params - DummySinglenessValidatorNode.create!( FactoryGirl.attributes_for(:node, *params) ) + DummySinglenessValidatorNode.create!( FactoryBot.attributes_for(:node, *params) ) end def build_node *params - DummySinglenessValidatorNode.new( FactoryGirl.attributes_for(:node, *params) ) + DummySinglenessValidatorNode.new( FactoryBot.attributes_for(:node, *params) ) end let!(:root_node) { create_node(content_type: 'HomePage') } diff --git a/releaf-core/app/assets/javascripts/releaf/include/remote_validator.js b/releaf-core/app/assets/javascripts/releaf/include/remote_validator.js index 431e5dd63..cac658594 100644 --- a/releaf-core/app/assets/javascripts/releaf/include/remote_validator.js +++ b/releaf-core/app/assets/javascripts/releaf/include/remote_validator.js @@ -372,7 +372,7 @@ RemoteValidator.prototype.register_clicked_button = function(button) v.clicked_button = button; // when sending form values with FormData, the clicked button value is not included in the data - // (except on Safari, and therefore also on PhantomJS - that's why the tests worked fine even without this). + // (except on Safari). // since releaf sometimes uses the clicked button value to modify the action on the server side, // (e.g. for "Save and create another" feature), the value of the clicked button must be appended diff --git a/releaf-core/app/assets/javascripts/releaf/include/store_settings.js b/releaf-core/app/assets/javascripts/releaf/include/store_settings.js index 4746a3299..729946707 100644 --- a/releaf-core/app/assets/javascripts/releaf/include/store_settings.js +++ b/releaf-core/app/assets/javascripts/releaf/include/store_settings.js @@ -12,8 +12,8 @@ jQuery(function(){ var settings = key_or_settings; if (typeof settings === "string") { - settings = {}; - settings[key_or_settings] = value; + settings = []; + settings.push({key: key_or_settings, value: value}); } LiteAjax.ajax({ url: settings_path, method: 'POST', data: { "settings": settings}, json: true }) diff --git a/releaf-core/app/builders/releaf/builders.rb b/releaf-core/app/builders/releaf/builders.rb index 73e67aeb1..76256b85b 100644 --- a/releaf-core/app/builders/releaf/builders.rb +++ b/releaf-core/app/builders/releaf/builders.rb @@ -29,7 +29,10 @@ def self.constant_defined_at_scope?(mapping, at) end def self.constant_name_error?(error_message, mapping) - (error_message =~ /#{mapping}$/).present? + # rails5 have anonymous classes while in production env for error messags + # ex. `Caused by NameError: uninitialized constant #::AnotherFormBuilder` instead of + # `Caused by NameError: uninitialized constant Releaf::Builders::AnotherFormBuilder` + (error_message =~ /#{mapping.split("::").last}$/).present? end def self.inherited_builder_scopes diff --git a/releaf-core/app/builders/releaf/builders/form_builder/associations.rb b/releaf-core/app/builders/releaf/builders/form_builder/associations.rb index f36308837..53c4c3f97 100644 --- a/releaf-core/app/builders/releaf/builders/form_builder/associations.rb +++ b/releaf-core/app/builders/releaf/builders/form_builder/associations.rb @@ -73,7 +73,7 @@ def releaf_has_many_association_body(reflector) attributes = { class: ["body", "list"] } - attributes["data"] = {sortable: nil} if reflector.sortable? + attributes["data"] = {sortable: true} if reflector.sortable? tag(:div, attributes) do association_collection(reflector).each_with_index.map do |association_object, index| diff --git a/releaf-core/app/builders/releaf/builders/pagination_builder.rb b/releaf-core/app/builders/releaf/builders/pagination_builder.rb index f6faa41fe..2ce61cd2c 100644 --- a/releaf-core/app/builders/releaf/builders/pagination_builder.rb +++ b/releaf-core/app/builders/releaf/builders/pagination_builder.rb @@ -79,7 +79,7 @@ def relative_page_relationship(offset) end def page_url(page_number) - template.url_for( params.merge( page: page_number )) + template.url_for( params.merge( page: page_number ).permit! ) end def pagination_select diff --git a/releaf-core/app/controllers/releaf/root_controller.rb b/releaf-core/app/controllers/releaf/root_controller.rb index e1bf929ef..08263e61c 100644 --- a/releaf-core/app/controllers/releaf/root_controller.rb +++ b/releaf-core/app/controllers/releaf/root_controller.rb @@ -13,15 +13,17 @@ def features # Store settings for menu collapsing and others def store_settings - if params[:settings].is_a? Hash - params[:settings].each_pair do|key, value| - value = false if value == "false" - value = true if value == "true" - Releaf.application.config.settings_manager.write(controller: self, key: key, value: value) + settings = params.permit(settings: [:key, :value]).to_h.fetch(:settings, nil) + if settings + settings.each do|item| + next if item[:key].nil? || item[:value].nil? + item[:value] = true if item[:value] == "true" + item[:value] = false if item[:value] == "false" + Releaf.application.config.settings_manager.write(controller: self, key: item[:key], value: item[:value]) end - render nothing: true, status: 200 + head :ok else - render nothing: true, status: 422 + head :unprocessable_entity end end end diff --git a/releaf-core/app/lib/releaf/search.rb b/releaf-core/app/lib/releaf/search.rb index 610d98233..1b0b52a8b 100644 --- a/releaf-core/app/lib/releaf/search.rb +++ b/releaf-core/app/lib/releaf/search.rb @@ -74,7 +74,7 @@ def join_reflection_without_through(reflection, table) join_condition = case reflection.macro when :has_many - self.relation = relation.uniq + self.relation = relation.distinct table1[primary_key].eq(table2[foreign_key]) when :has_one table1[primary_key].eq(table2[foreign_key]) @@ -90,7 +90,7 @@ def join_reflection_without_through(reflection, table) end if reflection.scope - where_scope = extract_where_condtion_from_scope(reflection, table2_alias) + where_scope = extract_where_condition_from_scope(reflection, table2_alias) join_condition = join_condition.and(where_scope) if where_scope.present? end @@ -103,25 +103,12 @@ def join_reflection_without_through(reflection, table) table2 end - def extract_where_condtion_from_scope(reflection, table_alias) - # XXX Hack based on ActiveRecord::Relation#to_sql + def extract_where_condition_from_scope(reflection, table_alias) tmp_relation = build_tmp_relation(reflection, table_alias) - where_scope = tmp_relation.where_values + return nil if tmp_relation.where_values_hash.blank? - return nil if where_scope.blank? - - connection = tmp_relation.klass.connection - visitor = connection.visitor - - arel = tmp_relation.arel - binds = (arel.bind_values + tmp_relation.bind_values).dup - binds.map! { |bv| connection.quote(*bv.reverse) } - - wheres = tmp_relation.arel.ast.cores.first.wheres - collect = visitor.accept(wheres, Arel::Collectors::Bind.new) - sql = collect.compile(binds) - Arel::Nodes::SqlLiteral.new(sql) + tmp_relation.arel.ast.cores.first.wheres end def build_tmp_relation(reflection, table_alias) diff --git a/releaf-core/app/models/releaf/settings.rb b/releaf-core/app/models/releaf/settings.rb index bee921035..cdd595ea4 100644 --- a/releaf-core/app/models/releaf/settings.rb +++ b/releaf-core/app/models/releaf/settings.rb @@ -1,6 +1,6 @@ class Releaf::Settings < RailsSettings::Base - scope :registered, -> { where(var: registered_keys).order(:var) } + scope :registered, -> { where(var: registered_keys, thing_type: nil, thing_id: nil).order(:var) } cattr_accessor :registry @@registry = {}.with_indifferent_access diff --git a/releaf-core/app/views/releaf/action/create_releaf_richtext_attachment.haml b/releaf-core/app/views/releaf/action/create_releaf_richtext_attachment.haml index 7956ebb49..a2772403a 100644 --- a/releaf-core/app/views/releaf/action/create_releaf_richtext_attachment.haml +++ b/releaf-core/app/views/releaf/action/create_releaf_richtext_attachment.haml @@ -1 +1,2 @@ -%script{type: "text/javascript"}= "window.parent.CKEDITOR.tools.callFunction(#{params[:CKEditorFuncNum]}, '#{@resource.file.url}', '');" +:javascript + window.parent.CKEDITOR.tools.callFunction(#{params[:CKEditorFuncNum]}, '#{@resource.file.url.html_safe}', ''); diff --git a/releaf-core/lib/generators/dummy/templates/controllers/application_controller.rb b/releaf-core/lib/generators/dummy/templates/controllers/application_controller.rb index 33576d135..6ae4b377e 100644 --- a/releaf-core/lib/generators/dummy/templates/controllers/application_controller.rb +++ b/releaf-core/lib/generators/dummy/templates/controllers/application_controller.rb @@ -23,7 +23,7 @@ def redirect_to_locale_root if target_root redirect_to target_root.path else - render text: "Welcome to Releaf", layout: true + render plain: "Welcome to Releaf", layout: true end end diff --git a/releaf-core/lib/generators/dummy/templates/migrations/create_authors.rb b/releaf-core/lib/generators/dummy/templates/migrations/create_authors.rb index 41df98121..3e1c585b8 100644 --- a/releaf-core/lib/generators/dummy/templates/migrations/create_authors.rb +++ b/releaf-core/lib/generators/dummy/templates/migrations/create_authors.rb @@ -1,4 +1,4 @@ -class CreateAuthors < ActiveRecord::Migration +class CreateAuthors < ActiveRecord::Migration[5.0] def change create_table :authors do |t| t.string :name, :null => false diff --git a/releaf-core/lib/generators/dummy/templates/migrations/create_banner_groups.rb b/releaf-core/lib/generators/dummy/templates/migrations/create_banner_groups.rb index 104ad2329..dce261044 100644 --- a/releaf-core/lib/generators/dummy/templates/migrations/create_banner_groups.rb +++ b/releaf-core/lib/generators/dummy/templates/migrations/create_banner_groups.rb @@ -1,4 +1,4 @@ -class CreateBannerGroups < ActiveRecord::Migration +class CreateBannerGroups < ActiveRecord::Migration[5.0] def change create_table :banner_groups do |t| t.integer :banner_page_id diff --git a/releaf-core/lib/generators/dummy/templates/migrations/create_banner_pages.rb b/releaf-core/lib/generators/dummy/templates/migrations/create_banner_pages.rb index 7b613b3fc..26e32b54e 100644 --- a/releaf-core/lib/generators/dummy/templates/migrations/create_banner_pages.rb +++ b/releaf-core/lib/generators/dummy/templates/migrations/create_banner_pages.rb @@ -1,9 +1,9 @@ -class CreateBannerPages < ActiveRecord::Migration +class CreateBannerPages < ActiveRecord::Migration[5.0] def change create_table :banner_pages do |t| t.text :intro_text_html t.string :top_banner_uid - t.string :bottom_banner_uid + t.string :bottom_banner_uid t.timestamps(null: false) end diff --git a/releaf-core/lib/generators/dummy/templates/migrations/create_banners.rb b/releaf-core/lib/generators/dummy/templates/migrations/create_banners.rb index a218105e2..6038b81d2 100644 --- a/releaf-core/lib/generators/dummy/templates/migrations/create_banners.rb +++ b/releaf-core/lib/generators/dummy/templates/migrations/create_banners.rb @@ -1,8 +1,8 @@ -class CreateBanners < ActiveRecord::Migration +class CreateBanners < ActiveRecord::Migration[5.0] def change create_table :banners do |t| t.integer :banner_group_id - t.integer :item_position + t.integer :item_position t.string :image_uid t.string :url t.timestamps(null: false) diff --git a/releaf-core/lib/generators/dummy/templates/migrations/create_book_sequels.rb b/releaf-core/lib/generators/dummy/templates/migrations/create_book_sequels.rb index 7ee78a578..a5f70f4f0 100644 --- a/releaf-core/lib/generators/dummy/templates/migrations/create_book_sequels.rb +++ b/releaf-core/lib/generators/dummy/templates/migrations/create_book_sequels.rb @@ -1,4 +1,4 @@ -class CreateBookSequels < ActiveRecord::Migration +class CreateBookSequels < ActiveRecord::Migration[5.0] def up create_table :book_sequels do |t| t.integer :book_id, null: false diff --git a/releaf-core/lib/generators/dummy/templates/migrations/create_books.rb b/releaf-core/lib/generators/dummy/templates/migrations/create_books.rb index 305edea2b..b16253c6f 100644 --- a/releaf-core/lib/generators/dummy/templates/migrations/create_books.rb +++ b/releaf-core/lib/generators/dummy/templates/migrations/create_books.rb @@ -1,4 +1,4 @@ -class CreateBooks < ActiveRecord::Migration +class CreateBooks < ActiveRecord::Migration[5.0] def up create_table :books do |t| t.string :title, null: false diff --git a/releaf-core/lib/generators/dummy/templates/migrations/create_bundles.rb b/releaf-core/lib/generators/dummy/templates/migrations/create_bundles.rb index c7022790c..0cf5ad0ac 100644 --- a/releaf-core/lib/generators/dummy/templates/migrations/create_bundles.rb +++ b/releaf-core/lib/generators/dummy/templates/migrations/create_bundles.rb @@ -1,4 +1,4 @@ -class CreateBundles < ActiveRecord::Migration +class CreateBundles < ActiveRecord::Migration[5.0] def change create_table :bundles do |t| t.timestamps(null: false) diff --git a/releaf-core/lib/generators/dummy/templates/migrations/create_chapters.rb b/releaf-core/lib/generators/dummy/templates/migrations/create_chapters.rb index 021197769..d2266d326 100644 --- a/releaf-core/lib/generators/dummy/templates/migrations/create_chapters.rb +++ b/releaf-core/lib/generators/dummy/templates/migrations/create_chapters.rb @@ -1,4 +1,4 @@ -class CreateChapters < ActiveRecord::Migration +class CreateChapters < ActiveRecord::Migration[5.0] def change create_table :chapters do |t| t.string :title, :null => false diff --git a/releaf-core/lib/generators/dummy/templates/migrations/create_home_pages.rb b/releaf-core/lib/generators/dummy/templates/migrations/create_home_pages.rb index ab2a03b45..b79fba148 100644 --- a/releaf-core/lib/generators/dummy/templates/migrations/create_home_pages.rb +++ b/releaf-core/lib/generators/dummy/templates/migrations/create_home_pages.rb @@ -1,4 +1,4 @@ -class CreateHomePages < ActiveRecord::Migration +class CreateHomePages < ActiveRecord::Migration[5.0] def change create_table :home_pages do |t| t.text :intro_text_html diff --git a/releaf-core/lib/generators/dummy/templates/migrations/create_node_extra_fields.rb b/releaf-core/lib/generators/dummy/templates/migrations/create_node_extra_fields.rb index c438da4b0..8c38e96c9 100644 --- a/releaf-core/lib/generators/dummy/templates/migrations/create_node_extra_fields.rb +++ b/releaf-core/lib/generators/dummy/templates/migrations/create_node_extra_fields.rb @@ -1,4 +1,4 @@ -class CreateNodeExtraFields < ActiveRecord::Migration +class CreateNodeExtraFields < ActiveRecord::Migration[5.0] def change add_column :nodes, :description, :text end diff --git a/releaf-core/lib/generators/dummy/templates/migrations/create_other_nodes.rb b/releaf-core/lib/generators/dummy/templates/migrations/create_other_nodes.rb index a65a19321..3c084d787 100644 --- a/releaf-core/lib/generators/dummy/templates/migrations/create_other_nodes.rb +++ b/releaf-core/lib/generators/dummy/templates/migrations/create_other_nodes.rb @@ -1,4 +1,4 @@ -class CreateOtherNodes < ActiveRecord::Migration +class CreateOtherNodes < ActiveRecord::Migration[5.0] def change create_table "other_nodes", :force => true do |t| t.string "name" diff --git a/releaf-core/lib/generators/dummy/templates/migrations/create_publishers.rb b/releaf-core/lib/generators/dummy/templates/migrations/create_publishers.rb index 0baa932c8..f92b3dec7 100644 --- a/releaf-core/lib/generators/dummy/templates/migrations/create_publishers.rb +++ b/releaf-core/lib/generators/dummy/templates/migrations/create_publishers.rb @@ -1,4 +1,4 @@ -class CreatePublishers < ActiveRecord::Migration +class CreatePublishers < ActiveRecord::Migration[5.0] def change create_table :publishers do |t| t.string :title, :null => false diff --git a/releaf-core/lib/generators/dummy/templates/migrations/create_text_pages.rb b/releaf-core/lib/generators/dummy/templates/migrations/create_text_pages.rb index 8a92810bb..3505760ce 100644 --- a/releaf-core/lib/generators/dummy/templates/migrations/create_text_pages.rb +++ b/releaf-core/lib/generators/dummy/templates/migrations/create_text_pages.rb @@ -1,4 +1,4 @@ -class CreateTextPages < ActiveRecord::Migration +class CreateTextPages < ActiveRecord::Migration[5.0] def change create_table :text_pages do |t| t.text :text_html diff --git a/releaf-core/lib/generators/dummy/templates/models/author.rb b/releaf-core/lib/generators/dummy/templates/models/author.rb index 632f52abb..8b366fdf5 100644 --- a/releaf-core/lib/generators/dummy/templates/models/author.rb +++ b/releaf-core/lib/generators/dummy/templates/models/author.rb @@ -1,6 +1,6 @@ class Author < ActiveRecord::Base validates_presence_of :name - belongs_to :publisher + belongs_to :publisher, required: false has_many :books, dependent: :restrict_with_exception diff --git a/releaf-core/lib/generators/dummy/templates/models/banner.rb b/releaf-core/lib/generators/dummy/templates/models/banner.rb index 95b5ff4e8..639316b23 100644 --- a/releaf-core/lib/generators/dummy/templates/models/banner.rb +++ b/releaf-core/lib/generators/dummy/templates/models/banner.rb @@ -1,7 +1,7 @@ class Banner < ActiveRecord::Base dragonfly_accessor :image validates_presence_of :url - belongs_to :banner_group + belongs_to :banner_group, required: false def releaf_title url diff --git a/releaf-core/lib/generators/dummy/templates/models/banner_group.rb b/releaf-core/lib/generators/dummy/templates/models/banner_group.rb index 536d36f25..03978874b 100644 --- a/releaf-core/lib/generators/dummy/templates/models/banner_group.rb +++ b/releaf-core/lib/generators/dummy/templates/models/banner_group.rb @@ -1,7 +1,7 @@ class BannerGroup < ActiveRecord::Base dragonfly_accessor :image validates_presence_of :title - belongs_to :home_page + belongs_to :home_page, required: false has_many :banners, -> { order(:item_position) }, dependent: :destroy accepts_nested_attributes_for :banners, allow_destroy: true diff --git a/releaf-core/lib/generators/dummy/templates/models/book.rb b/releaf-core/lib/generators/dummy/templates/models/book.rb index 120bfa226..ab9fb34b0 100644 --- a/releaf-core/lib/generators/dummy/templates/models/book.rb +++ b/releaf-core/lib/generators/dummy/templates/models/book.rb @@ -1,5 +1,5 @@ class Book < ActiveRecord::Base - belongs_to :author + belongs_to :author, optional: true has_many :chapters, -> { order(:item_position) }, inverse_of: :book has_many :book_sequels, dependent: :destroy has_many :sequels, through: :book_sequels diff --git a/releaf-core/lib/generators/releaf/templates/migrations/create_releaf_nodes.rb b/releaf-core/lib/generators/releaf/templates/migrations/create_releaf_nodes.rb index 738857861..fe1539267 100644 --- a/releaf-core/lib/generators/releaf/templates/migrations/create_releaf_nodes.rb +++ b/releaf-core/lib/generators/releaf/templates/migrations/create_releaf_nodes.rb @@ -1,4 +1,4 @@ -class CreateReleafNodes < ActiveRecord::Migration +class CreateReleafNodes < ActiveRecord::Migration[5.0] def change create_table "nodes", :force => true do |t| t.string "name" diff --git a/releaf-core/lib/generators/releaf/templates/migrations/create_releaf_permissions.rb b/releaf-core/lib/generators/releaf/templates/migrations/create_releaf_permissions.rb index ea495502d..b9a3dd5f4 100644 --- a/releaf-core/lib/generators/releaf/templates/migrations/create_releaf_permissions.rb +++ b/releaf-core/lib/generators/releaf/templates/migrations/create_releaf_permissions.rb @@ -1,4 +1,4 @@ -class CreateReleafPermissions < ActiveRecord::Migration +class CreateReleafPermissions < ActiveRecord::Migration[5.0] def change create_table :releaf_permissions do |t| t.integer :owner_id diff --git a/releaf-core/lib/generators/releaf/templates/migrations/create_releaf_richtext_attachments.rb b/releaf-core/lib/generators/releaf/templates/migrations/create_releaf_richtext_attachments.rb index 139404cab..9d072120f 100644 --- a/releaf-core/lib/generators/releaf/templates/migrations/create_releaf_richtext_attachments.rb +++ b/releaf-core/lib/generators/releaf/templates/migrations/create_releaf_richtext_attachments.rb @@ -1,4 +1,4 @@ -class CreateReleafRichtextAttachments < ActiveRecord::Migration +class CreateReleafRichtextAttachments < ActiveRecord::Migration[5.0] def change create_table :releaf_richtext_attachments do |t| t.string :file_uid diff --git a/releaf-core/lib/generators/releaf/templates/migrations/create_releaf_roles.rb b/releaf-core/lib/generators/releaf/templates/migrations/create_releaf_roles.rb index dfb3e519f..cf7466778 100644 --- a/releaf-core/lib/generators/releaf/templates/migrations/create_releaf_roles.rb +++ b/releaf-core/lib/generators/releaf/templates/migrations/create_releaf_roles.rb @@ -1,4 +1,4 @@ -class CreateReleafRoles < ActiveRecord::Migration +class CreateReleafRoles < ActiveRecord::Migration[5.0] def change create_table :releaf_roles do |t| t.string :name, :null => false diff --git a/releaf-core/lib/generators/releaf/templates/migrations/create_releaf_settings.rb b/releaf-core/lib/generators/releaf/templates/migrations/create_releaf_settings.rb index e0b0064eb..7a88b5f6e 100644 --- a/releaf-core/lib/generators/releaf/templates/migrations/create_releaf_settings.rb +++ b/releaf-core/lib/generators/releaf/templates/migrations/create_releaf_settings.rb @@ -1,4 +1,4 @@ -class CreateReleafSettings < ActiveRecord::Migration +class CreateReleafSettings < ActiveRecord::Migration[5.0] def self.up create_table :settings do |t| t.string :var, :null => false diff --git a/releaf-core/lib/generators/releaf/templates/migrations/create_releaf_translations.rb b/releaf-core/lib/generators/releaf/templates/migrations/create_releaf_translations.rb index 9a548bf66..53432657d 100644 --- a/releaf-core/lib/generators/releaf/templates/migrations/create_releaf_translations.rb +++ b/releaf-core/lib/generators/releaf/templates/migrations/create_releaf_translations.rb @@ -1,4 +1,4 @@ -class CreateReleafTranslations < ActiveRecord::Migration +class CreateReleafTranslations < ActiveRecord::Migration[5.0] def change create_table :releaf_i18n_entries do |t| t.string :key, null: false diff --git a/releaf-core/lib/generators/releaf/templates/migrations/create_releaf_users.rb b/releaf-core/lib/generators/releaf/templates/migrations/create_releaf_users.rb index 798cabb71..ac1ef97bf 100644 --- a/releaf-core/lib/generators/releaf/templates/migrations/create_releaf_users.rb +++ b/releaf-core/lib/generators/releaf/templates/migrations/create_releaf_users.rb @@ -1,4 +1,4 @@ -class CreateReleafUsers < ActiveRecord::Migration +class CreateReleafUsers < ActiveRecord::Migration[5.0] def change create_table :releaf_users do |t| t.string :name, :null => false diff --git a/releaf-core/releaf-core.gemspec b/releaf-core/releaf-core.gemspec index 1938466cb..f6e267479 100644 --- a/releaf-core/releaf-core.gemspec +++ b/releaf-core/releaf-core.gemspec @@ -14,22 +14,26 @@ Gem::Specification.new do |s| s.files = Dir["app/**/*"] + Dir["lib/**/*"] + ["LICENSE"] s.test_files = Dir["spec/**/*"] - s.add_dependency 'rails', '~> 4.2' - s.add_dependency 'i18n', '~> 0.7' + s.add_dependency 'rails', '~> 5.2.4' + s.add_dependency 'activesupport', '~> 5.2.4' + s.add_dependency 'activerecord', '~> 5.2.4' + s.add_dependency 'i18n', '~> 1.8.2' s.add_dependency 'sprockets-rails', '~> 3.0' s.add_dependency 'sass-rails', '~> 5.0' s.add_dependency 'jquery-rails', '~> 4.2' s.add_dependency 'jquery-ui-rails', '~> 5.0' s.add_dependency 'vanilla-ujs', '~> 1.2' - s.add_dependency 'railties', '~> 4.2' - s.add_dependency 'haml-rails', '~> 0.9' + s.add_dependency 'railties', '~> 5.2.4' + s.add_dependency 'haml-rails', '~> 2.0' + s.add_dependency 'bootsnap', '~> 1.4.6' s.add_dependency 'dragonfly', '~> 1.0' s.add_dependency 'rails-settings-cached', '~> 0.4' s.add_dependency 'ckeditor_rails', '~> 4.5' s.add_dependency 'acts_as_list', '~> 0.8' s.add_dependency 'will_paginate', '~> 3.1' s.add_dependency 'font-awesome-rails', '~> 4.6' - s.add_dependency 'globalize-accessors', '~> 0.2' + s.add_dependency 'globalize', '5.2.0' + s.add_dependency 'globalize-accessors', '~> 0.2.1' s.add_dependency 'rack-cache', '~> 1.0' s.add_dependency 'virtus', '~> 1.0' end diff --git a/releaf-core/spec/builders/releaf/builders/association_reflector_spec.rb b/releaf-core/spec/builders/releaf/builders/association_reflector_spec.rb index 02e6dbe22..68107bbaa 100644 --- a/releaf-core/spec/builders/releaf/builders/association_reflector_spec.rb +++ b/releaf-core/spec/builders/releaf/builders/association_reflector_spec.rb @@ -125,7 +125,7 @@ else fail end - expect(subject.value_as_sql(Book.all)).to eq(expected_result) + expect(subject.value_as_sql(Book.all)).to match "SELECT" end end diff --git a/releaf-core/spec/builders/releaf/builders/edit_builder_spec.rb b/releaf-core/spec/builders/releaf/builders/edit_builder_spec.rb index 759ccf1c2..7cfa50524 100644 --- a/releaf-core/spec/builders/releaf/builders/edit_builder_spec.rb +++ b/releaf-core/spec/builders/releaf/builders/edit_builder_spec.rb @@ -9,7 +9,7 @@ class TranslationsEditBuilderTestHelper < ActionView::Base def protect_against_forgery? true end - def form_authenticity_token + def form_authenticity_token(_) "xxx" end @@ -127,7 +127,7 @@ def request_forgery_protection_token describe "#create_another_available?" do context "when editing an existing record" do - let(:resource){ FactoryGirl.create(:book) } + let(:resource){ FactoryBot.create(:book) } context "when controller has create_another feature enabled" do it "returns false" do diff --git a/releaf-core/spec/builders/releaf/builders/page/header_builder_spec.rb b/releaf-core/spec/builders/releaf/builders/page/header_builder_spec.rb index eee72a771..dbfa50a98 100644 --- a/releaf-core/spec/builders/releaf/builders/page/header_builder_spec.rb +++ b/releaf-core/spec/builders/releaf/builders/page/header_builder_spec.rb @@ -40,7 +40,8 @@ def request_forgery_protection_token allow(subject).to receive(:home_url).and_return("www.xxx") allow(subject).to receive(:home_text).and_return("Rrr") allow(subject).to receive(:home_image_path).and_return("releaf/foo.png") - content = 'Rrr' + allow(subject).to receive(:image_tag).with("releaf/foo.png", alt: "Rrr").and_return('IMG') + content = 'IMG' expect(subject.home_link).to eq(content) end end diff --git a/releaf-core/spec/builders/releaf/builders/pagination_builder_spec.rb b/releaf-core/spec/builders/releaf/builders/pagination_builder_spec.rb index 38b9b63c8..e5cec8a51 100644 --- a/releaf-core/spec/builders/releaf/builders/pagination_builder_spec.rb +++ b/releaf-core/spec/builders/releaf/builders/pagination_builder_spec.rb @@ -13,7 +13,7 @@ class PaginationTestView < ActionView::Base let(:items_per_page) { 3 } let(:current_page_number) { 1 } let(:collection){ Book.page(current_page_number).per_page(items_per_page) } - let(:params){ { search: "xxx"} } + let(:params){ ActionController::Parameters.new(search: "xxx") } let(:subject){ described_class.new(template, collection: collection, params: params ) } before do |example| @@ -50,7 +50,7 @@ class PaginationTestView < ActionView::Base context "when collection has less entries than allowed on one page" do before do - FactoryGirl.create( :book ) + create( :book ) end it "returns nil" do @@ -63,7 +63,7 @@ class PaginationTestView < ActionView::Base context "when collection has exactly the number of entries that fits on one page" do before do items_per_page.times do - FactoryGirl.create( :book ) + create( :book ) end end @@ -78,7 +78,7 @@ class PaginationTestView < ActionView::Base context "when collection has more than one page" do before do (items_per_page + 1).times do - FactoryGirl.create( :book ) + create( :book ) end end @@ -108,7 +108,7 @@ class PaginationTestView < ActionView::Base it "returns pagination buttons and select with options" do 14.times do - FactoryGirl.create :book + create :book end expect(subject.pagination_block).to match_html %Q[ @@ -183,7 +183,7 @@ def next_page_button it "returns a button with correct class and rel attributes and a href pointing to the offset page" do 5.times do - FactoryGirl.create(:book) + create(:book) end expect(subject.page_button( 1, 'foo', 'foo-icon' )).to match_html %Q[ @@ -277,7 +277,7 @@ def next_page_button describe "#page_url", stub_url_for: false do it "calls url_for on template with added page number param" do - expect(template).to receive(:url_for).with( search: "xxx", page: 3).and_return("ok") + expect(template).to receive(:url_for).with(ActionController::Parameters.new(search: "xxx", page: 3).permit!).and_return("ok") expect(subject.page_url(3)).to eq "ok" end @@ -317,7 +317,7 @@ def next_page_button describe "#page_label" do before do - 14.times { FactoryGirl.create :book } + 14.times { create :book } end it "returns a string with the numbers of first and last items in page" do diff --git a/releaf-core/spec/builders/releaf/builders_spec.rb b/releaf-core/spec/builders/releaf/builders_spec.rb index 67b17889e..9e62e2bbb 100644 --- a/releaf-core/spec/builders/releaf/builders_spec.rb +++ b/releaf-core/spec/builders/releaf/builders_spec.rb @@ -125,6 +125,16 @@ class Admin::Advanced::Builders < Releaf::Builders; end end end + describe ".constant_name_error?" do + it "returns true when error matches given mapping" do + expect(described_class.constant_name_error?("Caused by NameError: uninitialized constant #::AnotherFormBuilder", "Releaf::Builders::AnotherFormBuilder")).to be true + end + + it "returns fales when error doesnt match given mapping" do + expect(described_class.constant_name_error?("Caused by NameError: uninitialized something", "Releaf::Builders::AnotherFormBuilder")).to be false + end + end + describe ".inherited_builder_scopes" do it "returns inherited classes except Object and BasicObject" do expect(described_class.inherited_builder_scopes).to eq(["Releaf::Builders"]) diff --git a/releaf-core/spec/controllers/concerns/releaf/richtext_attachments_spec.rb b/releaf-core/spec/controllers/concerns/releaf/richtext_attachments_spec.rb index 4dd00318b..bece4b9ca 100644 --- a/releaf-core/spec/controllers/concerns/releaf/richtext_attachments_spec.rb +++ b/releaf-core/spec/controllers/concerns/releaf/richtext_attachments_spec.rb @@ -10,14 +10,14 @@ context "when file is uploaded" do it "renders 'create_releaf_richtext_attachment'" do - post :create_releaf_richtext_attachment, upload: file + post :create_releaf_richtext_attachment, params: {upload: file} expect( response ).to be_successful expect( response ).to render_template('create_releaf_richtext_attachment') end it "creates attachment" do expect do - post :create_releaf_richtext_attachment, upload: file + post :create_releaf_richtext_attachment, params: {upload: file} end.to change { Releaf::RichtextAttachment.count }.by(1) end end diff --git a/releaf-core/spec/controllers/releaf/action_controller_spec.rb b/releaf-core/spec/controllers/releaf/action_controller_spec.rb index b67b28cf5..c0f11ab85 100644 --- a/releaf-core/spec/controllers/releaf/action_controller_spec.rb +++ b/releaf-core/spec/controllers/releaf/action_controller_spec.rb @@ -169,14 +169,14 @@ class FooFormBuilder; end # have no extra methods or overrides describe Admin::AuthorsController do before do - sign_in FactoryGirl.create(:user) + sign_in FactoryBot.create(:user) end describe "#index_path" do context "when action is other than :index" do context "when params have valid `index_path` value" do it "returns params 'index_path'" do - get :new, index_path: "xxxxxxxx" + get :new, params: {index_path: "xxxxxxxx"} allow(subject).to receive(:valid_index_path?).with("xxxxxxxx").and_return(true) expect(subject.index_path).to eq("xxxxxxxx") end @@ -184,7 +184,7 @@ class FooFormBuilder; end context "when params have invalid `index_path` value" do it "returns index action path" do - get :new, index_path: "xxxxxxxx" + get :new, params: {index_path: "xxxxxxxx"} allow(subject).to receive(:valid_index_path?).with("xxxxxxxx").and_return(false) expect(subject.index_path).to eq("/admin/authors") end @@ -228,7 +228,7 @@ class FooFormBuilder; end describe "#current_path" do it "returns current url without `ajax` param" do - get :index, ajax: 1, search: "something", page: 1 + get :index, params: {ajax: 1, search: "something", page: 1} expect(subject.current_path).to eq("/admin/authors?page=1&search=something") end @@ -271,15 +271,15 @@ class FooFormBuilder; end context "when `ajax` params exists within params" do it "assigns `true` to @_ajax instance variable" do - expect{ get :index, ajax: 1 }.to change{ subject.instance_variable_get("@_ajax") }.from(nil).to(true) + expect{ get :index, params: {ajax: 1} }.to change{ subject.instance_variable_get("@_ajax") }.from(nil).to(true) end it "removes ajax from `params`" do - expect{ get :index, ajax: 1 }.to_not change{ subject.params[:ajax] }.from(nil) + expect{ get :index, params: {ajax: 1} }.to_not change{ subject.params[:ajax] }.from(nil) end it "removes ajax from `request.query_parameters`" do - expect{ get :index, ajax: 1 }.to_not change{ subject.request.query_parameters[:ajax] }.from(nil) + expect{ get :index, params: {ajax: 1} }.to_not change{ subject.request.query_parameters[:ajax] }.from(nil) end end end @@ -290,7 +290,7 @@ class FooFormBuilder; end context "when show feature is available" do it "assigns all resources to @collection" do allow(subject).to receive(:feature_available?).with(:show).and_return(true) - get :show, id: author + get :show, params: {id: author} expect(assigns(:resource)).to eq(author) end end @@ -299,7 +299,7 @@ class FooFormBuilder; end it "does assign resource" do allow(subject).to receive(:feature_available?).and_call_original allow(subject).to receive(:feature_available?).with(:show).and_return(false) - get :show, id: author + get :show, params: {id: author} expect(assigns(:resource)).to be nil end end @@ -308,13 +308,13 @@ class FooFormBuilder; end describe "GET index" do before do 21.times do |i| - FactoryGirl.create(:author) + FactoryBot.create(:author) end end context "when resources_per_page is nil" do it "assigns all resources to @collection" do - get :index, show_all: 1 + get :index, params: {show_all: 1} expect(assigns(:collection).is_a?(ActiveRecord::Relation)).to be true expect(assigns(:collection).size).to eq(21) end @@ -331,13 +331,13 @@ class FooFormBuilder; end describe "DELETE #destroy" do before do - @author = FactoryGirl.create(:author) - FactoryGirl.create(:book, title: "The book", author: @author) - FactoryGirl.create(:book, title: "Almost the book", author: @author) + @author = FactoryBot.create(:author) + FactoryBot.create(:book, title: "The book", author: @author) + FactoryBot.create(:book, title: "Almost the book", author: @author) end it "creates flash error with message" do - delete :destroy, id: @author + delete :destroy, params: {id: @author} expect(flash["error"]).to eq({"id" => "resource_status", "message" => "Cant destroy, because relations exists"}) end end @@ -345,7 +345,7 @@ class FooFormBuilder; end describe Admin::BooksController do before do - sign_in FactoryGirl.create(:user) + sign_in FactoryBot.create(:user) @breadcrumbs_base = [ {name: I18n.t('admin/books'), url: admin_books_path} ] @@ -353,28 +353,28 @@ class FooFormBuilder; end describe "GET #index" do before do - FactoryGirl.create(:book, title: "great one") - FactoryGirl.create(:book, title: "bad one") - FactoryGirl.create(:book, title: "average third") + FactoryBot.create(:book, title: "great one") + FactoryBot.create(:book, title: "bad one") + FactoryBot.create(:book, title: "average third") end context "when empty search string given" do it "shows all records" do - get :index, search: "" + get :index, params: {search: ""} expect(assigns(:collection).count).to eq(3) end end context "when search string with multiple words given" do it "searches by given string" do - get :index, search: "one grea" + get :index, params: {search: "one grea"} expect(assigns(:collection).count).to eq(1) end end context "when search string given" do it "searches by given string" do - get :index, search: "great" + get :index, params: {search: "great"} expect(assigns(:collection).count).to eq(1) end end @@ -407,14 +407,14 @@ class FooFormBuilder; end end it "assigns the requested record to @resource" do - get :edit, id: @resource + get :edit, params: {id: @resource} expect(assigns(:resource)).to eq(@resource) end it "assigns breadcrumb for resource" do allow(Releaf::ResourceBase).to receive(:title).with(@resource).and_return("xxx") - get :edit, id: @resource + get :edit, params: {id: @resource} breadcrumbs = @breadcrumbs_base + [{name: "xxx", url: edit_admin_book_path(@resource.id)}] expect(assigns(:breadcrumbs)).to eq(breadcrumbs) diff --git a/releaf-core/spec/controllers/releaf/root_controller_spec.rb b/releaf-core/spec/controllers/releaf/root_controller_spec.rb index 975a30a7e..b1ad8c140 100644 --- a/releaf-core/spec/controllers/releaf/root_controller_spec.rb +++ b/releaf-core/spec/controllers/releaf/root_controller_spec.rb @@ -30,15 +30,16 @@ context 'when params[:settings] is Hash' do it "has a 200 status code" do allow(Releaf.application.config.settings_manager).to receive(:write) - post :store_settings, settings: {dummy: 'maybe'} + post :store_settings, params: {settings: [{key: "dummy", value: "maybe"}]} expect(response.status).to eq(200) end it "saves given data within current user settings, casting true/false strings to boolean" do + params = {settings: [{key: "dummy", value: "maybe"}, {key: "be_true", value: true}, {key: "be_false", value: false}]} expect(Releaf.application.config.settings_manager).to receive(:write).with(controller: subject, key: "dummy", value: "maybe") expect(Releaf.application.config.settings_manager).to receive(:write).with(controller: subject, key: "be_true", value: true) expect(Releaf.application.config.settings_manager).to receive(:write).with(controller: subject, key: "be_false", value: false) - post :store_settings, settings: {dummy: "maybe", be_true: 'true', be_false: 'false'} + post :store_settings, params: params end end end diff --git a/releaf-core/spec/controllers/releaf/settings_controller_spec.rb b/releaf-core/spec/controllers/releaf/settings_controller_spec.rb index 25139b6a9..55c68d433 100644 --- a/releaf-core/spec/controllers/releaf/settings_controller_spec.rb +++ b/releaf-core/spec/controllers/releaf/settings_controller_spec.rb @@ -12,7 +12,7 @@ Releaf::Settings.create(var: "a", value: "1") Releaf::Settings.create(var: "b", value: "2") Releaf::Settings.create(var: "c", value: "2") - Releaf::Settings.create(var: "a", value: "3", thing_type: "User", thing_id: "1") + Releaf::Settings.create(var: "a", value: "3", thing_type: "Releaf::Permissions::User", thing_id: "1") Releaf::Settings.register(key: "a", default: "x", description: "some setting") Releaf::Settings.register(key: "b", default: "xxxx", description: "some other setting") @@ -32,7 +32,7 @@ allow(Releaf::Settings::NormalizeValue).to receive(:call). with(value: "1", input_type: :boolean).and_return(88) - patch :update, {id: Releaf::Settings.first.id, resource: {value: "1"}} + patch :update, params: {id: Releaf::Settings.first.id, resource: {value: "1"}} expect(Releaf::Settings.first.value).to eq(88) end end diff --git a/releaf-core/spec/error_hash_builder_spec.rb b/releaf-core/spec/error_hash_builder_spec.rb index c8deaf090..e85c3e2b3 100644 --- a/releaf-core/spec/error_hash_builder_spec.rb +++ b/releaf-core/spec/error_hash_builder_spec.rb @@ -7,7 +7,7 @@ class DummyResourceValidatorAuthor < Author class DummyResourceValidatorBook < Book self.table_name = 'books' - belongs_to :author, inverse_of: :books, class_name: :DummyResourceValidatorAuthor + belongs_to :author, inverse_of: :books, class_name: :DummyResourceValidatorAuthor, required: false validates_presence_of :author accepts_nested_attributes_for :author diff --git a/releaf-core/spec/features/ajaxbox_spec.rb b/releaf-core/spec/features/ajaxbox_spec.rb index abab248d6..963675587 100644 --- a/releaf-core/spec/features/ajaxbox_spec.rb +++ b/releaf-core/spec/features/ajaxbox_spec.rb @@ -71,7 +71,7 @@ open_toolbox_dialog "Add child" expect(page).to have_css(".mfp-bg") - page.driver.click(10, 10) + find("body").click expect(page).to_not have_css(".mfp-bg") end @@ -83,7 +83,7 @@ open_toolbox_dialog "Delete" expect(page).to have_css(".mfp-bg") - page.driver.click(10, 10) + find("body").click expect(page).to have_css(".mfp-bg") expect(find(".mfp-bg")).to be_visible end @@ -95,7 +95,7 @@ find(".field[data-name='cover_image'] .value-preview img").click expect(page).to have_css(".mfp-bg") - page.driver.click(10, 10) + execute_script("document.querySelector('.mfp-bg').click();") expect(page).to_not have_css(".mfp-bg") find(".field[data-name='cover_image'] .value-preview img").click diff --git a/releaf-core/spec/features/breadcrumbs_spec.rb b/releaf-core/spec/features/breadcrumbs_spec.rb index f2b331386..c0ecd32ec 100644 --- a/releaf-core/spec/features/breadcrumbs_spec.rb +++ b/releaf-core/spec/features/breadcrumbs_spec.rb @@ -1,11 +1,11 @@ require 'rails_helper' -feature "Breadcrumbs", js: true do +feature "Breadcrumbs" do background do auth_as_user end scenario "Open show view with link to resource show in breadcrumbs" do - banner = Banner.create(url: "https://google.com") + banner = Banner.create!(url: "https://google.com") visit admin_banner_path(banner) within ".breadcrumbs" do diff --git a/releaf-core/spec/features/edit_actions_spec.rb b/releaf-core/spec/features/edit_actions_spec.rb index 3e4c8c253..02cccb778 100644 --- a/releaf-core/spec/features/edit_actions_spec.rb +++ b/releaf-core/spec/features/edit_actions_spec.rb @@ -2,9 +2,9 @@ feature "Base controller edit", js: true do background do auth_as_user - @author = FactoryGirl.create(:author) - @good_book = FactoryGirl.create(:book, title: "good book", author: @author, price: 12.34, description_lv: "in lv", description_en: "in en") - FactoryGirl.create(:book, title: "bad book", author: @author) + @author = FactoryBot.create(:author) + @good_book = FactoryBot.create(:book, title: "good book", author: @author, price: 12.34, description_lv: "in lv", description_en: "in en") + FactoryBot.create(:book, title: "bad book", author: @author) end scenario "creation of new resources" do @@ -33,7 +33,7 @@ visit new_admin_book_path wait_for_all_richtexts fill_in "Title", with: "Another ipsum" - find('#resource_title').native.send_key(:Enter) + find('#resource_title').native.send_key(:enter) expect(page).to have_css('body > .notifications .notification[data-id="resource_status"][data-type="success"]', text: "Create succeeded") expect(page).to have_css('header h1', text: 'Create new resource') diff --git a/releaf-core/spec/features/index_actions_spec.rb b/releaf-core/spec/features/index_actions_spec.rb index 67753b516..9977e79ab 100644 --- a/releaf-core/spec/features/index_actions_spec.rb +++ b/releaf-core/spec/features/index_actions_spec.rb @@ -2,10 +2,10 @@ feature "Base controller index", js: true do background do auth_as_user - author = FactoryGirl.create(:author) - good_book = FactoryGirl.create(:book, title: "good book", author: author, published_at: Date.parse("2015-12-12")) - FactoryGirl.create(:chapter, title: 'Scary night', text: 'Once upon a time...', book: good_book) - FactoryGirl.create(:book, title: "bad book", author: author) + author = create(:author) + good_book = create(:book, title: "good book", author: author, published_at: Date.parse("2015-12-12")) + create(:chapter, title: 'Scary night', text: 'Once upon a time...', book: good_book) + create(:book, title: "bad book", author: author) end scenario "shows resource count" do @@ -46,6 +46,7 @@ visit admin_books_path expect(page).to have_link("good book") + allow_any_instance_of(Admin::BooksController).to receive(:feature_available?).and_call_original allow_any_instance_of(Admin::BooksController).to receive(:feature_available?).with(:edit).and_return(false) visit admin_books_path expect(page).to_not have_link("good book") diff --git a/releaf-core/spec/features/richtext_spec.rb b/releaf-core/spec/features/richtext_spec.rb index fc900a91e..91b9f9636 100644 --- a/releaf-core/spec/features/richtext_spec.rb +++ b/releaf-core/spec/features/richtext_spec.rb @@ -21,7 +21,7 @@ scenario "Test helper fills in correct value" do visit new_admin_node_path(content_type: 'TextPage') - html = %Q[

"HTML" 'content'

] + html = %Q[

"HTML" 'content'

] wait_for_all_richtexts fill_in_richtext 'Text', with: html content = evaluate_script('CKEDITOR.instances["resource_content_attributes_text_html"].getData();') diff --git a/releaf-core/spec/features/search_spec.rb b/releaf-core/spec/features/search_spec.rb index e72c24199..d7c950086 100644 --- a/releaf-core/spec/features/search_spec.rb +++ b/releaf-core/spec/features/search_spec.rb @@ -456,7 +456,7 @@ end model do - belongs_to :post + belongs_to :post, required: false end end @@ -505,8 +505,8 @@ end model do - belongs_to :writer, class_name: :Writer - belongs_to :editor, class_name: :Writer + belongs_to :writer, class_name: :Writer, required: false + belongs_to :editor, class_name: :Writer, required: false end end @@ -556,7 +556,7 @@ end model do - belongs_to :writer + belongs_to :writer, required: false end end @@ -656,7 +656,7 @@ end model do - belongs_to :writer + belongs_to :writer, required: false end end diff --git a/releaf-core/spec/features/settings_spec.rb b/releaf-core/spec/features/settings_spec.rb index 60c0fef0e..c82f29e84 100644 --- a/releaf-core/spec/features/settings_spec.rb +++ b/releaf-core/spec/features/settings_spec.rb @@ -29,7 +29,7 @@ end click_link "Back to list" - expect(page).to have_content("2014-04-01 12:33:59") + expect(page).to have_content("12:33") expect(Releaf::Settings["content.updated_at"]).to eq(Time.parse("2014-04-01 12:33:59")) click_link "content.updated" @@ -54,7 +54,7 @@ click_link "Back to list" expect(Releaf::Settings["content.textarea"]).to eq("AA\r\nBB\r\nCC\r\nDD\r\n") - expect(page).to have_content("AA\nBB\nCC\nDD\n") + expect(page).to have_content("AA BB CC DD") click_link "content.richtext" wait_for_all_richtexts @@ -65,6 +65,6 @@ click_link "Back to list" expect(Releaf::Settings["content.richtext"]).to eq("

EE
\r\nFF

\r\n\r\n

GG HH

\r\n") - expect(page).to have_content("EE\nFF\nGG\nHH\n") + expect(page).to have_content("EE FF GG HH") end end diff --git a/releaf-core/spec/lib/releaf/responders_spec.rb b/releaf-core/spec/lib/releaf/responders_spec.rb index cff3fedd7..6df23f8fe 100644 --- a/releaf-core/spec/lib/releaf/responders_spec.rb +++ b/releaf-core/spec/lib/releaf/responders_spec.rb @@ -8,6 +8,7 @@ allow(subject).to receive(:active_responder).and_return(Releaf::Responders::AfterSaveResponder) allow(subject).to receive(:request).and_return(request) allow(subject).to receive(:content_type).and_return(:html) + allow(subject).to receive(:action_name).and_return(:save) end context "when no responder defined within options" do diff --git a/releaf-core/spec/lib/validation_error_codes_spec.rb b/releaf-core/spec/lib/validation_error_codes_spec.rb index 02053e919..b40dd8911 100644 --- a/releaf-core/spec/lib/validation_error_codes_spec.rb +++ b/releaf-core/spec/lib/validation_error_codes_spec.rb @@ -15,29 +15,29 @@ class DummyModel end it "adds ActiveModel::ErrorMessage as error instead of String" do - expect(item.errors.get(:name).first.class).to eq(ActiveModel::ErrorMessage) + expect(item.errors[:name].first.class).to eq(ActiveModel::ErrorMessage) end it "does not owerwrite default error message behaviour" do - expect(item.errors.get(:name).first).to eq("can't be blank") + expect(item.errors[:name].first).to eq("can't be blank") end context "when validation have :error_code option" do it "adds :error_code value as error_code" do - expect(item.errors.get(:name).first.error_code).to eq(:no_name) + expect(item.errors[:name].first.error_code).to eq(:no_name) end end context "when validation message is symbol" do it "adds message as error_code" do - expect(item.errors.get(:surname).first.error_code).to eq(:blank) + expect(item.errors[:surname].first.error_code).to eq(:blank) end end context "when validation message is not symbol and don't have :error_code option" do it "adds :invalid as error_code" do - item.errors.add(:age, Proc.new {"no age"}) - expect(item.errors.get(:age).first.error_code).to eq(:invalid) + item.errors.add(:age, "no age") + expect(item.errors[:age].first.error_code).to eq(:invalid) end end @@ -50,7 +50,7 @@ class DummyModel context "when error with :data option is added" do it "stores data" do item.errors.add(:age, :invalid, data: {foo: :bar}) - expect( item.errors.get(:age).first.data ).to eq(foo: :bar) + expect( item.errors[:age].first.data ).to eq(foo: :bar) end end end diff --git a/releaf-core/spec/misc/factories_spec.rb b/releaf-core/spec/misc/factories_spec.rb index 985a2433c..c9d2ebc20 100644 --- a/releaf-core/spec/misc/factories_spec.rb +++ b/releaf-core/spec/misc/factories_spec.rb @@ -1,6 +1,6 @@ require "rails_helper" -describe "FactoryGirl factories" do +describe "FactoryBot factories" do describe "admin factory" do it "creates new user" do diff --git a/releaf-core/spec/models/settings_spec.rb b/releaf-core/spec/models/settings_spec.rb index 956449b37..9d2a688de 100644 --- a/releaf-core/spec/models/settings_spec.rb +++ b/releaf-core/spec/models/settings_spec.rb @@ -4,19 +4,23 @@ describe ":registered scope" do it "returns only registed settings ordered by `var`" do - registered = described_class.where(var: "x") - allow(described_class).to receive(:registered_keys).and_return([:a, :b]) - allow(described_class).to receive(:where).with(var: [:a, :b]).and_return(registered) - allow(registered).to receive(:order).with(:var).and_return(:c) - expect(described_class.registered).to eq(:c) + item_1 = Releaf::Settings.create(var: "a", value: "1") + item_2 = Releaf::Settings.create(var: "b", value: "2") + Releaf::Settings.create(var: "c", value: "2") + Releaf::Settings.create(var: "a", value: "3", thing_type: "Releaf::Permissions::User", thing_id: "1") + + Releaf::Settings.register(key: "a", default: "x", description: "some setting") + Releaf::Settings.register(key: "b", default: "xxxx", description: "some other setting") + + expect(described_class.registered).to eq [item_1, item_2] end it "returns valid query" do - expect(described_class.registered.count).to be_instance_of(Fixnum) + expect(described_class.registered.count).to be_instance_of(Integer) end it "returns instance of `Releaf::Settings::ActiveRecord_Relation`" do - expect(described_class.registered).to be_instance_of(Releaf::Settings::ActiveRecord_Relation) + expect(described_class.registered).to be_instance_of(Releaf::Settings.const_get(:ActiveRecord_Relation)) end end @@ -78,7 +82,7 @@ end it "returns instance of `Releaf::Settings::ActiveRecord_Relation`" do - expect(described_class.register_scoped).to be_instance_of(Releaf::Settings::ActiveRecord_Relation) + expect(described_class.register_scoped).to be_instance_of(Releaf::Settings.const_get(:ActiveRecord_Relation)) end end diff --git a/releaf-i18n_database/app/lib/releaf/i18n_database/parse_spreadsheet_translations.rb b/releaf-i18n_database/app/lib/releaf/i18n_database/parse_spreadsheet_translations.rb index 2df76438a..dd7d70567 100644 --- a/releaf-i18n_database/app/lib/releaf/i18n_database/parse_spreadsheet_translations.rb +++ b/releaf-i18n_database/app/lib/releaf/i18n_database/parse_spreadsheet_translations.rb @@ -34,8 +34,8 @@ def spreadsheet end def file_format_error?(error_class_name, error_message) - return true if ['Zip::ZipError','Ole::Storage::FormatError' ].include?(error_class_name) - error_class_name == 'ArgumentError' && error_message.match("Don't know how to open file").present? + return true if ['Zip::Error','Ole::Storage::FormatError' ].include?(error_class_name) + error_class_name == 'ArgumentError' && error_message.match("Can't detect the type").present? end def translations diff --git a/releaf-i18n_database/app/lib/releaf/i18n_database/translations_store.rb b/releaf-i18n_database/app/lib/releaf/i18n_database/translations_store.rb index d6f02e1b2..c990c5940 100644 --- a/releaf-i18n_database/app/lib/releaf/i18n_database/translations_store.rb +++ b/releaf-i18n_database/app/lib/releaf/i18n_database/translations_store.rb @@ -68,7 +68,7 @@ def localization_data Releaf::I18nDatabase::I18nEntryTranslation .joins(:i18n_entry) .where.not(text: '') - .pluck("CONCAT(locale, '.', releaf_i18n_entries.key) AS translation_key", "text") + .pluck(Arel.sql("CONCAT(locale, '.', releaf_i18n_entries.key) AS translation_key"), "text") .to_h end diff --git a/releaf-i18n_database/app/lib/releaf/i18n_database/translations_utilities.rb b/releaf-i18n_database/app/lib/releaf/i18n_database/translations_utilities.rb index 8f953735c..6dbba4ba0 100644 --- a/releaf-i18n_database/app/lib/releaf/i18n_database/translations_utilities.rb +++ b/releaf-i18n_database/app/lib/releaf/i18n_database/translations_utilities.rb @@ -13,7 +13,7 @@ def self.filter_only_blank_translations(collection) blank_where_collection = blank_where_collection.where(column.eq('').or(column.eq(nil))) end - collection.where(blank_where_collection.where_values.reduce(:or)) + collection.where(blank_where_collection.where_clause.send(:predicates).reduce(:or)) end def self.filter_by_text(collection, lookup_string) diff --git a/releaf-i18n_database/app/views/releaf/i18n_database/translations/_form_fields.haml b/releaf-i18n_database/app/views/releaf/i18n_database/translations/_form_fields.haml index 652592d41..9854ef815 100644 --- a/releaf-i18n_database/app/views/releaf/i18n_database/translations/_form_fields.haml +++ b/releaf-i18n_database/app/views/releaf/i18n_database/translations/_form_fields.haml @@ -14,7 +14,7 @@ %input{type: "text", class: "text", name: "translations[][localizations][#{locale}]"} %td.delete-column.only-icon = releaf_button(nil, "times", class: %w(danger remove-nested-item), title: t("Remove", scope: controller_scope_name)) -%section.nested{data: {name: "translations", releaf: {template: html_escape(template_html)}}} +%section.nested{data: {name: "translations", releaf: {template: template_html.to_str}}} %table.table %thead %tr diff --git a/releaf-i18n_database/lib/releaf-i18n_database.rb b/releaf-i18n_database/lib/releaf-i18n_database.rb index a2fa863a4..2cadfc0a0 100644 --- a/releaf-i18n_database/lib/releaf-i18n_database.rb +++ b/releaf-i18n_database/lib/releaf-i18n_database.rb @@ -1,4 +1,4 @@ -require 'axlsx_rails' +require 'caxlsx_rails' require 'i18n' require 'rails-i18n' require 'roo' diff --git a/releaf-i18n_database/releaf-i18n_database.gemspec b/releaf-i18n_database/releaf-i18n_database.gemspec index 7e62a52ab..8488431ed 100644 --- a/releaf-i18n_database/releaf-i18n_database.gemspec +++ b/releaf-i18n_database/releaf-i18n_database.gemspec @@ -15,7 +15,7 @@ Gem::Specification.new do |s| s.test_files = Dir["spec/**/*"] s.add_dependency 'releaf-core', Releaf::VERSION - s.add_dependency 'rails-i18n', '~> 4.0.0' - s.add_dependency 'axlsx_rails', '~> 0.3', '>= 0.3.0' + s.add_dependency 'rails-i18n' + s.add_dependency 'caxlsx_rails', '~> 0.6' s.add_dependency 'roo' end diff --git a/releaf-i18n_database/spec/controllers/i18n_backend/translations_controller_spec.rb b/releaf-i18n_database/spec/controllers/i18n_backend/translations_controller_spec.rb index c2a87eca2..307feb5b1 100644 --- a/releaf-i18n_database/spec/controllers/i18n_backend/translations_controller_spec.rb +++ b/releaf-i18n_database/spec/controllers/i18n_backend/translations_controller_spec.rb @@ -34,19 +34,19 @@ def file_attachment context "when searching" do it "searches by translation key" do - get :index, search: 'great' + get :index, params: {search: 'great'} expect( assigns(:collection).size ).to eq(1) end it "searched by localized values" do - get :index, search: 'manta' + get :index, params: {search: 'manta'} expect( assigns(:collection).size ).to eq(1) end end context "when searching blank translations" do it "returns translations that has blank translation in any localization" do - get :index, only_blank: 'true' + get :index, params: {only_blank: 'true'} expect( assigns(:collection).map(&:id) ).to match_array [@t1.id] end end @@ -62,7 +62,7 @@ def file_attachment context "when search scope is given" do it "renders translations matching search pattern" do - get :index, search: 'stuff' + get :index, params: {search: 'stuff'} expect( assigns(:collection).size ).to eq(2) end end @@ -72,12 +72,12 @@ def file_attachment context "when save successful" do it "updates translations updated_at" do expect(Releaf::I18nDatabase::Backend).to receive("translations_updated_at=").with(@time_now) - put :update, translations: [{key: 'a.b.c', localizations: {en: 'test', lv: 'xxl'}}] + put :update, params: {translations: [{key: 'a.b.c', localizations: {en: 'test', lv: 'xxl'}}]} end context "when save with import" do before do - put :update, translations: [{key: 'a.b.c', localizations: {en: 'test', lv: 'xxl'}}], import: "true" + put :update, params: {translations: [{key: 'a.b.c', localizations: {en: 'test', lv: 'xxl'}}], import: "true"} end it "redirects to index view" do @@ -91,7 +91,7 @@ def file_attachment context "when save without import" do before do - put :update, translations: [{key: 'a.b.c', localizations: {en: 'test', lv: 'xxl'}}] + put :update, params: {translations: [{key: 'a.b.c', localizations: {en: 'test', lv: 'xxl'}}]} end it "redirects to edit view" do @@ -106,12 +106,12 @@ def file_attachment context "when save failed" do it "renders edit view" do - put :update, translations: [{key: '', localizations: {en: 'test', lv: 'xxl'}}] + put :update, params: {translations: [{key: '', localizations: {en: 'test', lv: 'xxl'}}]} expect(response).to render_template(:edit) end it "flash error notification" do - put :update, translations: [{key: '', localizations: {en: 'test', lv: 'xxl'}}] + put :update, params: {translations: [{key: '', localizations: {en: 'test', lv: 'xxl'}}]} expect(flash["error"]).to eq("id" => "resource_status", "message" => "Update failed") end end @@ -122,7 +122,7 @@ def file_attachment before do file = fixture_file_upload(File.expand_path('../../fixtures/translations_import.xlsx', __dir__), 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet') - post :import, import_file: file + post :import, params: {import_file: file} end it "parses uploaded file and assigns content to collection" do diff --git a/releaf-i18n_database/spec/features/translations_spec.rb b/releaf-i18n_database/spec/features/translations_spec.rb index 142095d22..e6a9cfd64 100644 --- a/releaf-i18n_database/spec/features/translations_spec.rb +++ b/releaf-i18n_database/spec/features/translations_spec.rb @@ -357,7 +357,7 @@ context "when positive create_plurals option passed" do it "creates pluralized translations for all Releaf locales" do - result = ["animals.horse.few", "animals.horse.many", "animals.horse.one", "animals.horse.other", "animals.horse.zero"] + result = ["animals.horse.one", "animals.horse.other", "animals.horse.zero"] expect{ I18n.t("animals.horse", count: 1, create_plurals: true) }.to change{ Releaf::I18nDatabase::I18nEntry.pluck(:key).sort }. from([]).to(result.sort) end diff --git a/releaf-i18n_database/spec/lib/releaf/i18n_database/parse_spreadsheet_translations_spec.rb b/releaf-i18n_database/spec/lib/releaf/i18n_database/parse_spreadsheet_translations_spec.rb index 44f63c389..73e470aa0 100644 --- a/releaf-i18n_database/spec/lib/releaf/i18n_database/parse_spreadsheet_translations_spec.rb +++ b/releaf-i18n_database/spec/lib/releaf/i18n_database/parse_spreadsheet_translations_spec.rb @@ -3,7 +3,6 @@ describe Releaf::I18nDatabase::ParseSpreadsheetTranslations do let(:translation){ Releaf::I18nDatabase::I18nEntry.new } let(:fixture_path){ File.expand_path('../../../fixtures/translations_import.xlsx', __dir__) } - let(:error_message){ "Don't know how to open file #{fixture_path}" } subject{ described_class.new(file_path: fixture_path, extension: "xlsx") } describe "#call" do @@ -82,9 +81,9 @@ describe "#file_format_error?" do context "when given error is an ArgumentError" do - context "when the message contains 'Don't know how to open file'" do + context "when the message contains 'Can't detect the type'" do it "returns true" do - expect(subject.file_format_error?("ArgumentError", error_message)).to be true + expect(subject.file_format_error?("ArgumentError", "Can't detect the type")).to be true end end context "when the message is different" do @@ -94,9 +93,9 @@ end end - context "when the error is a Zip::ZipError" do + context "when the error is a Zip::Error" do it "returns true" do - expect(subject.file_format_error?("Zip::ZipError", "error message")).to be true + expect(subject.file_format_error?("Zip::Error", "error message")).to be true end end diff --git a/releaf-i18n_database/spec/models/i18n_database/i18n_entry_spec.rb b/releaf-i18n_database/spec/models/i18n_database/i18n_entry_spec.rb index d0a33479e..6f8f635cd 100644 --- a/releaf-i18n_database/spec/models/i18n_database/i18n_entry_spec.rb +++ b/releaf-i18n_database/spec/models/i18n_database/i18n_entry_spec.rb @@ -3,7 +3,7 @@ describe Releaf::I18nDatabase::I18nEntry do it { is_expected.to validate_presence_of(:key) } it { is_expected.to validate_length_of(:key).is_at_most(255) } - it { is_expected.to validate_uniqueness_of(:key) } + it { subject.key = "a"; is_expected.to validate_uniqueness_of(:key) } it { is_expected.to have_many(:i18n_entry_translation).dependent(:destroy) } it { is_expected.to accept_nested_attributes_for(:i18n_entry_translation).allow_destroy(true) } diff --git a/releaf-i18n_database/spec/models/i18n_database/i18n_entry_translation_spec.rb b/releaf-i18n_database/spec/models/i18n_database/i18n_entry_translation_spec.rb index bd94d1afb..0fcb662b0 100644 --- a/releaf-i18n_database/spec/models/i18n_database/i18n_entry_translation_spec.rb +++ b/releaf-i18n_database/spec/models/i18n_database/i18n_entry_translation_spec.rb @@ -4,6 +4,6 @@ it { is_expected.to validate_presence_of(:i18n_entry) } it { is_expected.to validate_presence_of(:locale) } it { is_expected.to validate_length_of(:locale).is_at_most(5) } - it { subject.locale = "de"; is_expected.to validate_uniqueness_of(:i18n_entry_id).scoped_to([:locale]) } + it { subject.locale = "de"; subject.i18n_entry_id = 1; is_expected.to validate_uniqueness_of(:i18n_entry_id).scoped_to([:locale]) } it { is_expected.to belong_to(:i18n_entry) } end diff --git a/releaf-permissions/spec/builders/releaf/permissions/page/header_builder_spec.rb b/releaf-permissions/spec/builders/releaf/permissions/page/header_builder_spec.rb index 91371d373..41c60412e 100644 --- a/releaf-permissions/spec/builders/releaf/permissions/page/header_builder_spec.rb +++ b/releaf-permissions/spec/builders/releaf/permissions/page/header_builder_spec.rb @@ -9,7 +9,7 @@ def protect_against_forgery? true end - def form_authenticity_token + def form_authenticity_token(_) "xxx" end diff --git a/releaf-permissions/spec/controllers/permissions/profile_controller_spec.rb b/releaf-permissions/spec/controllers/permissions/profile_controller_spec.rb index 6663dd3cb..103ed94a5 100644 --- a/releaf-permissions/spec/controllers/permissions/profile_controller_spec.rb +++ b/releaf-permissions/spec/controllers/permissions/profile_controller_spec.rb @@ -1,7 +1,7 @@ require 'rails_helper' describe Releaf::Permissions::ProfileController do - let(:another_role){ FactoryGirl.create(:content_role) } + let(:another_role){ FactoryBot.create(:content_role) } let(:user){ subject.current_releaf_permissions_user } login_as_user :user @@ -14,25 +14,26 @@ describe "PATCH update" do context 'when attributes contain role_id' do it "does not update it" do - expect{ patch :update, {resource: {role_id: another_role.id}} }.to_not change{ user.role_id } + expect{ patch :update, params: {resource: {role_id: another_role.id}} }.to_not change{ user.role_id } end end context 'with allowed attributes' do it "saves new attributes" do - attributes = { + attributes = ActionController::Parameters.new({ "name" => "new name", "surname" => "new surname", "email" => "new.email@example.com", "locale" => "lv" - } + }) + attributes.permit! # This is needed in order to get same instance as we expect. # Otherwise we'll get same record, but different instance and test will fail allow( user ).to receive(:becomes).with(Releaf::Permissions::User).and_return(user) expect(user).to receive(:update_attributes).with(attributes) - patch :update, {resource: attributes} + patch :update, params: {resource: attributes} end end end diff --git a/releaf-permissions/spec/controllers/permissions/users_controller_spec.rb b/releaf-permissions/spec/controllers/permissions/users_controller_spec.rb index a485fc08e..b9cd9f81e 100644 --- a/releaf-permissions/spec/controllers/permissions/users_controller_spec.rb +++ b/releaf-permissions/spec/controllers/permissions/users_controller_spec.rb @@ -4,7 +4,7 @@ # have no extra methods or overrides describe Releaf::Permissions::UsersController do before do - sign_in FactoryGirl.create(:user) + sign_in FactoryBot.create(:user) end describe "GET #new" do @@ -16,12 +16,12 @@ describe "GET #index" do before do - FactoryGirl.create(:content_user, name: "John") - FactoryGirl.create(:content_user, name: "Bill", surname: "Green", email: "another@example.com") + FactoryBot.create(:content_user, name: "John") + FactoryBot.create(:content_user, name: "Bill", surname: "Green", email: "another@example.com") end it "searches by name, surname and email" do - get :index, search: "bill green another@example" + get :index, params: {search: "bill green another@example"} expect(assigns(:collection).count).to eq(1) end end diff --git a/releaf-permissions/spec/features/profile_updating_spec.rb b/releaf-permissions/spec/features/profile_updating_spec.rb index e274e3ab6..22454c1f0 100644 --- a/releaf-permissions/spec/features/profile_updating_spec.rb +++ b/releaf-permissions/spec/features/profile_updating_spec.rb @@ -1,7 +1,7 @@ require 'rails_helper' feature "User profile" do background do - auth_as_user(false, FactoryGirl.create(:user, email: "email@example.com")) + auth_as_user(false, FactoryBot.create(:user, email: "email@example.com")) visit releaf_permissions_user_profile_path end diff --git a/releaf-permissions/spec/models/permissions/role_spec.rb b/releaf-permissions/spec/models/permissions/role_spec.rb index 11bb7bf6d..9b16fd9a6 100644 --- a/releaf-permissions/spec/models/permissions/role_spec.rb +++ b/releaf-permissions/spec/models/permissions/role_spec.rb @@ -4,7 +4,7 @@ describe 'validations' do it { is_expected.to validate_presence_of(:name) } it { is_expected.to validate_presence_of(:default_controller) } - it { is_expected.to validate_uniqueness_of(:name).case_insensitive } + it { subject.name = "x"; is_expected.to validate_uniqueness_of(:name).case_insensitive } end describe 'associations' do diff --git a/releaf.gemspec b/releaf.gemspec index 95d2a6718..4f0c3e9d9 100644 --- a/releaf.gemspec +++ b/releaf.gemspec @@ -20,22 +20,24 @@ Gem::Specification.new do |s| s.add_dependency gem, Releaf::VERSION end - s.add_development_dependency 'rspec-rails' - s.add_development_dependency 'capybara' - s.add_development_dependency 'poltergeist' - s.add_development_dependency 'factory_girl_rails', '4.8.0' + s.add_development_dependency 'rspec-rails', '~> 4.0' + s.add_development_dependency 'rails-controller-testing' + s.add_development_dependency 'listen', '~> 3.2.1' + s.add_development_dependency 'capybara', '~> 3.32' + s.add_development_dependency 'selenium-webdriver', '~> 3.142' + s.add_development_dependency 'factory_bot', '~> 5.2' s.add_development_dependency 'syntax' - s.add_development_dependency 'simplecov' + s.add_development_dependency 'simplecov', '~> 0.16.1' s.add_development_dependency 'simplecov-rcov' - s.add_development_dependency 'database_cleaner' - s.add_development_dependency 'shoulda-matchers', '~> 2.8' + s.add_development_dependency 'database_cleaner', '~> 1.8' + s.add_development_dependency 'shoulda-matchers', '~> 4.3' s.add_development_dependency 'db-query-matchers' - s.add_development_dependency 'coveralls' + s.add_development_dependency 'coveralls', '~> 0.8' s.add_development_dependency 'timecop' - s.add_development_dependency 'with_model', '1.2.2' + s.add_development_dependency 'with_model', '~> 2.1' s.add_development_dependency 'pry' - s.add_development_dependency 'pry-nav' s.add_development_dependency 'roo' + s.add_development_dependency 'puma', '~> 4.3' - s.required_ruby_version = '>= 2.2.0' + s.required_ruby_version = '>= 2.5.0' end diff --git a/spec/factories/author.rb b/spec/factories/author.rb index 7bb1ef614..0f214aff3 100644 --- a/spec/factories/author.rb +++ b/spec/factories/author.rb @@ -1,6 +1,6 @@ -FactoryGirl.define do +FactoryBot.define do factory :author do - name "Aleksandrs" - surname "Lielais" + name { "Aleksandrs" } + surname { "Lielais" } end end diff --git a/spec/factories/banner_page.rb b/spec/factories/banner_page.rb index 277f9f070..3b6d1b24d 100644 --- a/spec/factories/banner_page.rb +++ b/spec/factories/banner_page.rb @@ -1,4 +1,4 @@ -FactoryGirl.define do +FactoryBot.define do factory :banner_page do end diff --git a/spec/factories/book.rb b/spec/factories/book.rb index e44d86c52..ab06bec9e 100644 --- a/spec/factories/book.rb +++ b/spec/factories/book.rb @@ -1,5 +1,5 @@ -FactoryGirl.define do +FactoryBot.define do factory :book do - title "some book" + title { "some book" } end end diff --git a/spec/factories/chapter.rb b/spec/factories/chapter.rb index 9342014ff..942c24895 100644 --- a/spec/factories/chapter.rb +++ b/spec/factories/chapter.rb @@ -1,7 +1,7 @@ -FactoryGirl.define do +FactoryBot.define do factory :chapter do sequence(:title) { |n| "Chapter #{n}" } - text 'Some awesome text for great test' - sample_html 'heavy words' + text { 'Some awesome text for great test' } + sample_html { 'heavy words' } end end diff --git a/spec/factories/common.rb b/spec/factories/common.rb index fd836eb48..06974f112 100644 --- a/spec/factories/common.rb +++ b/spec/factories/common.rb @@ -1,4 +1,4 @@ -FactoryGirl.define do +FactoryBot.define do sequence(:name) {|n| "name-#{n}" } sequence(:surname) {|n| "surname-#{n}" } sequence(:email) {|n| "email-#{n}@example.com" } diff --git a/spec/factories/home_page.rb b/spec/factories/home_page.rb index d562c9afd..dfca13bf8 100644 --- a/spec/factories/home_page.rb +++ b/spec/factories/home_page.rb @@ -1,5 +1,5 @@ -FactoryGirl.define do +FactoryBot.define do factory :home_page do - text_html "xx duper" + text_html { "xx duper" } end end diff --git a/spec/factories/node.rb b/spec/factories/node.rb index e1d6ca9d3..8b40f9b99 100644 --- a/spec/factories/node.rb +++ b/spec/factories/node.rb @@ -1,49 +1,49 @@ -FactoryGirl.define do +FactoryBot.define do factory :node, class: ::Node do sequence(:name) {|n| "node #{n}"} sequence(:slug) {|n| "node-#{n}"} - content_type "HomePage" + content_type { "HomePage" } end factory :other_node, class: ::OtherSite::OtherNode do sequence(:name) {|n| "node #{n}"} sequence(:slug) {|n| "node-#{n}"} - content_type "HomePage" + content_type { "HomePage" } end factory :home_page_node, class: ::Node do sequence(:name) {|n| "node #{n}"} sequence(:slug) {|n| "node-#{n}"} - content_type "HomePage" - content_attributes ({ intro_text_html: "some STRRRONG text" }) + content_type { "HomePage" } + content_attributes {{ intro_text_html: "some STRRRONG text" }} end factory :other_home_page_node, class: ::OtherSite::OtherNode do sequence(:name) {|n| "node #{n}"} sequence(:slug) {|n| "node-#{n}"} - content_type "HomePage" - content_attributes ({ intro_text_html: "some STRRRONG text" }) + content_type { "HomePage" } + content_attributes {{ intro_text_html: "some STRRRONG text" }} end factory :text_page_node, class: ::Node do sequence(:name) {|n| "node #{n}"} sequence(:slug) {|n| "node-#{n}"} - content_type "TextPage" - content_attributes ({ text_html: "some STRIONG text" }) + content_type { "TextPage" } + content_attributes {{ text_html: "some STRIONG text" }} end factory :other_text_page_node, class: ::OtherSite::OtherNode do sequence(:name) {|n| "node #{n}"} sequence(:slug) {|n| "node-#{n}"} - content_type "TextPage" - content_attributes ({ text_html: "some STRIONG text" }) + content_type { "TextPage" } + content_attributes {{ text_html: "some STRIONG text" }} end factory :banner_page_node, class: ::Node do sequence(:name) {|n| "node #{n}"} sequence(:slug) {|n| "node-#{n}"} - content_type "BannerPage" - content_attributes ({}) + content_type { "BannerPage" } + content_attributes {{}} end diff --git a/spec/factories/node_route.rb b/spec/factories/node_route.rb index 53602b158..bba3b9dfb 100644 --- a/spec/factories/node_route.rb +++ b/spec/factories/node_route.rb @@ -1,7 +1,7 @@ -FactoryGirl.define do +FactoryBot.define do factory :node_route, class: ::Releaf::Content::Route do sequence(:node_id) {|n| n} sequence(:path) {|n| "path-#{n}"} - locale "en" + locale { "en" } end end diff --git a/spec/factories/publisher.rb b/spec/factories/publisher.rb index ee4de5409..d26b3cbd6 100644 --- a/spec/factories/publisher.rb +++ b/spec/factories/publisher.rb @@ -1,5 +1,5 @@ -FactoryGirl.define do +FactoryBot.define do factory :publisher do - title "Good publisher" + title { "Good publisher" } end end diff --git a/spec/factories/role.rb b/spec/factories/role.rb index e2da6a036..aef81c28a 100644 --- a/spec/factories/role.rb +++ b/spec/factories/role.rb @@ -1,9 +1,9 @@ -FactoryGirl.define do +FactoryBot.define do factory :roles, :class => Releaf::Permissions::Role do sequence(:name) {|n| "role #{n}"} factory :admin_role do - default_controller "releaf/permissions/users" + default_controller { "releaf/permissions/users" } after(:create) do |role| Releaf.application.config.available_controllers.each do|controller| role.permissions.create!(permission: "controller.#{controller}") @@ -12,7 +12,7 @@ end factory :content_role do - default_controller "admin/nodes" + default_controller { "admin/nodes" } after(:create) do |role| role.permissions.create!(permission: "controller.admin/nodes") end diff --git a/spec/factories/text_page.rb b/spec/factories/text_page.rb index b69f2a420..9e5961949 100644 --- a/spec/factories/text_page.rb +++ b/spec/factories/text_page.rb @@ -1,5 +1,5 @@ -FactoryGirl.define do +FactoryBot.define do factory :text_page do - text_html "super duper" + text_html { "super duper" } end end diff --git a/spec/factories/user.rb b/spec/factories/user.rb index 4c27dc5d8..157520eaf 100644 --- a/spec/factories/user.rb +++ b/spec/factories/user.rb @@ -1,12 +1,12 @@ -FactoryGirl.define do +FactoryBot.define do factory :users, class: Releaf::Permissions::User do trait :user_basic do email name surname - locale 'en' - password 'password' - password_confirmation 'password' + locale { 'en' } + password { 'password' } + password_confirmation { 'password' } end factory :user do diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index 74ec52e05..8608641da 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -2,7 +2,6 @@ require 'simplecov-rcov' require 'coveralls' require 'pry' -require 'pry-nav' SimpleCov.command_name 'rspec' Coveralls.wear!('rails') @@ -23,10 +22,11 @@ require 'spec_helper' require File.expand_path("../dummy/config/environment.rb", __FILE__) require 'rspec/rails' -require 'factory_girl' +require 'rails-controller-testing' +require 'factory_bot' require "shoulda-matchers" require 'db-query-matchers' -require 'capybara/poltergeist' +require 'selenium/webdriver' require 'with_model' require 'timecop' require 'with_model' @@ -41,23 +41,22 @@ # for devise testing include Warden::Test::Helpers +Capybara.register_driver(:chrome) do |app| + options = ::Selenium::WebDriver::Chrome::Options.new + options.add_argument('--headless') + options.add_argument('--window-size=1400,900') -Capybara.register_driver :poltergeist do |app| - Capybara::Poltergeist::Driver.new(app, js_errors: true, inspector: true, phantomjs_logger: WarningSuppressor) + if ENV['CI'] + options.add_argument('--no-sandbox') + options.add_argument('--disable-dev-shm-usage') + end + + Capybara::Selenium::Driver.new(app, browser: :chrome, options: options) end -class WarningSuppressor - IGNOREABLE = /CoreText performance|userSpaceScaleFactor/ +Capybara.javascript_driver = :chrome - def write(message) - if message =~ IGNOREABLE - 0 - else - puts(message) - 1 - end - end -end +Capybara.default_set_options = { clear: :backspace } # needed for 'fill_in "Foo", with: ""' to work RSpec.configure do |config| config.use_transactional_fixtures = false @@ -65,6 +64,10 @@ def write(message) config.order = "random" config.infer_spec_type_from_file_location! + config.include Shoulda::Matchers::ActiveModel, type: :model + config.include Shoulda::Matchers::ActiveRecord, type: :model + config.include Shoulda::Matchers::Independent + config.color = true if ENV['COVERAGE'] @@ -72,6 +75,7 @@ def write(message) end config.include Releaf::Test::Helpers + config.include CapybaraActions, type: :feature config.include WaitSteps config.include ExcelHelpers config.extend WithModel @@ -85,11 +89,16 @@ def write(message) config.extend ControllerMacros, type: :helper - # FactoryGirl - config.include FactoryGirl::Syntax::Methods + [:controller, :view, :request].each do |type| + config.include ::Rails::Controller::Testing::TestProcess, type: type + config.include ::Rails::Controller::Testing::TemplateAssertions, type: type + config.include ::Rails::Controller::Testing::Integration, type: type + end + + + config.include FactoryBot::Syntax::Methods - Capybara.javascript_driver = :poltergeist - Capybara.server = :webrick + Capybara.default_normalize_ws = true # disable empty translation creation diff --git a/spec/support/capybra_actions.rb b/spec/support/capybra_actions.rb new file mode 100644 index 000000000..6e82724d4 --- /dev/null +++ b/spec/support/capybra_actions.rb @@ -0,0 +1,6 @@ +module CapybaraActions + def blur_from(locator) + field = find_field(locator) + field.native.send_keys :tab + end +end diff --git a/spec/support/controller_macros.rb b/spec/support/controller_macros.rb index 026bc585f..99b0d5852 100644 --- a/spec/support/controller_macros.rb +++ b/spec/support/controller_macros.rb @@ -2,7 +2,7 @@ module ControllerMacros def login_as_user factory before(:each) do @request.env["devise.mapping"] = Devise.mappings[:admin] - sign_in FactoryGirl.create(factory) # Using factory girl as an example + sign_in FactoryBot.create(factory) # Using factory girl as an example end end end diff --git a/spec/support/excel_helpers.rb b/spec/support/excel_helpers.rb index 3d979aed7..8d0bbf535 100644 --- a/spec/support/excel_helpers.rb +++ b/spec/support/excel_helpers.rb @@ -45,9 +45,9 @@ def match_sheet actual, fixture for column in columns fixture_value = fixture.cell(row, column) actual_value = actual.cell(row, column) - if fixture_value != actual_value + if fixture_value.to_s != actual_value.to_s @errors << { - cell: "#{Roo::Base.number_to_letter(column)}#{row}", + cell: "#{Roo::Utils.number_to_letter(column)}#{row}", fixture_value: fixture_value, actual_value: actual_value }