refinerycms-pages 4.0.2 → 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 (42) hide show
  1. checksums.yaml +5 -5
  2. data/app/controllers/refinery/admin/page_parts_controller.rb +2 -1
  3. data/app/controllers/refinery/admin/pages_controller.rb +12 -11
  4. data/app/controllers/refinery/admin/pages_dialogs_controller.rb +8 -8
  5. data/app/controllers/refinery/pages/admin/preview_controller.rb +7 -0
  6. data/app/controllers/refinery/pages_controller.rb +4 -1
  7. data/app/helpers/refinery/admin/pages_helper.rb +29 -7
  8. data/app/models/refinery/page.rb +39 -51
  9. data/app/models/refinery/page_part.rb +12 -6
  10. data/app/presenters/refinery/pages/menu_presenter.rb +2 -2
  11. data/app/views/refinery/admin/pages/_form.html.erb +10 -10
  12. data/app/views/refinery/admin/pages/_page.html.erb +17 -45
  13. data/app/views/refinery/admin/pages/_sortable_list.html.erb +1 -1
  14. data/app/views/refinery/admin/pages/children.html.erb +1 -1
  15. data/app/views/refinery/admin/pages_dialogs/_page_link.html.erb +1 -1
  16. data/app/views/refinery/admin/pages_dialogs/link_to.html.erb +28 -21
  17. data/config/locales/en.yml +3 -3
  18. data/config/locales/sk.yml +4 -2
  19. data/db/migrate/20100913234708_create_refinerycms_pages_schema.rb +27 -30
  20. data/db/seeds.rb +1 -1
  21. data/lib/generators/refinery/pages/pages_generator.rb +1 -1
  22. data/lib/generators/refinery/pages/templates/config/initializers/refinery/pages.rb.erb +10 -3
  23. data/lib/refinery/pages/configuration.rb +8 -5
  24. data/lib/refinery/pages/engine.rb +2 -1
  25. data/lib/refinery/pages/finder.rb +95 -96
  26. data/lib/refinery/pages/instance_methods.rb +6 -4
  27. data/lib/refinery/pages.rb +3 -3
  28. data/lib/refinerycms/pages.rb +1 -0
  29. data/refinerycms-pages.gemspec +16 -22
  30. data/spec/controllers/refinery/pages_controller_spec.rb +23 -6
  31. data/spec/factories/page_parts.rb +2 -2
  32. data/spec/helpers/refinery/pages/admin/pages_helper_spec.rb +8 -18
  33. data/spec/models/refinery/page_menu_spec.rb +2 -2
  34. data/spec/models/refinery/page_url_spec.rb +4 -4
  35. data/spec/support/refinery/pages/caching_helpers.rb +1 -1
  36. data/spec/support/selector_helpers.rb +43 -0
  37. data/spec/{features → system}/refinery/admin/pages_spec.rb +164 -155
  38. data/spec/{features → system}/refinery/pages_spec.rb +10 -10
  39. metadata +48 -102
  40. checksums.yaml.gz.sig +0 -3
  41. data.tar.gz.sig +0 -0
  42. metadata.gz.sig +0 -2
@@ -3,22 +3,39 @@ require "spec_helper"
3
3
  module Refinery
4
4
  describe PagesController, :type => :controller do
5
5
  before do
6
- FactoryBot.create(:page, :link_url => "/")
7
- FactoryBot.create(:page, :title => "test")
6
+ FactoryBot.create(:page, { link_url: "/" })
7
+ FactoryBot.create(:page, title: "testing")
8
+ FactoryBot.create(:page, link_url: "/items")
8
9
  end
9
10
 
10
11
  describe "#home" do
11
- it "renders home template" do
12
- get :home
13
- expect(response).to render_template("home")
12
+ context "when page path set to default ('/')" do
13
+ it "renders home template" do
14
+ get :home
15
+ expect(response).to render_template("home")
16
+ end
17
+ end
18
+
19
+ context "when home_page_path set to another path" do
20
+ it "redirects to the specified path" do
21
+ allow(Refinery::Pages).to receive(:home_page_path).and_return('/items')
22
+ get :home
23
+ expect(response).to redirect_to('/items')
24
+ end
14
25
  end
15
26
  end
16
27
 
17
28
  describe "#show" do
18
29
  it "renders show template" do
19
- get :show, params: {path: "test"}
30
+ get :show, params: {path: "testing"}
20
31
  expect(response).to render_template("show")
21
32
  end
22
33
  end
34
+
35
+ describe "#show" do
36
+ it "does not interfere with active storage" do
37
+ expect(:get => "/rails/active_storage").not_to be_routable
38
+ end
39
+ end
23
40
  end
24
41
  end
@@ -1,6 +1,6 @@
1
1
  FactoryBot.define do
2
2
  factory :page_part, class: Refinery::PagePart do
3
- title 'Body'
4
- slug 'side_body'
3
+ title { 'Body' }
4
+ slug { 'side_body' }
5
5
  end
6
6
  end
@@ -18,13 +18,13 @@ module Refinery
18
18
 
19
19
  context "when page layout template is set using symbols" do
20
20
  before do
21
- allow(Pages.config).to receive(:layout_template_whitelist).and_return [:three, :one, :two]
21
+ allow(Refinery::Pages.config).to receive(:layout_template_whitelist).and_return [:three, :one, :two]
22
22
  end
23
23
 
24
- it "works as expected" do
25
- page = FactoryBot.create(:page, :layout_template => "three")
24
+ it "page layout template is set correctly" do
25
+ page = FactoryBot.create(:page, layout_template: "three")
26
26
 
27
- expect(helper.template_options(:layout_template, page)).to eq(:selected => 'three')
27
+ expect(helper.template_options(:layout_template, page)).to eq(selected: 'three')
28
28
  end
29
29
  end
30
30
 
@@ -57,9 +57,7 @@ module Refinery
57
57
  it "adds 'hidden' label" do
58
58
  page.show_in_menu = false
59
59
 
60
- expect(helper.page_meta_information(page)).to eq(
61
- %Q{<span class="label">#{::I18n.t('refinery.admin.pages.page.hidden')}</span>}
62
- )
60
+ expect(helper.page_meta_information(page)).to have_text ::I18n.t('refinery.admin.pages.page.hidden')
63
61
  end
64
62
  end
65
63
 
@@ -67,29 +65,21 @@ module Refinery
67
65
  it "adds 'skip to first child' label" do
68
66
  page.skip_to_first_child = true
69
67
 
70
- expect(helper.page_meta_information(page)).to eq(
71
- %Q{<span class="label">#{::I18n.t('refinery.admin.pages.page.skip_to_first_child')}</span>}
72
- )
68
+ expect(helper.page_meta_information(page)).to have_text ::I18n.t('refinery.admin.pages.page.skip_to_first_child')
73
69
  end
74
70
  end
75
71
 
76
72
  context "when link_url is present" do
77
73
  it "adds 'redirected' label" do
78
74
  page.link_url = '/redirect'
79
-
80
- expect(helper.page_meta_information(page)).to eq(
81
- %Q{<span class="label">#{::I18n.t('refinery.admin.pages.page.redirected')}</span>}
82
- )
75
+ expect(helper.page_meta_information(page)).to have_text ::I18n.t('refinery.admin.pages.page.redirected')
83
76
  end
84
77
  end
85
78
 
86
79
  context "when draft is true" do
87
80
  it "adds 'draft' label" do
88
81
  page.draft = true
89
-
90
- expect(helper.page_meta_information(page)).to eq(
91
- %Q{<span class="label notice">#{::I18n.t('refinery.admin.pages.page.draft')}</span>}
92
- )
82
+ expect(helper.page_meta_information(page)).to have_text ::I18n.t('refinery.admin.pages.page.draft')
93
83
  end
94
84
  end
95
85
  end
@@ -42,7 +42,7 @@ module Refinery
42
42
 
43
43
  context "with #menu_title" do
44
44
  before do
45
- page[:menu_title] = "Menu Title"
45
+ page.menu_title = "Menu Title"
46
46
  end
47
47
 
48
48
  it_should_behave_like "Refinery menu item hash"
@@ -54,7 +54,7 @@ module Refinery
54
54
 
55
55
  context "with #title" do
56
56
  before do
57
- page[:title] = "Title"
57
+ page.title = "Title"
58
58
  end
59
59
 
60
60
  it_should_behave_like "Refinery menu item hash"
@@ -105,7 +105,7 @@ module Refinery
105
105
 
106
106
  describe '#canonical' do
107
107
  let!(:default_canonical) {
108
- Globalize.with_locale(Refinery::I18n.default_frontend_locale) {
108
+ Mobility.with_locale(Refinery::I18n.default_frontend_locale) {
109
109
  page.canonical
110
110
  }
111
111
  }
@@ -121,7 +121,7 @@ module Refinery
121
121
  specify "translated page returns its pages's canonical" do
122
122
  allow(Refinery::I18n).to receive(:current_frontend_locale).and_return(:ru)
123
123
 
124
- Globalize.with_locale(:ru) do
124
+ Mobility.with_locale(:ru) do
125
125
  page.title = ru_page_title
126
126
  page.save
127
127
 
@@ -133,7 +133,7 @@ module Refinery
133
133
 
134
134
  describe '#canonical_slug' do
135
135
  let!(:default_canonical_slug) {
136
- Globalize.with_locale(Refinery::I18n.default_frontend_locale) {
136
+ Mobility.with_locale(Refinery::I18n.default_frontend_locale) {
137
137
  page.canonical_slug
138
138
  }
139
139
  }
@@ -148,7 +148,7 @@ module Refinery
148
148
  specify "translated page returns its page's canonical slug'" do
149
149
  allow(Refinery::I18n).to receive(:current_frontend_locale).and_return(:ru)
150
150
 
151
- Globalize.with_locale(:ru) do
151
+ Mobility.with_locale(:ru) do
152
152
  page.title = ru_page_title
153
153
  page.save
154
154
 
@@ -15,7 +15,7 @@ module CachingHelpers
15
15
 
16
16
  RSpec::Matchers.define :be_cached do
17
17
  match do |page|
18
- File.exists?(cached_file_path(page))
18
+ File.exist?(cached_file_path(page))
19
19
  end
20
20
  end
21
21
 
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ def index_entry
4
+ 'li.record.page'
5
+ end
6
+
7
+ def index_item(id)
8
+ [id, '.item'].join(' ')
9
+ end
10
+
11
+ # various edit actions selectors: there are several in a single index entry
12
+ # 1. the page title is wrapped in an edit link
13
+ # <a class="title edit" href="/refinery/pages/.../edit" tooltip="Edit this page">page title</a>
14
+ # 2. if there are several locales there is an edit_in_locale link for each locale
15
+ # <a id="es" class="edit locale_icon locale" href="/refinery/pages/.../edit?switch_locale=es" tooltip=page_title></a>
16
+ # 3. the actions group has an edit icon with a link to edit the page (equivalent to 1)
17
+ # <a class="edit_icon edit" href="/refinery/pages/.../edit" tooltip="Edit this page"></a>
18
+ #
19
+ def edit_selector(class_name: nil, locale: nil, slug: nil)
20
+ class_selector = [class_name, 'edit'].compact.join('.')
21
+ query_selector = ("?switch_locale=#{locale}" if locale.present?)
22
+ "a.#{class_selector}[href$='#{slug}/edit#{query_selector}']"
23
+ end
24
+
25
+ def title_link_selector(slug: '')
26
+ edit_selector(slug: slug, class_name: :title)
27
+ end
28
+
29
+ def icon_link_selector(slug: '')
30
+ edit_selector(slug: slug, class_name: :edit_icon)
31
+ end
32
+
33
+ def locale_link_selector(locale:, slug: '')
34
+ edit_selector(slug: slug, class_name: :locale, locale: locale.downcase)
35
+ end
36
+
37
+ def locales
38
+ "span.locales"
39
+ end
40
+
41
+ def locale_picker(locale)
42
+ ".locales ##{locale}"
43
+ end