liquid_cms 0.2.0.4 → 0.2.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +3 -13
- data/app/controllers/cms/pages_controller.rb +0 -21
- data/app/liquid/cms_paperclip_extension.rb +2 -2
- data/generators/liquid_cms/liquid_cms_generator.rb +1 -1
- data/lib/liquid_cms.rb +0 -1
- data/lib/liquid_cms/configuration.rb +0 -3
- data/lib/liquid_cms/context.rb +1 -1
- data/lib/liquid_cms/version.rb +1 -1
- data/test/factories/company.rb +1 -1
- data/test/integration/pages_test.rb +0 -46
- data/test/test_helper.rb +0 -6
- data/test/test_helpers/login_methods.rb +1 -0
- metadata +3 -3
data/Rakefile
CHANGED
@@ -7,23 +7,13 @@ require 'rake/testtask'
|
|
7
7
|
desc 'Default: run tests.'
|
8
8
|
task :default => :test
|
9
9
|
|
10
|
-
test_types = %w(unit functional integration)
|
11
|
-
|
12
10
|
desc 'Test the liquid_cms gem.'
|
13
|
-
task :test =>
|
11
|
+
task :test => ['test:unit', 'test:functional', 'test:integration']
|
14
12
|
|
15
|
-
|
16
|
-
desc "Run the #{test} tests for the liquid_cms gem"
|
13
|
+
%w(unit functional integration).each do |test|
|
14
|
+
desc "Run the #{test} tests for the liquid_cms gem."
|
17
15
|
Rake::TestTask.new("test:#{test}") do |t|
|
18
16
|
t.pattern = "test/#{test}/*_test.rb"
|
19
17
|
t.verbose = true
|
20
18
|
end
|
21
19
|
end
|
22
|
-
|
23
|
-
test_types.each do |test|
|
24
|
-
desc "Run the #{test} tests for the liquid_cms gem (no context)"
|
25
|
-
Rake::TestTask.new("test:#{test}:no_context") do |t|
|
26
|
-
t.pattern = "test/#{test}/*_test_no_context.rb"
|
27
|
-
t.verbose = true
|
28
|
-
end
|
29
|
-
end
|
@@ -1,11 +1,6 @@
|
|
1
1
|
class Cms::PagesController < Cms::MainController
|
2
2
|
skip_before_filter :verify_authenticity_token, :only => [:load, :page_asset]
|
3
3
|
|
4
|
-
caches_action :load, :cache_path => :cache_value
|
5
|
-
#caches_action :page_asset, :cache_path => :cache_value
|
6
|
-
|
7
|
-
cache_sweeper Cms::CacheSweeper, :only => %w(update destroy)
|
8
|
-
|
9
4
|
authenticate_user :all, :except => %w(load page_asset)
|
10
5
|
|
11
6
|
def new
|
@@ -91,23 +86,7 @@ class Cms::PagesController < Cms::MainController
|
|
91
86
|
end
|
92
87
|
|
93
88
|
protected
|
94
|
-
# the current url with the last level of the path removed which essentially allows a page to be loaded with anything (wilcard) one level deeper
|
95
|
-
# ex. normal page at /page will also accept /page/test, /page/abcd, etc.
|
96
89
|
def wildcard_path
|
97
90
|
'/'+params[:url].slice(0..-2).join('/')
|
98
91
|
end
|
99
|
-
|
100
|
-
def cache_value_url
|
101
|
-
extra_params = params.except(:controller, :action, :url)
|
102
|
-
|
103
|
-
# sort the parameters so we can have the same url if the params are given to us in a different order
|
104
|
-
extra_values = extra_params.present? ? extra_params.sort{|a,b| a.first <=> b.first}.collect{|elem| "#{elem[0]}=#{elem[1]}"}.join('&') : nil
|
105
|
-
|
106
|
-
[context_cache_path, params[:url], extra_values].flatten.compact.join('/')
|
107
|
-
end
|
108
|
-
|
109
|
-
# a unique string used to help expire the cache
|
110
|
-
def context_cache_path
|
111
|
-
Cms.context_class && @cms_context.present? ? "CONTEXT_PATH_#{@cms_context.id}" : 'NO_CONTEXT'
|
112
|
-
end
|
113
92
|
end
|
@@ -6,8 +6,8 @@ module Paperclip
|
|
6
6
|
{}.tap do |h|
|
7
7
|
all_styles = self.styles.keys + ['original']
|
8
8
|
all_styles.each do |style|
|
9
|
-
g = Paperclip::Geometry.from_file(self.path(style))
|
10
|
-
h[style] = {'width' => g.width.to_i, 'height' => g.height.to_i, 'url' => self.url(style)}
|
9
|
+
g = Paperclip::Geometry.from_file(self.path(style))
|
10
|
+
h[style] = {'width' => g.width.to_i, 'height' => g.height.to_i, 'url' => self.url(style)}
|
11
11
|
end
|
12
12
|
end
|
13
13
|
end
|
data/lib/liquid_cms.rb
CHANGED
@@ -9,8 +9,6 @@ module Cms
|
|
9
9
|
mattr_reader :context_class
|
10
10
|
def self.context_class=(klass)
|
11
11
|
@@context_class = klass
|
12
|
-
return if klass.nil? || ENV['NO_CONTEXT'] == 'true'
|
13
|
-
|
14
12
|
Dispatcher.to_prepare {
|
15
13
|
eval(klass.to_s).extend Cms::ContextAssociation
|
16
14
|
|
@@ -21,7 +19,6 @@ module Cms
|
|
21
19
|
@@context_class = nil
|
22
20
|
|
23
21
|
def self.set_context(context, bind_to)
|
24
|
-
return if @@context_class.nil?
|
25
22
|
bind_to.instance_variable_set :@cms_context, context
|
26
23
|
end
|
27
24
|
|
data/lib/liquid_cms/context.rb
CHANGED
data/lib/liquid_cms/version.rb
CHANGED
data/test/factories/company.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/../test_helper'
|
2
|
-
require File.dirname(__FILE__) + '/../test_helpers/cache_helper'
|
3
2
|
|
4
3
|
class Cms::PagesTest < ActionController::IntegrationTest
|
5
4
|
|
@@ -280,49 +279,4 @@ class Cms::PagesTest < ActionController::IntegrationTest
|
|
280
279
|
assert_response 404
|
281
280
|
end
|
282
281
|
end
|
283
|
-
|
284
|
-
context "caching" do
|
285
|
-
setup do
|
286
|
-
ActionController::Base.perform_caching = true
|
287
|
-
Rails.cache.clear
|
288
|
-
@page = Factory(:page, :context => @company)
|
289
|
-
end
|
290
|
-
|
291
|
-
teardown do
|
292
|
-
ActionController::Base.perform_caching = false
|
293
|
-
end
|
294
|
-
|
295
|
-
should "expire the cache when the page is updated" do
|
296
|
-
assert_cache_empty
|
297
|
-
|
298
|
-
get @page.url
|
299
|
-
assert_cache_present
|
300
|
-
|
301
|
-
# updating the page will remove the cache
|
302
|
-
put cms_page_path(@page), :content => 'new content'
|
303
|
-
assert_cache_empty
|
304
|
-
|
305
|
-
get @page.url
|
306
|
-
assert_cache_present
|
307
|
-
|
308
|
-
# destroying the page will remove the cache
|
309
|
-
delete cms_page_path(@page)
|
310
|
-
assert_cache_empty
|
311
|
-
end
|
312
|
-
|
313
|
-
should "generate a cache key" do
|
314
|
-
get '/'
|
315
|
-
assert_cache_key "views/CONTEXT_PATH_#{@company.id}"
|
316
|
-
|
317
|
-
get @page.url
|
318
|
-
assert_cache_key "views/CONTEXT_PATH_#{@company.id}/page"
|
319
|
-
|
320
|
-
get @page.url+'?page=1&test=abcde'
|
321
|
-
assert_cache_key "views/CONTEXT_PATH_#{@company.id}/page/page=1&test=abcde"
|
322
|
-
|
323
|
-
# different order sent via url, but the path params will be sorted in the path
|
324
|
-
get @page.url+'?test=abcde&page=1'
|
325
|
-
assert_cache_key "views/CONTEXT_PATH_#{@company.id}/page/page=1&test=abcde"
|
326
|
-
end
|
327
|
-
end
|
328
282
|
end
|
data/test/test_helper.rb
CHANGED
@@ -5,12 +5,6 @@ $:.unshift File.dirname(__FILE__)
|
|
5
5
|
require "rails_app/config/environment"
|
6
6
|
require 'test_help'
|
7
7
|
|
8
|
-
if ENV['NO_CONTEXT'] == 'true'
|
9
|
-
Cms.setup do |config|
|
10
|
-
config.context_class = nil
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
8
|
ActiveRecord::Migration.verbose = false
|
15
9
|
ActiveRecord::Base.logger = Logger.new(nil)
|
16
10
|
ActiveRecord::Base.establish_connection(:adapter => "sqlite3", :database => ":memory:")
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: liquid_cms
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 85
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
9
|
- 0
|
10
|
-
-
|
11
|
-
version: 0.2.0.
|
10
|
+
- 5
|
11
|
+
version: 0.2.0.5
|
12
12
|
platform: ruby
|
13
13
|
authors:
|
14
14
|
- Andrew Kaspick
|