refinerycms-core 4.0.3 → 4.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (107) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/config/refinery_core_manifest.js +9 -1
  3. data/app/assets/images/refinery/logo-large.png +0 -0
  4. data/app/assets/images/refinery/logo-medium.png +0 -0
  5. data/app/assets/images/refinery/logo-site-bar.png +0 -0
  6. data/app/assets/images/refinery/logo-small-medium.png +0 -0
  7. data/app/assets/images/refinery/logo-small.png +0 -0
  8. data/app/assets/images/refinery/logo-tiny.png +0 -0
  9. data/app/assets/images/refinery/logo.png +0 -0
  10. data/app/assets/images/refinery/refinery-cms-logo.svg +1 -558
  11. data/app/assets/javascripts/refinery/admin.js.erb +37 -21
  12. data/app/assets/javascripts/refinery/ajaxy_pagination.js +16 -0
  13. data/app/assets/javascripts/refinery/image_crop.js +101 -0
  14. data/app/assets/javascripts/refinery/interface.js.erb +42 -0
  15. data/app/assets/javascripts/refinery/refinery.js.erb +3 -3
  16. data/app/assets/javascripts/refinery/submit_continue.js.erb +23 -0
  17. data/app/assets/stylesheets/refinery/components/_file_type_icons.scss +36 -0
  18. data/app/assets/stylesheets/refinery/components/_icons.scss +89 -47
  19. data/app/assets/stylesheets/refinery/global/_colours.scss +12 -5
  20. data/app/assets/stylesheets/refinery/mixins/_images.scss +99 -0
  21. data/app/assets/stylesheets/refinery/mixins/_locales.scss +22 -0
  22. data/app/assets/stylesheets/refinery/mixins/_rounded.scss +9 -23
  23. data/app/assets/stylesheets/refinery/plugins/_ui.scss +7 -4
  24. data/app/assets/stylesheets/refinery/refinery.scss +4 -1
  25. data/app/assets/stylesheets/refinery/sections/_layout.scss +490 -265
  26. data/app/controllers/refinery/admin/dialogs_controller.rb +6 -6
  27. data/app/helpers/refinery/action_helper.rb +75 -0
  28. data/app/helpers/refinery/icon_helper.rb +51 -0
  29. data/app/helpers/refinery/image_helper.rb +1 -1
  30. data/app/helpers/refinery/pagination_helper.rb +1 -0
  31. data/app/helpers/refinery/site_bar_helper.rb +10 -7
  32. data/app/helpers/refinery/tag_helper.rb +5 -36
  33. data/app/helpers/refinery/translation_helper.rb +12 -1
  34. data/app/views/refinery/_head.html.erb +1 -0
  35. data/app/views/refinery/_matomo_analytics.html.erb +18 -0
  36. data/app/views/refinery/_site_bar.html.erb +9 -9
  37. data/app/views/refinery/admin/_error_messages.html.erb +4 -4
  38. data/app/views/refinery/admin/_locale_picker.html.erb +8 -14
  39. data/config/initializers/assets.rb +5 -1
  40. data/config/initializers/zeitwerk.rb +12 -0
  41. data/config/locales/en.yml +3 -1
  42. data/config/locales/sk.yml +7 -0
  43. data/lib/generators/refinery/cms/cms_generator.rb +24 -20
  44. data/lib/generators/refinery/core/templates/config/initializers/refinery/core.rb.erb +5 -0
  45. data/lib/generators/refinery/dummy/dummy_generator.rb +32 -10
  46. data/lib/generators/refinery/dummy/templates/rails/application.rb.erb +27 -7
  47. data/lib/generators/refinery/dummy/templates/rails/boot.rb.erb +1 -2
  48. data/lib/generators/refinery/dummy/templates/rails/database.yml +55 -14
  49. data/lib/generators/refinery/dummy/templates/rails/manifest.js +3 -0
  50. data/lib/generators/refinery/dummy/templates/rails/storage.yml +7 -0
  51. data/lib/generators/refinery/engine/engine_generator.rb +1 -0
  52. data/lib/generators/refinery/engine/templates/Gemfile +1 -2
  53. data/lib/generators/refinery/engine/templates/Rakefile +2 -2
  54. data/lib/generators/refinery/engine/templates/app/controllers/refinery/namespace/admin/plural_name_controller.rb.erb +1 -1
  55. data/lib/generators/refinery/engine/templates/app/controllers/refinery/namespace/plural_name_controller.rb.erb +1 -1
  56. data/lib/generators/refinery/engine/templates/app/models/refinery/namespace/singular_name.rb.erb +1 -0
  57. data/lib/generators/refinery/engine/templates/app/views/refinery/namespace/admin/plural_name/_form.html.erb +1 -1
  58. data/lib/generators/refinery/engine/templates/db/migrate/1_create_namespace_plural_name.rb.erb +15 -4
  59. data/lib/generators/refinery/engine/templates/lib/generators/refinery/extension_plural_name_generator.rb.erb +1 -1
  60. data/lib/generators/refinery/engine/templates/lib/refinery/plural_name.rb.erb +1 -1
  61. data/lib/refinery/admin/base_controller.rb +2 -2
  62. data/lib/refinery/application_controller.rb +1 -2
  63. data/lib/refinery/cli.rb +1 -1
  64. data/lib/refinery/core/configuration.rb +4 -1
  65. data/lib/refinery/core/engine.rb +20 -0
  66. data/lib/refinery/core.rb +0 -1
  67. data/lib/refinery/crud.rb +33 -32
  68. data/lib/refinery/extension_generation.rb +55 -8
  69. data/lib/refinery/generators/generated_attribute.rb +13 -0
  70. data/lib/refinery/plugins.rb +1 -1
  71. data/lib/refinery/version.rb +4 -4
  72. data/lib/refinery.rb +9 -2
  73. data/lib/refinerycms/core.rb +1 -0
  74. data/lib/tasks/refinery.rake +3 -3
  75. data/refinerycms-core.gemspec +21 -27
  76. data/spec/controllers/refinery/sitemap_controller_spec.rb +1 -1
  77. data/spec/helpers/refinery/tag_helper_spec.rb +1 -1
  78. data/spec/helpers/refinery/translation_helper_spec.rb +46 -10
  79. data/spec/lib/generators/refinery/cms/cms_generator_spec.rb +6 -6
  80. data/spec/lib/generators/refinery/engine/engine_generator_multiple_resources_spec.rb +23 -2
  81. data/spec/lib/refinery/cli_spec.rb +2 -2
  82. data/spec/lib/refinery/{users_manager_spec.rb → core/users_manager_spec.rb} +1 -1
  83. data/spec/lib/refinery/crud_spec.rb +2 -1
  84. data/spec/presenters/refinery/translated_field_presenter_spec.rb +5 -7
  85. data/spec/support/refinery.rb +2 -2
  86. data/spec/{features → system}/refinery/admin/custom_assets_spec.rb +1 -1
  87. data/spec/system/refinery/admin/dialogs_spec.rb +29 -0
  88. data/spec/{features → system}/refinery/admin/xhr_paging_spec.rb +10 -7
  89. data/spec/{features → system}/refinery/application_layout_spec.rb +3 -4
  90. data/spec/{features → system}/refinery/core_spec.rb +1 -1
  91. data/spec/{features → system}/refinery/site_bar_spec.rb +5 -3
  92. data/vendor/assets/javascripts/canvas-to-blob.js +126 -0
  93. data/vendor/assets/javascripts/cropper.js +3715 -0
  94. data/vendor/assets/stylesheets/cropper.css +305 -0
  95. metadata +108 -171
  96. checksums.yaml.gz.sig +0 -0
  97. data/app/assets/javascripts/refinery/ajaxy_pagination.js.coffee +0 -10
  98. data/app/assets/javascripts/refinery/interface.js.coffee.erb +0 -33
  99. data/app/assets/javascripts/refinery/submit_continue.js.coffee.erb +0 -12
  100. data/spec/features/refinery/admin/dialogs_spec.rb +0 -29
  101. data/spec/support/database_cleaner.rb +0 -21
  102. data.tar.gz.sig +0 -0
  103. metadata.gz.sig +0 -5
  104. /data/lib/generators/refinery/cms/templates/config/{database.yml.mysql → database.mysql.yml} +0 -0
  105. /data/lib/generators/refinery/cms/templates/config/{database.yml.postgresql → database.postgresql.yml} +0 -0
  106. /data/lib/generators/refinery/cms/templates/config/{database.yml.sqlite3 → database.sqlite3.yml} +0 -0
  107. /data/lib/refinery/{users_manager.rb → core/users_manager.rb} +0 -0
@@ -3,13 +3,43 @@ module Refinery
3
3
 
4
4
  def self.included(base)
5
5
  base.class_eval do
6
- argument :attributes, :type => :array, :default => [], :banner => "field:type field:type"
7
-
8
- class_option :namespace, :type => :string, :default => nil, :banner => 'NAMESPACE', :required => false
9
- class_option :authors, :type => :array, :default => [], :banner => 'author author', :required => false, :desc => 'Indicates authors of this extension'
10
- class_option :extension, :type => :string, :default => nil, :banner => 'ENGINE', :required => false
11
- class_option :i18n, :type => :array, :default => [], :required => false, :banner => "field field", :desc => 'Indicates generated fields'
12
- class_option :install, :type => :boolean, :default => false, :required => false, :banner => nil, :desc => 'Bundles and runs the generated generator, rake db:migrate, rake db:seed for you'
6
+ argument :attributes,
7
+ type: :array,
8
+ default: [],
9
+ banner: 'field:type field:type'
10
+
11
+ class_option :namespace,
12
+ type: :string,
13
+ default: '',
14
+ banner: 'NAMESPACE',
15
+ required: false
16
+
17
+ class_option :authors,
18
+ type: :array,
19
+ default: [],
20
+ banner: 'author author',
21
+ required: false,
22
+ desc: 'Indicates authors of this extension'
23
+
24
+ class_option :extension,
25
+ type: :string,
26
+ default: '',
27
+ banner: 'ENGINE',
28
+ required: false
29
+
30
+ class_option :i18n,
31
+ type: :array,
32
+ default: [],
33
+ required: false,
34
+ banner: 'field field',
35
+ desc: 'Indicates generated fields'
36
+
37
+ class_option :install,
38
+ type: :boolean,
39
+ default: false,
40
+ required: false,
41
+ banner: nil,
42
+ desc: 'Bundles and runs the generated generator, rake db:migrate, rake db:seed for you'
13
43
 
14
44
  remove_class_option :skip_namespace
15
45
  end
@@ -68,6 +98,13 @@ module Refinery
68
98
  @localized_attributes ||= attributes.select{ |a| options[:i18n].include?(a.name)}
69
99
  end
70
100
 
101
+ def localized_table_name
102
+ localized_table_name = [ 'refinery']
103
+ localized_table_name << namespacing.underscore if table_name != namespacing.underscore.pluralize
104
+ localized_table_name << [ singular_table_name, 'translations']
105
+ localized_table_name.join('_')
106
+ end
107
+
71
108
  def attributes_for_translation_table
72
109
  localized_attributes.inject([]) { |memo, attr| memo << ":#{attr.name} => :#{attr.type}"}.join(', ')
73
110
  end
@@ -333,6 +370,14 @@ module Refinery
333
370
  gsub('namespace', namespacing.underscore)
334
371
  end
335
372
 
373
+ def index_route
374
+ if namespacing.underscore == plural_name
375
+ '/' + plural_name
376
+ else
377
+ '/' + namespacing.underscore + '/' + plural_name
378
+ end
379
+ end
380
+
336
381
  def viable_templates
337
382
  @viable_templates ||= begin
338
383
  all_templates.reject(&method(:reject_template?)).inject({}) do |hash, path|
@@ -393,8 +438,10 @@ module Refinery
393
438
  end
394
439
  end
395
440
 
441
+ # merge_rb is only used for merging routes.rb
442
+ # Put destination lines first, so that extension namespaced routes precede the default extension route
396
443
  def merge_rb
397
- (source_lines[0..-2] + destination_lines[1..-2] + [source_lines.last]).join "\n"
444
+ (destination_lines[0..-2] + source_lines[1..-2] + [destination_lines.last]).join "\n"
398
445
  end
399
446
 
400
447
  def merge_yaml
@@ -3,9 +3,22 @@ require 'rails/generators/generated_attribute'
3
3
  module Refinery
4
4
  module Generators
5
5
  class GeneratedAttribute < Rails::Generators::GeneratedAttribute
6
+ REFINERY_TYPES = %w(image resource radio select checkbox)
7
+
6
8
  attr_accessor :refinery_type
7
9
 
8
10
  class << self
11
+ def parse(column_definition)
12
+ name, type, index_type = column_definition.split(":")
13
+
14
+ # Handle Refinery's custom types before Rails validates them
15
+ if type && REFINERY_TYPES.include?(type)
16
+ new(name, type.to_sym, index_type)
17
+ else
18
+ super
19
+ end
20
+ end
21
+
9
22
  def reference?(type)
10
23
  [:references, :belongs_to, :image, :resource].include? type
11
24
  end
@@ -49,7 +49,7 @@ module Refinery
49
49
  def update_positions(plugin_list)
50
50
  plugins = plugin_list.map {|p| find_by_name(p) }.reject(&:blank?)
51
51
  plugins.each_with_index do |plugin, index|
52
- plugin.update_attributes(position: index)
52
+ plugin.update(position: index)
53
53
  end
54
54
  end
55
55
 
@@ -1,8 +1,8 @@
1
1
  module Refinery
2
2
  class Version
3
3
  @major = 4
4
- @minor = 0
5
- @tiny = 3
4
+ @minor = 1
5
+ @tiny = 0
6
6
  @build = nil
7
7
 
8
8
  class << self
@@ -13,8 +13,8 @@ module Refinery
13
13
  end
14
14
 
15
15
  def required_ruby_version
16
- '>= 2.2.2'
16
+ '>= 3.1'
17
17
  end
18
18
  end
19
19
  end
20
- end
20
+ end
data/lib/refinery.rb CHANGED
@@ -1,4 +1,11 @@
1
- require 'rails' # from railties
1
+ begin
2
+ require 'rails' # from railties
3
+ rescue NameError => e
4
+ raise unless e.message.include?("ActiveSupport::LoggerThreadSafeLevel::Logger")
5
+
6
+ require "logger"
7
+ retry
8
+ end
2
9
  require 'active_record'
3
10
  require 'action_controller'
4
11
  require 'rbconfig'
@@ -141,7 +148,7 @@ module Refinery
141
148
 
142
149
  klass = klass.constantize if klass.respond_to?(:constantize)
143
150
  active_name = ::ActiveModel::Name.new(
144
- klass, (Refinery if klass.parents.include?(Refinery))
151
+ klass, (Refinery if klass.module_parents.include?(Refinery))
145
152
  )
146
153
 
147
154
  if options[:admin]
@@ -0,0 +1 @@
1
+ require_relative '../refinery/core'
@@ -1,18 +1,18 @@
1
1
  namespace :refinery do
2
2
  desc "Override files for use in an application"
3
3
  task :override => :environment do
4
- Refinery::CLI.new.override(ENV)
4
+ Refinery::Cli.new.override(ENV)
5
5
  end
6
6
 
7
7
  desc "Override files for use in an application"
8
8
  namespace :override do
9
9
  task :list => :environment do
10
- Refinery::CLI.new.override_list(ENV)
10
+ Refinery::Cli.new.override_list(ENV)
11
11
  end
12
12
  end
13
13
 
14
14
  desc "Un-crudify a method on a controller that uses crudify"
15
15
  task :uncrudify => :environment do
16
- Refinery::CLI.new.uncrudify(ENV['controller'], ENV['action'])
16
+ Refinery::Cli.new.uncrudify(ENV['controller'], ENV['action'])
17
17
  end
18
18
  end
@@ -1,44 +1,38 @@
1
- # Encoding: UTF-8
2
- require File.expand_path('../../core/lib/refinery/version', __FILE__)
1
+ # frozen_string_literal: true
2
+
3
+ require File.expand_path('../core/lib/refinery/version', __dir__)
3
4
 
4
5
  version = Refinery::Version.to_s
5
- rails_version = ['>= 5.1.0', '< 5.2']
6
+ rails_version = ['>= 6.1.0', '< 9']
6
7
 
7
8
  Gem::Specification.new do |s|
8
9
  s.platform = Gem::Platform::RUBY
9
- s.name = %q{refinerycms-core}
10
+ s.name = 'refinerycms-core'
10
11
  s.version = version
11
- s.summary = %q{Core extension for Refinery CMS}
12
- s.description = %q{The core of Refinery CMS. This handles the common functionality and is required by most extensions}
13
- s.email = %q{refinerycms@p.arndt.io}
14
- s.homepage = %q{https://www.refinerycms.com}
15
- s.rubyforge_project = %q{refinerycms}
16
- s.authors = ['Philip Arndt', 'Uģis Ozols', 'Rob Yurkowski']
17
- s.license = %q{MIT}
18
- s.require_paths = %w(lib)
12
+ s.summary = 'Core extension for Refinery CMS'
13
+ s.description = 'The core of Refinery CMS. This handles the common functionality and is required by most extensions'
14
+ s.email = 'gems@p.arndt.io'
15
+ s.homepage = 'https://github.com/refinery/refinerycms'
16
+ s.authors = ['Philip Arndt', 'David Jones', 'Uģis Ozols', 'Brice Sanchez']
17
+ s.license = 'MIT'
18
+ s.require_paths = %w[lib]
19
19
 
20
20
  s.files = `git ls-files`.split("\n")
21
21
  s.test_files = `git ls-files -- spec/*`.split("\n")
22
22
 
23
23
  s.required_ruby_version = Refinery::Version.required_ruby_version
24
24
 
25
- s.add_dependency 'refinerycms-i18n', ['~> 4.0', '>= 4.0.0']
26
- s.add_dependency 'awesome_nested_set', ['~> 3.0', '>= 3.0.0']
27
- s.add_dependency 'railties', rails_version
28
- s.add_dependency 'activerecord', rails_version
29
25
  s.add_dependency 'actionpack', rails_version
30
- s.add_dependency 'truncate_html', '~> 0.9'
31
- s.add_dependency 'will_paginate', '~> 3.1', '>= 3.1.0'
32
- s.add_dependency 'sass-rails', '>= 4.0', '< 5.1'
26
+ s.add_dependency 'activerecord', rails_version
27
+
28
+ s.add_dependency 'decorators', '~> 2.0', '>= 2.0.0'
33
29
  s.add_dependency 'font-awesome-sass', '>= 4.3.0', '< 5.0'
34
- s.add_dependency 'coffee-rails', ['~> 4.0', '>= 4.0.0']
35
30
  s.add_dependency 'jquery-rails', '~> 4.3', '>= 4.3.1'
36
- s.add_dependency 'jquery-ui-rails', '~> 5.0', '>= 5.0.0'
37
- s.add_dependency 'decorators', '~> 2.0', '>= 2.0.0'
31
+ s.add_dependency 'jquery-ui-rails', '~> 7.0.0'
32
+ s.add_dependency 'railties', rails_version
33
+ s.add_dependency 'refinerycms-i18n', ['~> 5.0', '>= 5.0.1']
34
+ s.add_dependency 'sass-rails', '>= 4.0', '< 7'
35
+ s.add_dependency 'truncate_html', '~> 0.9'
36
+ s.add_dependency 'will_paginate', '~> 3.1', '>= 3.1.0'
38
37
  s.add_dependency 'zilch-authorisation', '~> 0', '>= 0.0.1'
39
-
40
- s.cert_chain = [File.expand_path("../../certs/parndt.pem", __FILE__)]
41
- if $0 =~ /gem\z/ && ARGV.include?("build") && ARGV.include?(__FILE__)
42
- s.signing_key = File.expand_path("~/.ssh/gem-private_key.pem")
43
- end
44
38
  end
@@ -9,7 +9,7 @@ module Refinery
9
9
  it "shows a valid xml response" do
10
10
  get :index
11
11
 
12
- expect(response).to be_success
12
+ expect(response).to be_successful
13
13
  end
14
14
  end
15
15
  end
@@ -15,7 +15,7 @@ module Refinery
15
15
  end
16
16
 
17
17
  it "wraps image_tag with some options preset" do
18
- expect(helper.refinery_icon_tag("ugis.ozols.jpg")).to xml_eq(%Q{<img alt="Ugis.ozols" height="16" src="/images/refinery/icons/ugis.ozols.jpg" width="16" />})
18
+ expect(helper.refinery_icon_tag("ugis.ozols.jpg", { alt: "Ugis.ozols"})).to xml_eq(%Q{<img alt="Ugis.ozols" height="16" src="/images/refinery/icons/ugis.ozols.jpg" width="16" />})
19
19
  end
20
20
  end
21
21
 
@@ -1,7 +1,7 @@
1
1
  require "spec_helper"
2
2
 
3
3
  module Refinery
4
- describe TranslationHelper, :type => :helper do
4
+ describe TranslationHelper, type: :helper do
5
5
 
6
6
  describe "#t" do
7
7
  it "overrides Rails' translation method" do
@@ -14,30 +14,66 @@ module Refinery
14
14
  let(:page) { FactoryBot.build(:page) }
15
15
 
16
16
  before do
17
- Globalize.with_locale(:en) do
18
- page.title = "draft"
19
- page.save!
17
+ Mobility.with_locale(:en) do
18
+ page.update!({title: 'draft'})
20
19
  end
21
20
 
22
- Globalize.with_locale(:lv) do
21
+ Mobility.with_locale(:lv) do
23
22
  page.title = "melnraksts"
24
23
  page.save!
25
24
  end
26
25
  end
27
26
 
28
- context "when title is present" do
29
- it "returns it" do
27
+ context "when field for current locale is present" do
28
+ it "it's value is returned" do
30
29
  expect(helper.translated_field(page, :title)).to eq("draft")
31
30
  end
32
31
  end
33
32
 
34
- context "when title for current locale isn't available" do
35
- it "returns existing title from translations" do
36
- Page.translation_class.where(locale: :en).first.destroy
33
+ context "when field for current locale isn't present" do
34
+
35
+ it "returns existing field value from other translations" do
36
+ Page::Translation.where(locale: :en).first.destroy
37
37
  expect(helper.translated_field(page, :title)).to eq("melnraksts")
38
38
  end
39
39
  end
40
40
  end
41
41
 
42
+ describe '#locales_with_translated_field' do
43
+ let(:page) { FactoryBot.build(:page) }
44
+
45
+ before do
46
+ allow(Refinery::I18n).to receive(:frontend_locales).and_return([:en, :lv, :it])
47
+ Mobility.with_locale(:en) do
48
+ page.update!({title: 'draft'})
49
+ end
50
+
51
+ Mobility.with_locale(:lv) do
52
+ page.title = "melnraksts"
53
+ page.save!
54
+ end
55
+ end
56
+
57
+ it 'returns an array of locales which have the named field translated' do
58
+ expect(helper.locales_with_translated_field(page, :title)).to eq([:en, :lv])
59
+ end
60
+
61
+ context 'The field has no translations' do
62
+ before do
63
+ Refinery::I18n.frontend_locales.each do |locale|
64
+ Mobility.with_locale(locale) do
65
+ page.title = "A title"
66
+ page.menu_title = ""
67
+ page.save!
68
+ end
69
+ end
70
+ end
71
+
72
+ it 'returns an empty array' do
73
+ expect(helper.locales_with_translated_field(page, :menu_title)).to eq([])
74
+ end
75
+ end
76
+ end
77
+
42
78
  end
43
79
  end
@@ -57,9 +57,9 @@ end
57
57
  end
58
58
  end
59
59
  directory "config" do
60
- file "database.yml.mysql"
61
- file "database.yml.postgresql"
62
- file "database.yml.sqlite3"
60
+ file "database.mysql.yml"
61
+ file "database.postgresql.yml"
62
+ file "database.sqlite3.yml"
63
63
  end
64
64
  }
65
65
  end
@@ -97,12 +97,12 @@ end
97
97
  end
98
98
 
99
99
  def copy_routes
100
- routes = File.join(Gem.loaded_specs['railties'].full_gem_path, 'lib', 'rails', 'generators', 'rails', 'app', 'templates', 'config', 'routes.rb')
100
+ routes = File.join(Gem.loaded_specs['railties'].
101
+ full_gem_path, 'lib', 'rails', 'generators', 'rails', 'app', 'templates', 'config', 'routes.rb.tt')
101
102
  destination = File.join(destination_root, "config")
102
103
 
103
104
  FileUtils.mkdir_p(destination)
104
- FileUtils.cp routes, destination
105
+ FileUtils.cp routes, File.join(destination, "routes.rb")
105
106
  end
106
-
107
107
  end
108
108
  end
@@ -7,6 +7,7 @@ module Refinery
7
7
  describe EngineGenerator do
8
8
  include GeneratorSpec::TestCase
9
9
  destination File.expand_path("../../../../../../tmp", __FILE__)
10
+ let(:extension_root){"#{destination_root}/vendor/extensions/rspec_product_tests"}
10
11
 
11
12
  before do
12
13
  prepare_destination
@@ -41,6 +42,13 @@ module Refinery
41
42
  end
42
43
  }
43
44
  end
45
+
46
+ it "does not namespace the link_url in the extension controller" do
47
+ File.read("#{extension_root}/app/controllers/refinery/rspec_product_tests/rspec_product_tests_controller.rb") do |file|
48
+ expect(file.grep(%r{/:link_url => "/rspec_product_tests"\)\.first/})).to be_truthy
49
+ end
50
+ end
51
+
44
52
  end
45
53
 
46
54
  context "when generating a resource inside existing extensions dir" do
@@ -66,16 +74,29 @@ module Refinery
66
74
  end
67
75
 
68
76
  it "appends existing seeds file" do
69
- File.open("#{destination_root}/vendor/extensions/rspec_product_tests/db/seeds.rb") do |file|
77
+ File.open("#{extension_root}/db/seeds.rb") do |file|
70
78
  expect(file.grep(%r{/rspec_product_tests|/rspec_item_tests}).count).to eq(2)
71
79
  end
72
80
  end
73
81
 
74
82
  it "appends routes to the routes file" do
75
- File.open("#{destination_root}/vendor/extensions/rspec_product_tests/config/routes.rb") do |file|
83
+ File.open("#{extension_root}/config/routes.rb") do |file|
76
84
  expect(file.grep(%r{rspec_item_tests}).count).to eq(2)
77
85
  end
78
86
  end
87
+
88
+ it "places second and subsequent routes before the primary extension routes" do
89
+ content = File.read("#{extension_root}/config/routes.rb")
90
+ item_front_end_route = content.index("resources :rspec_item_tests, :only => [:index, :show]")
91
+ product_front_end_route = content.index("resources :rspec_product_tests, :path => '', :only => [:index, :show]")
92
+ expect(item_front_end_route).to be < product_front_end_route
93
+ end
94
+
95
+ it "uses the namespaced url in the extension controller" do
96
+ content = File.read("#{extension_root}/app/controllers/refinery/rspec_product_tests/rspec_item_tests_controller.rb") do |file|
97
+ expect(file.grep(%r{/:link_url => "/rspec_product_tests/rspec_item_tests"\)\.first/})).to be_truthy
98
+ end
99
+ end
79
100
  end
80
101
  end
81
102
  end
@@ -2,7 +2,7 @@ require "spec_helper"
2
2
  require 'refinery/cli'
3
3
  require "rake"
4
4
 
5
- describe "CLI" do
5
+ describe "Cli" do
6
6
  let(:rake) { Rake::Application.new }
7
7
 
8
8
  before do
@@ -98,7 +98,7 @@ describe "CLI" do
98
98
  Array(spec_success_message).each do |message_fragment|
99
99
  expect(msg).to include(message_fragment)
100
100
  end
101
- expect(File.exists?(Rails.root.join(copied_file_location))).to be_truthy
101
+ expect(File.exist?(Rails.root.join(copied_file_location))).to be_truthy
102
102
  end
103
103
  end
104
104
  end
@@ -1,5 +1,5 @@
1
1
  require 'spec_helper_no_rails'
2
- require 'refinery/users_manager'
2
+ require 'refinery/core/users_manager'
3
3
 
4
4
  module Refinery
5
5
  module Core
@@ -15,7 +15,8 @@ module Refinery
15
15
  end
16
16
 
17
17
  class CrudDummyController < ::ApplicationController
18
- crudify :'refinery/crud_dummy'
18
+ skip_before_action :find_or_set_locale, raise: false
19
+ crudify :'refinery/crud_dummy', find_actions: [:update, :destroy, :edit]
19
20
  end
20
21
  end
21
22
 
@@ -5,14 +5,12 @@ module Refinery
5
5
  let(:page) { FactoryBot.build(:page) }
6
6
 
7
7
  before do
8
- Globalize.with_locale(:en) do
9
- page.title = "draft"
10
- page.save!
8
+ Mobility.with_locale(:en) do
9
+ page.update!({ title: "draft" })
11
10
  end
12
11
 
13
- Globalize.with_locale(:lv) do
14
- page.title = "melnraksts"
15
- page.save!
12
+ Mobility.with_locale(:lv) do
13
+ page.update!(title: "melnraksts")
16
14
  end
17
15
  end
18
16
 
@@ -25,7 +23,7 @@ module Refinery
25
23
 
26
24
  context "when title for current locale isn't available" do
27
25
  it "returns existing title from translations" do
28
- Page.translation_class.where(locale: :en).first.destroy
26
+ Page::Translation.where(locale: :en).first.destroy
29
27
  expect(TranslatedFieldPresenter.new(page).call(:title)).to eq("melnraksts")
30
28
  end
31
29
  end
@@ -1,9 +1,9 @@
1
- require 'refinerycms-testing'
1
+ require 'refinery/testing'
2
2
 
3
3
  RSpec.configure do |config|
4
4
  config.extend Refinery::Testing::ControllerMacros::Authentication, :type => :controller
5
5
  config.include Refinery::Testing::ControllerMacros::Routes, :type => :controller
6
- config.extend Refinery::Testing::FeatureMacros::Authentication, :type => :feature
6
+ config.extend Refinery::Testing::FeatureMacros::Authentication, :type => :system
7
7
 
8
8
  # set some config values so that image and resource factories don't fail to create
9
9
  config.before do
@@ -1,7 +1,7 @@
1
1
  require "spec_helper"
2
2
 
3
3
  module Refinery
4
- describe "custom", type: :feature do
4
+ describe "custom", type: :system do
5
5
  refinery_login
6
6
 
7
7
  let(:custom_js){ Refinery.roots('refinery/core').join('spec/support/fixtures/custom_js.js') }
@@ -0,0 +1,29 @@
1
+ require "spec_helper"
2
+
3
+ module Refinery
4
+ describe "dialog", type: :system do
5
+ refinery_login
6
+
7
+ context "links" do
8
+ it "have iframe src" do
9
+ visit refinery.admin_dialog_path("Link")
10
+ expect(page).to have_selector("iframe[src$='/refinery/pages_dialogs/link_to']")
11
+ end
12
+ end
13
+
14
+ context "images" do
15
+ it "have iframe src" do
16
+ visit refinery.admin_dialog_path("Image")
17
+ expect(page).to have_selector("iframe[src$='/refinery/images/insert?modal=true']")
18
+ end
19
+ end
20
+
21
+ context "a" do
22
+ it "404s" do
23
+ expect_any_instance_of(Admin::DialogsController).to receive(:error_404).once
24
+
25
+ visit refinery.admin_dialog_path("a")
26
+ end
27
+ end
28
+ end
29
+ end
@@ -1,18 +1,22 @@
1
1
  require "spec_helper"
2
2
 
3
3
  module Refinery
4
- describe "Crudify", type: :feature do
4
+ describe "Crudify", type: :system do
5
+ before do
6
+ driven_by(:selenium_chrome_headless)
7
+ end
5
8
  refinery_login
6
9
 
7
10
  describe "xhr_paging", :js do
8
11
  # Refinery::Admin::ImagesController specifies :order => 'created_at DESC' in crudify
9
12
  let(:first_image) { Image.order('created_at DESC').first }
10
13
  let(:last_image) { Image.order('created_at DESC').last }
11
- let!(:image_1) { FactoryBot.create :image }
12
- let!(:image_2) { FactoryBot.create :image }
14
+ let!(:image_1) { FactoryBot.create(:image) }
15
+ let!(:image_2) { FactoryBot.create(:image) }
13
16
 
14
17
  before do
15
18
  allow(Image).to receive(:per_page).and_return(1)
19
+ allow(Refinery::Images).to receive(:preferred_image_view).and_return(:grid)
16
20
  end
17
21
 
18
22
  it 'performs ajax paging of index' do
@@ -22,9 +26,9 @@ module Refinery
22
26
  expect(page).to have_css(%Q{img[alt="#{first_image.title}"]})
23
27
 
24
28
  # placeholder which would disappear in a full page refresh.
25
- page.evaluate_script("node = document.createElement('i');")
26
- page.evaluate_script("node.id = 'has_not_refreshed_entire_page';")
27
- page.evaluate_script("document.body.appendChild(node);")
29
+ page.execute_script("node = document.createElement('i');")
30
+ page.execute_script("node.id = 'has_not_refreshed_entire_page';")
31
+ page.execute_script("document.body.appendChild(node);")
28
32
 
29
33
  within '.pagination' do
30
34
  click_link '2'
@@ -37,5 +41,4 @@ module Refinery
37
41
  end
38
42
  end
39
43
  end
40
-
41
44
  end
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  module Refinery
4
- describe 'layout', :type => :feature do
4
+ describe 'layout', :type => :system do
5
5
  refinery_login
6
6
 
7
7
  let(:home_page) do
@@ -9,10 +9,9 @@ module Refinery
9
9
  end
10
10
 
11
11
  describe 'body' do
12
- it "id is the page's canonical id" do
12
+ it "has an id that includes the page's canonical name" do
13
13
  visit home_page.url
14
-
15
- expect(page).to have_css 'body#home-page'
14
+ expect(page.find("body")[:id]).to eq "home-page"
16
15
  end
17
16
  end
18
17
  end
@@ -2,7 +2,7 @@ require "spec_helper"
2
2
 
3
3
  module Refinery
4
4
  module Core
5
- describe Engine, :type => :feature do
5
+ describe Engine, :type => :system do
6
6
  describe "#refinery_inclusion!" do
7
7
  it "should be idempotent" do
8
8
  expect { visit(refinery.root_path) }.not_to raise_error