refinerycms-pages 3.0.1 → 3.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5fdd8c12a2b4c050e7c4997d2b1c44e80ada1219
4
- data.tar.gz: 3cc0a3205db48009b2594ec278280dbaf3434162
3
+ metadata.gz: 2e83dbfdfba885ff0dd0f31a0b23f226c01483b0
4
+ data.tar.gz: 1eb13220474770daf946ab20955393fab25e7388
5
5
  SHA512:
6
- metadata.gz: 521eb0e2ede33925f53d4f4e4094b1531a42ba8a56155d0906f7841ad9ba9134aca6d8c4a7610240f550cf52e39e056c4fae7d1de54a18c9558f60e511f762b8
7
- data.tar.gz: 6d08af242e7024af03de977cbd50cbcc3a6757384a9ba7dcb63208b19ef96868f6069cb1aa92b4fa167fff27477d87fd62237960169959f313a391584284f188
6
+ metadata.gz: 94f97db5e16189f54615a2fdc27000554583c2704ef9cf8a3261ae87e6e08034892bff197c36f2758aabf53f807abf8645db29ad7e74ad4bb80d460f17f5073f
7
+ data.tar.gz: 6ea014c7893bf92120a23aece4e6b8d005f75c2cc37a2bdb644dcdbf60d719f2e0773c13195ca24159c840e32ed2a098457db8bf319b8c4b840f1ceea01bed2d
@@ -23,7 +23,7 @@ module Refinery
23
23
 
24
24
  protected
25
25
  def new_page_part_params
26
- params.permit(:title, :slug, :body)
26
+ params.except(:part_index).permit(:title, :slug, :body, :locale)
27
27
  end
28
28
 
29
29
  end
@@ -50,6 +50,7 @@ module Refinery
50
50
  # We show the title from the next available locale
51
51
  # if there is no title for the current locale
52
52
  def page_title_with_translations(page)
53
+ Refinery.deprecate('page_title_with_translations', when: '3.1', replacement: 'translated_field')
53
54
  page.title.presence || page.translations.detect { |t| t.title.present?}.title
54
55
  end
55
56
 
@@ -11,6 +11,7 @@ module Refinery
11
11
  # Sections may be hidden, in which case they wont display at all.
12
12
  class SectionPresenter
13
13
  include ActionView::Helpers::TagHelper
14
+ include ActionView::Helpers::SanitizeHelper
14
15
 
15
16
  def initialize(initial_hash = {})
16
17
  initial_hash.map do |key, value|
@@ -62,6 +63,10 @@ module Refinery
62
63
  attr_writer :id, :fallback_html, :hidden
63
64
 
64
65
  def wrap_content_in_tag(content)
66
+ content = sanitize(content,
67
+ tags: Loofah::HTML5::WhiteList::ALLOWED_ELEMENTS,
68
+ attributes: Loofah::HTML5::WhiteList::ALLOWED_ATTRIBUTES
69
+ )
65
70
  content_tag(:section, content_tag(:div, content, :class => 'inner'), :id => id)
66
71
  end
67
72
  end
@@ -4,10 +4,12 @@ module Refinery
4
4
  # a title. These are much like normal sections except they are wrapped in
5
5
  # a h1 tag rather than a div.
6
6
  class TitleSectionPresenter < SectionPresenter
7
+ include ActionView::Helpers::SanitizeHelper
8
+
7
9
  private
8
10
 
9
11
  def wrap_content_in_tag(content)
10
- content_tag(:h1, content, :id => id)
12
+ content_tag(:h1, sanitize(content), :id => id)
11
13
  end
12
14
  end
13
15
  end
@@ -19,7 +19,7 @@
19
19
  <% end %>
20
20
 
21
21
  <span class='title <%= 'toggle' if page.children.present? %>'>
22
- <%= page_title_with_translations page %>
22
+ <%= translated_field(page, :title) %>
23
23
  <%= page_meta_information page %>
24
24
  </span>
25
25
 
data/license.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # MIT License
2
2
 
3
- Copyright (c) 2005 [Resolve Digital](http://resolve.digital)
3
+ Copyright (c) 2005 [Resolve Digital](https://resolve.digital)
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -19,7 +19,7 @@ Gem::Specification.new do |s|
19
19
  s.files = `git ls-files`.split("\n")
20
20
  s.test_files = `git ls-files -- spec/*`.split("\n")
21
21
 
22
- s.add_dependency 'friendly_id', '~> 5.1.0'
22
+ s.add_dependency 'friendly_id', ['>= 5.1.0', '< 5.3']
23
23
  s.add_dependency 'globalize', ['>= 4.0.0', '< 5.2']
24
24
  s.add_dependency 'awesome_nested_set', '~> 3.0.0'
25
25
  s.add_dependency 'seo_meta', '~> 2.0.0.rc.1'
@@ -13,6 +13,15 @@ def expect_window_without_content(content, window: windows.last)
13
13
  end
14
14
  end
15
15
 
16
+ def switch_page_form_locale(locale)
17
+ within "#switch_locale_picker" do
18
+ find("a", text: locale.upcase).click
19
+ end
20
+
21
+ # make sure that the locale change has taken effect
22
+ expect(page).to have_selector("#switch_locale_picker li.selected a##{locale.downcase}")
23
+ end
24
+
16
25
  module Refinery
17
26
  module Admin
18
27
  describe "Pages", :type => :feature do
@@ -99,14 +108,14 @@ module Refinery
99
108
  expect(page).not_to have_content(locations.title)
100
109
  end
101
110
 
102
- it "expands children", :js do
111
+ it "expands children", js: true do
103
112
  find("#page_#{company.id} .title.toggle").click
104
113
 
105
114
  expect(page).to have_content(team.title)
106
115
  expect(page).to have_content(locations.title)
107
116
  end
108
117
 
109
- it "expands children when nested multiple levels deep", :js do
118
+ it "expands children when nested multiple levels deep", js: true do
110
119
  find("#page_#{company.id} .title.toggle").click
111
120
  find("#page_#{locations.id} .title.toggle").click
112
121
 
@@ -149,7 +158,7 @@ module Refinery
149
158
  expect(page.body).to match(%r{href="/my-first-page"})
150
159
  end
151
160
 
152
- it "includes menu title field", :js => true do
161
+ it "includes menu title field", js: true do
153
162
  visit refinery.new_admin_page_path
154
163
 
155
164
  fill_in "Title", :with => "My first page"
@@ -204,7 +213,7 @@ module Refinery
204
213
 
205
214
  context 'when saving and continuing to edit' do
206
215
  before :each do
207
- find('a[tooltip^=Edit]').visible?
216
+ expect(page).to have_selector('a[tooltip^=Edit]', visible: true)
208
217
  find('a[tooltip^=Edit]').click
209
218
 
210
219
  fill_in "Title", :with => "Updated"
@@ -212,13 +221,13 @@ module Refinery
212
221
  find('#flash').visible?
213
222
  end
214
223
 
215
- it "updates page", :js do
224
+ it "updates page", js: true do
216
225
  expect(page).to have_content("'Updated' was successfully updated.")
217
226
  end
218
227
 
219
228
  # Regression test for https://github.com/refinery/refinerycms/issues/1892
220
229
  context 'when saving to exit (a second time)' do
221
- it 'updates page', :js do
230
+ it 'updates page', js: true do
222
231
  find("#submit_button").click
223
232
  expect(page).to have_content("'Updated' was successfully updated.")
224
233
  end
@@ -226,7 +235,7 @@ module Refinery
226
235
  end
227
236
  end
228
237
 
229
- describe 'Previewing', :js do
238
+ describe 'Previewing', js: true do
230
239
  let(:preview_content) { "Some changes I'm unsure what they will look like".freeze }
231
240
  context "an existing page" do
232
241
  before { Page.create :title => 'Preview me' }
@@ -466,7 +475,7 @@ module Refinery
466
475
  end
467
476
  end
468
477
 
469
- describe "a page with two locales", js:true do
478
+ describe "a page with two locales" do
470
479
  let(:en_page_title) { 'News' }
471
480
  let(:en_page_slug) { 'news' }
472
481
  let(:ru_page_title) { 'Новости' }
@@ -489,19 +498,18 @@ module Refinery
489
498
  news_page.destroy!
490
499
  visit refinery.admin_pages_path
491
500
 
492
- find('a', text:"Add new page").trigger(:click)
493
- within "#switch_locale_picker" do
494
- find('a', text: "RU").trigger(:click)
495
- end
501
+ click_link "Add new page"
502
+ switch_page_form_locale "RU"
503
+
496
504
  fill_in "Title", :with => ru_page_title
497
505
  click_button "Save"
506
+ expect(page).to have_selector("#page_#{Page.last.id} .actions")
498
507
 
499
508
  within "#page_#{Page.last.id} .actions" do
500
509
  find("a[href^='/#{Refinery::Core.backend_route}/pages/#{ru_page_slug_encoded}/edit']").click
501
510
  end
502
- within "#switch_locale_picker" do
503
- find('a', text: "EN").trigger(:click)
504
- end
511
+
512
+ switch_page_form_locale "EN"
505
513
  fill_in "Title", :with => en_page_title
506
514
  find("#submit_button").click
507
515
 
@@ -527,7 +535,7 @@ module Refinery
527
535
  end
528
536
  end
529
537
 
530
- it "uses the slug from the default locale in admin" do
538
+ it "uses the slug from the default locale in admin", js: true do
531
539
  visit refinery.admin_pages_path
532
540
 
533
541
  within "#page_#{news_page.id}" do
@@ -570,9 +578,8 @@ module Refinery
570
578
  it "lets you add a Russian title without an English title" do
571
579
  ru_page.destroy!
572
580
  find('a', text: 'Add new page').trigger(:click)
573
- within "#switch_locale_picker" do
574
- find('a', text: "RU").trigger(:click)
575
- end
581
+ switch_page_form_locale "RU"
582
+
576
583
  fill_in "Title", :with => ru_page_title
577
584
  click_button "Save"
578
585
 
@@ -622,7 +629,7 @@ module Refinery
622
629
  end
623
630
  end
624
631
 
625
- context "when page is a child page", js: true do
632
+ context "when page is a child page" do
626
633
  it 'succeeds' do
627
634
  ru_page.destroy!
628
635
  parent_page = Page.create(:title => "Parent page")
@@ -642,12 +649,12 @@ module Refinery
642
649
  end
643
650
  end
644
651
 
645
- describe "new page part", :js do
652
+ describe "new page part" do
646
653
  before do
647
654
  allow(Refinery::Pages).to receive(:new_page_parts).and_return(true)
648
655
  end
649
656
 
650
- it "adds new page part" do
657
+ it "adds new page part", js: true do
651
658
  visit refinery.new_admin_page_path
652
659
  find("#add_page_part").trigger(:click)
653
660
 
@@ -662,7 +669,7 @@ module Refinery
662
669
  end
663
670
  end
664
671
 
665
- describe "delete existing page part", :js do
672
+ describe "delete existing page part" do
666
673
  let!(:some_page) { Page.create! :title => "Some Page" }
667
674
 
668
675
  before do
@@ -673,7 +680,7 @@ module Refinery
673
680
  allow(Refinery::Pages).to receive(:new_page_parts).and_return(true)
674
681
  end
675
682
 
676
- it "deletes page parts" do
683
+ it "deletes page parts", js: true do
677
684
  visit refinery.edit_admin_page_path(some_page.id)
678
685
 
679
686
  within "#page_parts" do
@@ -721,7 +728,7 @@ module Refinery
721
728
  @page = parent_page.children.create :title => 'Child Page'
722
729
  end
723
730
 
724
- specify 'sub page should inherit them', :js => true do
731
+ specify 'sub page should inherit them', js: true do
725
732
  visit refinery.edit_admin_page_path(@page.id)
726
733
 
727
734
  find('#toggle_advanced_options').trigger(:click)
@@ -739,7 +746,7 @@ module Refinery
739
746
  end
740
747
 
741
748
  # regression spec for https://github.com/refinery/refinerycms/issues/1891
742
- describe "a page part with HTML", js:true do
749
+ describe "a page part with HTML" do
743
750
  before do
744
751
  page = Refinery::Page.create! :title => "test"
745
752
  Refinery::Pages.default_parts.each_with_index do |default_page_part, index|
@@ -752,7 +759,7 @@ module Refinery
752
759
  end
753
760
  end
754
761
 
755
- specify "should retain the html" do
762
+ specify "should retain the html", js:true do
756
763
  visit refinery.admin_pages_path
757
764
  find('a[tooltip="Edit this page"]').trigger(:click)
758
765
  Capybara.ignore_hidden_elements = false
@@ -766,7 +773,7 @@ module Refinery
766
773
  before { Globalize.locale = :en }
767
774
  refinery_login
768
775
 
769
- describe "a page with a single locale", js: true do
776
+ describe "a page with a single locale" do
770
777
  before do
771
778
  allow(Refinery::I18n).to receive(:frontend_locales).and_return([:en, :lv])
772
779
  Page.create :title => 'First Page'
@@ -775,11 +782,9 @@ module Refinery
775
782
  it "can have a second locale added to it" do
776
783
  visit refinery.admin_pages_path
777
784
 
778
- find('a', text: 'Add new page').trigger(:click)
785
+ click_link "Add new page"
786
+ switch_page_form_locale "LV"
779
787
 
780
- within "#switch_locale_picker" do
781
- find('a', text: "LV").trigger(:click)
782
- end
783
788
  fill_in "Title", :with => "Brīva vieta reklāmai"
784
789
  click_button "Save"
785
790
 
@@ -73,35 +73,6 @@ module Refinery
73
73
  end
74
74
  end
75
75
  end
76
-
77
- describe "#page_title_with_translations" do
78
- let(:page) { FactoryGirl.build(:page) }
79
-
80
- before do
81
- Globalize.with_locale(:en) do
82
- page.title = "draft"
83
- page.save!
84
- end
85
-
86
- Globalize.with_locale(:lv) do
87
- page.title = "melnraksts"
88
- page.save!
89
- end
90
- end
91
-
92
- context "when title is present" do
93
- it "returns it" do
94
- expect(helper.page_title_with_translations(page)).to eq("draft")
95
- end
96
- end
97
-
98
- context "when title for current locale isn't available" do
99
- it "returns existing title from translations" do
100
- Page.translation_class.where(:locale => :en).first.destroy
101
- expect(helper.page_title_with_translations(page)).to eq("melnraksts")
102
- end
103
- end
104
- end
105
76
  end
106
77
  end
107
78
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: refinerycms-pages
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.1
4
+ version: 3.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Philip Arndt
@@ -10,22 +10,28 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2016-01-27 00:00:00.000000000 Z
13
+ date: 2016-03-16 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: friendly_id
17
17
  requirement: !ruby/object:Gem::Requirement
18
18
  requirements:
19
- - - "~>"
19
+ - - ">="
20
20
  - !ruby/object:Gem::Version
21
21
  version: 5.1.0
22
+ - - "<"
23
+ - !ruby/object:Gem::Version
24
+ version: '5.3'
22
25
  type: :runtime
23
26
  prerelease: false
24
27
  version_requirements: !ruby/object:Gem::Requirement
25
28
  requirements:
26
- - - "~>"
29
+ - - ">="
27
30
  - !ruby/object:Gem::Version
28
31
  version: 5.1.0
32
+ - - "<"
33
+ - !ruby/object:Gem::Version
34
+ version: '5.3'
29
35
  - !ruby/object:Gem::Dependency
30
36
  name: globalize
31
37
  requirement: !ruby/object:Gem::Requirement
@@ -80,14 +86,14 @@ dependencies:
80
86
  requirements:
81
87
  - - '='
82
88
  - !ruby/object:Gem::Version
83
- version: 3.0.1
89
+ version: 3.0.2
84
90
  type: :runtime
85
91
  prerelease: false
86
92
  version_requirements: !ruby/object:Gem::Requirement
87
93
  requirements:
88
94
  - - '='
89
95
  - !ruby/object:Gem::Version
90
- version: 3.0.1
96
+ version: 3.0.2
91
97
  - !ruby/object:Gem::Dependency
92
98
  name: babosa
93
99
  requirement: !ruby/object:Gem::Requirement