alchemy_cms 3.0.3 → 3.0.4

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: cda5be7267deaae5e113d0a626d74d6f3a18c269
4
- data.tar.gz: 04e31e50bc6f7d66932cc15dcbee595a2a15eebe
3
+ metadata.gz: 4a98f349ff1159991c93354c2cd40b77793ade10
4
+ data.tar.gz: a7378076e929a7fe8f80fc59256041260f3ff7dd
5
5
  SHA512:
6
- metadata.gz: 20760cb152ca71cfc3180bb3afd08d3ed3390e6e9cac648c78135c6bf85bf3c67655ed75423c9c7685af69f70d8f6ac7e012d5667aa60d8da53646487f815c10
7
- data.tar.gz: 79f024717ee68637c13f7eaee22af24f387b0d03c6eb131b5938e1f24e339788a2979599725dec6fc89496d803eab6c5841c60dc95119516a6676763d0a9ab9e
6
+ metadata.gz: 081d537f1cc0a4528039e2466885fbe41b072f24131d08f4757cca4e91bafa6867c6ee4b255d90db5a3fb0b07f12f4c02714d4b4c6b5915781b652ab81c7e4f8
7
+ data.tar.gz: eea901691a4b7351154098e8ff0f8635b3233381e20529ef284d463213fab9b2b9a224f78183a83fb9924df9505844c3a8a3ada02451c326b04be525df54f5c8
data/.travis.yml CHANGED
@@ -13,7 +13,7 @@ script: 'bundle exec rspec'
13
13
  env:
14
14
  - DB=mysql
15
15
  - DB=postgresql
16
- - RAILS_VERSION=4.0.12
16
+ - RAILS_VERSION=4.0.13
17
17
  notifications:
18
18
  irc:
19
19
  on_success: change
@@ -421,6 +421,20 @@ module Alchemy
421
421
  "alchemy/elements/#{name}_view"
422
422
  end
423
423
 
424
+ # Returns the key that's taken for cache path.
425
+ #
426
+ # Uses the page's +published_at+ value that's updated when the user publishes the page.
427
+ #
428
+ # If the page is the current preview it uses the element's updated_at value as cache key.
429
+ #
430
+ def cache_key
431
+ if Page.current_preview == self.page
432
+ "alchemy/elements/#{id}-#{updated_at}"
433
+ else
434
+ "alchemy/elements/#{id}-#{page.published_at}"
435
+ end
436
+ end
437
+
424
438
  private
425
439
 
426
440
  # creates the contents for this element as described in the elements.yml
@@ -70,15 +70,15 @@
70
70
  <% end %>
71
71
  <label><%= _t(:page_properties) %></label>
72
72
  </div>
73
- <% if configuration(:cache_pages) && !@page.layoutpage? %>
74
- <div class="button_with_label">
75
- <%= form_tag alchemy.publish_admin_page_path(@page), id: 'publish_page_form' do %>
76
- <button class="icon_button" title="<%= _t(:explain_publishing) %>">
77
- <%= render_icon('publish') %>
78
- </button>
79
- <label><%= _t("Publish page") %></label>
80
- <% end %>
81
- </div>
73
+ <% if can?(:publish, @page) && !@page.layoutpage? %>
74
+ <div class="button_with_label">
75
+ <%= form_tag alchemy.publish_admin_page_path(@page), id: 'publish_page_form' do %>
76
+ <%= button_tag class: 'icon_button', title: _t(:explain_publishing) do %>
77
+ <%= render_icon('publish') %>
78
+ <% end %>
79
+ <label><%= _t("Publish page") %></label>
80
+ <% end %>
81
+ </div>
82
82
  <% end %>
83
83
  <div class="toolbar_spacer"></div>
84
84
  <div class="select_with_label">
@@ -130,6 +130,7 @@ module Alchemy
130
130
  :destroy,
131
131
  :flush,
132
132
  :order,
133
+ :publish,
133
134
  :sort,
134
135
  :switch_language
135
136
  ], Alchemy::Page
@@ -182,7 +183,6 @@ module Alchemy
182
183
  :fold,
183
184
  :info,
184
185
  :link,
185
- :publish,
186
186
  :read,
187
187
  :update,
188
188
  :unlock,
@@ -1,5 +1,5 @@
1
1
  module Alchemy
2
- VERSION = "3.0.3"
2
+ VERSION = "3.0.4"
3
3
 
4
4
  def self.version
5
5
  VERSION
@@ -1,6 +1,6 @@
1
1
  # This rails template installs Alchemy and all depending gems.
2
2
  require File.expand_path('../../../alchemy/version', __FILE__)
3
3
 
4
- gem 'alchemy_cms', github: 'magiclabs/alchemy_cms', branch: 'master'
5
- gem 'alchemy-devise', github: 'magiclabs/alchemy-devise', branch: 'master'
4
+ gem 'alchemy_cms', github: 'magiclabs/alchemy_cms', branch: '3.0-stable'
5
+ gem 'alchemy-devise', github: 'magiclabs/alchemy-devise', branch: '2.0-stable'
6
6
  gem 'capistrano', '~> 2.15.5', group: 'development'
@@ -4,4 +4,8 @@ class DummyUser < ActiveRecord::Base
4
4
  def self.logged_in
5
5
  []
6
6
  end
7
+
8
+ def alchemy_roles
9
+ @alchemy_roles || %w(admin)
10
+ end
7
11
  end
@@ -18,7 +18,6 @@ module Dummy
18
18
  # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
19
19
  # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
20
20
  # config.i18n.default_locale = :de
21
-
22
- I18n.enforce_available_locales = true
21
+ config.i18n.enforce_available_locales = false
23
22
  end
24
23
  end
@@ -33,6 +33,4 @@ Dummy::Application.configure do
33
33
 
34
34
  # Print deprecation notices to the stderr.
35
35
  config.active_support.deprecation = :stderr
36
-
37
- I18n.enforce_available_locales = false
38
36
  end
@@ -1,75 +1,107 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe 'Page editing feature' do
4
- let(:a_page) { FactoryGirl.create(:public_page, visible: true) }
4
+ let(:a_page) { create(:page) }
5
5
 
6
- before { authorize_as_admin }
6
+ context 'as author' do
7
+ before { authorize_as_admin(build(:author_user)) }
7
8
 
8
- context "in configure overlay" do
9
+ it 'cannot publish page.' do
10
+ visit alchemy.edit_admin_page_path(a_page)
11
+ expect(page).to_not have_selector('#publish_page_form')
12
+ end
13
+ end
14
+
15
+ context 'as editor' do
16
+ before { authorize_as_admin(build(:editor_user)) }
17
+
18
+ it 'can publish page.' do
19
+ visit alchemy.edit_admin_page_path(a_page)
20
+ find('#publish_page_form button').click
21
+ expect(page).to have_content Alchemy::I18n.t(:page_published, name: a_page.name)
22
+ end
23
+
24
+ context 'while editing a global page' do
25
+ let(:a_page) { create(:page, layoutpage: true) }
9
26
 
10
- context "when editing a normal page" do
11
- it "should show all relevant input fields" do
12
- visit alchemy.configure_admin_page_path(a_page)
13
- expect(page).to have_selector('input#page_urlname')
14
- expect(page).to have_selector('input#page_title')
15
- expect(page).to have_selector('input#page_robot_index')
16
- expect(page).to have_selector('input#page_robot_follow')
27
+ it 'cannot publish page.' do
28
+ visit alchemy.edit_admin_page_path(a_page)
29
+ expect(page).to_not have_selector('#publish_page_form')
17
30
  end
31
+ end
32
+ end
18
33
 
19
- context "with sitemaps show_flag config option set to true" do
20
- before do
21
- Alchemy::Config.stub(:get) { |arg| arg == :sitemap ? {'show_flag' => true} : Alchemy::Config.show[arg.to_s] }
22
- end
34
+ context 'as admin' do
35
+ let(:a_page) { FactoryGirl.create(:public_page, visible: true) }
23
36
 
24
- it "should show sitemap checkbox" do
37
+ before { authorize_as_admin }
38
+
39
+ context "in configure overlay" do
40
+ context "when editing a normal page" do
41
+ it "should show all relevant input fields" do
25
42
  visit alchemy.configure_admin_page_path(a_page)
26
- expect(page).to have_selector('input[type="checkbox"]#page_sitemap')
43
+ expect(page).to have_selector('input#page_urlname')
44
+ expect(page).to have_selector('input#page_title')
45
+ expect(page).to have_selector('input#page_robot_index')
46
+ expect(page).to have_selector('input#page_robot_follow')
27
47
  end
28
- end
29
48
 
30
- context "with sitemaps show_flag config option set to false" do
31
- before do
32
- Alchemy::Config.stub(:get) { |arg| arg == :sitemap ? {'show_flag' => false} : Alchemy::Config.show[arg.to_s] }
49
+ context "with sitemaps show_flag config option set to true" do
50
+ before do
51
+ Alchemy::Config.stub(:get) { |arg| arg == :sitemap ? {'show_flag' => true} : Alchemy::Config.show[arg.to_s] }
52
+ end
53
+
54
+ it "should show sitemap checkbox" do
55
+ visit alchemy.configure_admin_page_path(a_page)
56
+ expect(page).to have_selector('input[type="checkbox"]#page_sitemap')
57
+ end
33
58
  end
34
59
 
35
- it "should show sitemap checkbox" do
36
- visit alchemy.configure_admin_page_path(a_page)
37
- expect(page).to_not have_selector('input[type="checkbox"]#page_sitemap')
60
+ context "with sitemaps show_flag config option set to false" do
61
+ before do
62
+ Alchemy::Config.stub(:get) { |arg| arg == :sitemap ? {'show_flag' => false} : Alchemy::Config.show[arg.to_s] }
63
+ end
64
+
65
+ it "should show sitemap checkbox" do
66
+ visit alchemy.configure_admin_page_path(a_page)
67
+ expect(page).to_not have_selector('input[type="checkbox"]#page_sitemap')
68
+ end
38
69
  end
39
70
  end
40
- end
41
71
 
42
- context "when editing a global page" do
43
- let(:layout_page) { FactoryGirl.create(:page, layoutpage: true) }
72
+ context "when editing a global page" do
73
+ let(:layout_page) { FactoryGirl.create(:page, layoutpage: true) }
44
74
 
45
- it "should not show the input fields for normal pages" do
46
- visit alchemy.edit_admin_layoutpage_path(layout_page)
47
- expect(page).to_not have_selector('input#page_urlname')
48
- expect(page).to_not have_selector('input#page_title')
49
- expect(page).to_not have_selector('input#page_robot_index')
50
- expect(page).to_not have_selector('input#page_robot_follow')
75
+ it "should not show the input fields for normal pages" do
76
+ visit alchemy.edit_admin_layoutpage_path(layout_page)
77
+ expect(page).to_not have_selector('input#page_urlname')
78
+ expect(page).to_not have_selector('input#page_title')
79
+ expect(page).to_not have_selector('input#page_robot_index')
80
+ expect(page).to_not have_selector('input#page_robot_follow')
81
+ end
51
82
  end
52
- end
53
83
 
54
- context "when page is taggable" do
55
- before { Alchemy::Page.any_instance.stub(:taggable?).and_return(true) }
56
- it "should show the tag_list input field" do
57
- visit alchemy.configure_admin_page_path(a_page)
58
- expect(page).to have_selector('input#page_tag_list')
84
+ context "when page is taggable" do
85
+ before { Alchemy::Page.any_instance.stub(:taggable?).and_return(true) }
86
+
87
+ it "should show the tag_list input field" do
88
+ visit alchemy.configure_admin_page_path(a_page)
89
+ expect(page).to have_selector('input#page_tag_list')
90
+ end
59
91
  end
60
92
  end
61
- end
62
93
 
63
- context "in preview frame" do
64
- it "the menubar does not render on the page" do
65
- visit alchemy.admin_page_path(a_page)
66
- page.should_not have_selector('#alchemy_menubar')
67
- end
94
+ context "in preview frame" do
95
+ it "the menubar does not render on the page" do
96
+ visit alchemy.admin_page_path(a_page)
97
+ page.should_not have_selector('#alchemy_menubar')
98
+ end
68
99
 
69
- it "navigation links are not clickable" do
70
- visit alchemy.admin_page_path(a_page)
71
- within('#navigation') do
72
- page.should have_selector('a[href="javascript: void(0)"]')
100
+ it "navigation links are not clickable" do
101
+ visit alchemy.admin_page_path(a_page)
102
+ within('#navigation') do
103
+ page.should have_selector('a[href="javascript: void(0)"]')
104
+ end
73
105
  end
74
106
  end
75
107
  end
@@ -122,7 +122,10 @@ describe Alchemy::Permissions do
122
122
  should be_able_to(:link, Alchemy::Page)
123
123
  should be_able_to(:visit, Alchemy::Page)
124
124
  should be_able_to(:unlock, Alchemy::Page)
125
- should be_able_to(:publish, Alchemy::Page)
125
+ end
126
+
127
+ it "can not publish pages" do
128
+ should_not be_able_to(:publish, Alchemy::Page)
126
129
  end
127
130
 
128
131
  it "can manage elements" do
@@ -180,6 +183,10 @@ describe Alchemy::Permissions do
180
183
  should be_able_to(:switch_language, Alchemy::Page)
181
184
  end
182
185
 
186
+ it "can publish pages" do
187
+ should be_able_to(:publish, Alchemy::Page)
188
+ end
189
+
183
190
  it "can not see invisible pages" do
184
191
  should_not be_able_to(:see, not_visible_page)
185
192
  end
@@ -538,6 +538,29 @@ module Alchemy
538
538
  end
539
539
  end
540
540
 
541
+ describe '#cache_key' do
542
+ let(:page) { stub_model(Page, published_at: Time.now - 1.week) }
543
+ let(:element) { stub_model(Element, page: page, updated_at: Time.now) }
544
+
545
+ subject { element.cache_key }
546
+
547
+ before do
548
+ expect(Page).to receive(:current_preview).and_return(preview)
549
+ end
550
+
551
+ context "when current page rendered in preview mode" do
552
+ let(:preview) { page }
553
+
554
+ it { is_expected.to eq("alchemy/elements/#{element.id}-#{element.updated_at}") }
555
+ end
556
+
557
+ context "when current page not in preview mode" do
558
+ let(:preview) { nil }
559
+
560
+ it { is_expected.to eq("alchemy/elements/#{element.id}-#{page.published_at}") }
561
+ end
562
+ end
563
+
541
564
  it_behaves_like "having a hint" do
542
565
  let(:subject) { Element.new }
543
566
  end
@@ -715,9 +715,27 @@ module Alchemy
715
715
  end
716
716
 
717
717
  describe '#cache_key' do
718
- let(:page) { stub_model(Page) }
719
- subject { page }
720
- its(:cache_key) { should match(page.id.to_s) }
718
+ let(:page) do
719
+ stub_model(Page, updated_at: Time.now, published_at: Time.now - 1.week)
720
+ end
721
+
722
+ subject { page.cache_key }
723
+
724
+ before do
725
+ expect(Page).to receive(:current_preview).and_return(preview)
726
+ end
727
+
728
+ context "when current page rendered in preview mode" do
729
+ let(:preview) { page }
730
+
731
+ it { is_expected.to eq("alchemy/pages/#{page.id}-#{page.updated_at}") }
732
+ end
733
+
734
+ context "when current page not in preview mode" do
735
+ let(:preview) { nil }
736
+
737
+ it { is_expected.to eq("alchemy/pages/#{page.id}-#{page.published_at}") }
738
+ end
721
739
  end
722
740
 
723
741
  describe '#cell_definitions' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: alchemy_cms
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.3
4
+ version: 3.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thomas von Deyen
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2014-12-24 00:00:00.000000000 Z
15
+ date: 2015-03-17 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: rails
@@ -1154,7 +1154,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
1154
1154
  requirements:
1155
1155
  - ImageMagick (libmagick), v6.6 or greater.
1156
1156
  rubyforge_project:
1157
- rubygems_version: 2.4.5
1157
+ rubygems_version: 2.4.3
1158
1158
  signing_key:
1159
1159
  specification_version: 4
1160
1160
  summary: A powerful, userfriendly and flexible CMS for Rails 4