locomotivecms_steam 1.0.0.rc8 → 1.0.0.rc9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +6 -6
- data/lib/locomotive/steam/adapters/memory/condition.rb +1 -1
- data/lib/locomotive/steam/entities/content_entry.rb +1 -2
- data/lib/locomotive/steam/entities/site.rb +3 -1
- data/lib/locomotive/steam/liquid/drops/content_entry.rb +7 -1
- data/lib/locomotive/steam/liquid/drops/content_entry_collection.rb +2 -1
- data/lib/locomotive/steam/liquid/drops/site.rb +1 -1
- data/lib/locomotive/steam/liquid/filters/base.rb +4 -4
- data/lib/locomotive/steam/liquid/filters/pagination.rb +6 -2
- data/lib/locomotive/steam/liquid/tags/with_scope.rb +1 -0
- data/lib/locomotive/steam/middlewares/private_access.rb +79 -0
- data/lib/locomotive/steam/middlewares/renderer.rb +2 -1
- data/lib/locomotive/steam/models/i18n_field.rb +10 -1
- data/lib/locomotive/steam/repositories/content_entry_repository.rb +4 -1
- data/lib/locomotive/steam/server.rb +1 -0
- data/lib/locomotive/steam/services/page_finder_service.rb +4 -2
- data/lib/locomotive/steam/version.rb +1 -1
- data/spec/spec_helper.rb +2 -3
- data/spec/unit/entities/content_entry_spec.rb +5 -0
- data/spec/unit/liquid/drops/content_entry_collection_spec.rb +20 -2
- data/spec/unit/liquid/drops/content_entry_spec.rb +26 -0
- data/spec/unit/liquid/drops/site_spec.rb +6 -0
- data/spec/unit/liquid/filters/base_spec.rb +31 -0
- data/spec/unit/liquid/tags/with_scope_spec.rb +9 -0
- data/spec/unit/middlewares/private_access_spec.rb +103 -0
- data/spec/unit/repositories/content_entry_repository_spec.rb +7 -0
- metadata +8 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e1d5af761258aca259b67088438e3e79272ead4e
|
4
|
+
data.tar.gz: 1d6e1ec7dbf6bef557662bf314261f237c17dc03
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b1e9bcd2e5a5c89943ea36c582f0dc023c47e5ae6d89b1428a041fe70f591cb7809b65ed57f839205d983e70bbef361dd0382210ede9172331c16f56d0dfc091
|
7
|
+
data.tar.gz: 9937c436f582495e9bf5d8363961c1f8f2944621641a70a39c064d280423e8200d339b9a9830f91e9d2accfe09a1a52dd8c14f07fe376fb8a9f4664a8ee1fb3a
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
locomotivecms_steam (1.0.0.
|
4
|
+
locomotivecms_steam (1.0.0.rc9)
|
5
5
|
RedCloth (~> 4.2.9)
|
6
6
|
chronic (~> 0.10.2)
|
7
7
|
coffee-script (~> 2.4.1)
|
@@ -37,7 +37,7 @@ GEM
|
|
37
37
|
minitest (~> 5.1)
|
38
38
|
thread_safe (~> 0.3, >= 0.3.4)
|
39
39
|
tzinfo (~> 1.1)
|
40
|
-
addressable (2.
|
40
|
+
addressable (2.4.0)
|
41
41
|
attr_extras (4.4.0)
|
42
42
|
bson (3.2.6)
|
43
43
|
byebug (4.0.5)
|
@@ -132,7 +132,7 @@ GEM
|
|
132
132
|
netrc (0.11.0)
|
133
133
|
nokogiri (1.6.6.4)
|
134
134
|
mini_portile (~> 0.6.0)
|
135
|
-
nokogumbo (1.4.
|
135
|
+
nokogumbo (1.4.6)
|
136
136
|
nokogiri
|
137
137
|
origin (2.1.1)
|
138
138
|
pry (0.10.3)
|
@@ -176,11 +176,11 @@ GEM
|
|
176
176
|
diff-lcs (>= 1.2.0, < 2.0)
|
177
177
|
rspec-support (~> 3.3.0)
|
178
178
|
rspec-support (3.3.0)
|
179
|
-
sanitize (4.0.
|
179
|
+
sanitize (4.0.1)
|
180
180
|
crass (~> 1.0.2)
|
181
181
|
nokogiri (>= 1.4.4)
|
182
|
-
nokogumbo (
|
183
|
-
sass (3.4.
|
182
|
+
nokogumbo (~> 1.4.1)
|
183
|
+
sass (3.4.20)
|
184
184
|
simplecov (0.11.1)
|
185
185
|
docile (~> 1.1.0)
|
186
186
|
json (~> 1.8)
|
@@ -156,8 +156,7 @@ module Locomotive::Steam
|
|
156
156
|
|
157
157
|
def _cast_convertor(name, &block)
|
158
158
|
if (value = attributes[name]).respond_to?(:translations)
|
159
|
-
value.
|
160
|
-
value
|
159
|
+
value.apply(&block)
|
161
160
|
else
|
162
161
|
yield(value)
|
163
162
|
end
|
@@ -50,7 +50,7 @@ module Locomotive
|
|
50
50
|
return '' if @_source.nil?
|
51
51
|
|
52
52
|
if not @@forbidden_attributes.include?(meth.to_s)
|
53
|
-
repository(@_source).value_for(@_source, meth,
|
53
|
+
repository(@_source).value_for(@_source, meth, conditions_for(meth))
|
54
54
|
else
|
55
55
|
nil
|
56
56
|
end
|
@@ -86,6 +86,12 @@ module Locomotive
|
|
86
86
|
repository.with(entry.content_type)
|
87
87
|
end
|
88
88
|
|
89
|
+
def conditions_for(name)
|
90
|
+
# note: treat conditions only they apply to the content type (if it's a has_many/many_to_many relationships)
|
91
|
+
_name = @context['with_scope_content_type']
|
92
|
+
!_name || _name == name ? @context['with_scope'] : nil
|
93
|
+
end
|
94
|
+
|
89
95
|
end
|
90
96
|
end
|
91
97
|
end
|
@@ -4,6 +4,10 @@ module Locomotive
|
|
4
4
|
module Filters
|
5
5
|
module Base
|
6
6
|
|
7
|
+
def absolute_url(url)
|
8
|
+
url =~ Locomotive::Steam::IsHTTP ? url : URI.join(@context['base_url'], url).to_s
|
9
|
+
end
|
10
|
+
|
7
11
|
protected
|
8
12
|
|
9
13
|
# Convert an array of properties ('key:value') into a hash
|
@@ -47,10 +51,6 @@ module Locomotive
|
|
47
51
|
@context.registers[:services].theme_asset_url.build(path)
|
48
52
|
end
|
49
53
|
|
50
|
-
def absolute_url(url)
|
51
|
-
url.starts_with?('/') ? url : "/#{url}"
|
52
|
-
end
|
53
|
-
|
54
54
|
end
|
55
55
|
|
56
56
|
::Liquid::Template.register_filter(Base)
|
@@ -26,7 +26,7 @@ module Locomotive
|
|
26
26
|
def default_pagination_links(paginate)
|
27
27
|
paginate['parts'].map do |part|
|
28
28
|
if part['is_link']
|
29
|
-
"<a href=\"#{
|
29
|
+
"<a href=\"#{default_pagination_url(part['url'])}\">#{part['title']}</a>"
|
30
30
|
elsif part['hellip_break']
|
31
31
|
"<span class=\"gap\">#{part['title']}</span>"
|
32
32
|
else
|
@@ -41,10 +41,14 @@ module Locomotive
|
|
41
41
|
if paginate[type.to_s].blank?
|
42
42
|
"<span class=\"disabled #{css}_page\">#{label}</span>"
|
43
43
|
else
|
44
|
-
"<a href=\"#{
|
44
|
+
"<a href=\"#{default_pagination_url(paginate[type.to_s]['url'])}\" class=\"#{css}_page\">#{label}</a>"
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
48
|
+
def default_pagination_url(url)
|
49
|
+
url.starts_with?('/') ? url : "/#{url}"
|
50
|
+
end
|
51
|
+
|
48
52
|
end
|
49
53
|
|
50
54
|
::Liquid::Template.register_filter(Pagination)
|
@@ -33,6 +33,7 @@ module Locomotive
|
|
33
33
|
def display(options = {}, &block)
|
34
34
|
current_context.stack do
|
35
35
|
current_context['with_scope'] = self.decode(options)
|
36
|
+
current_context['with_scope_content_type'] = false # for now, no content type is assigned to this with_scope
|
36
37
|
yield
|
37
38
|
end
|
38
39
|
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
module Locomotive::Steam
|
2
|
+
module Middlewares
|
3
|
+
|
4
|
+
# Hide a site behind a password to prevent public access.
|
5
|
+
# If page with the "lock_screen" handle exists, then it
|
6
|
+
# will be used to display the login form. Otherwise, a very basic
|
7
|
+
# form will be displayed.
|
8
|
+
#
|
9
|
+
class PrivateAccess < ThreadSafe
|
10
|
+
|
11
|
+
include Helpers
|
12
|
+
|
13
|
+
def _call
|
14
|
+
return if env['steam.private_access_disabled']
|
15
|
+
|
16
|
+
if site.private_access
|
17
|
+
log "Site with private access"
|
18
|
+
|
19
|
+
if access_granted?
|
20
|
+
store_password
|
21
|
+
else
|
22
|
+
render_lock_screen
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def render_lock_screen
|
30
|
+
if page = services.page_finder.by_handle('lock_screen', false)
|
31
|
+
log "Found custom lock screen: #{page.title}"
|
32
|
+
env['steam.page'] = page
|
33
|
+
else
|
34
|
+
render_response(lock_screen_html, 403)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def access_granted?
|
39
|
+
!submitted_password.blank? && submitted_password == site.password
|
40
|
+
end
|
41
|
+
|
42
|
+
def submitted_password
|
43
|
+
params[:private_access_password] || request.session[:private_access_password]
|
44
|
+
end
|
45
|
+
|
46
|
+
def store_password
|
47
|
+
request.session[:private_access_password] = params[:private_access_password] if params[:private_access_password].present?
|
48
|
+
end
|
49
|
+
|
50
|
+
def lock_screen_html
|
51
|
+
<<-HTML
|
52
|
+
<html>
|
53
|
+
<title>#{site.name} - Password protected</title>
|
54
|
+
<style>
|
55
|
+
@import url(http://fonts.googleapis.com/css?family=Open+Sans:400,700);
|
56
|
+
body { background: #f8f8f8; height: 100%; font-family: "Open Sans", sans-serif; font-size: 12px; -webkit-transform-style: preserve-3d; -moz-transform-style: preserve-3d; transform-style: preserve-3d; }
|
57
|
+
form { position: relative; top: 50%; width: 300px; margin: 0px auto; transform: translateY(-50%); -webkit-transform: translateY(-50%); -ms-transform: translateY(-50%); }
|
58
|
+
form p { text-align: center; color: #d9684c; }
|
59
|
+
form input[type=password] { border: 2px solid #eee; font-size: 14px; padding: 5px 8px; background: #fff; }
|
60
|
+
form input[type=submit] { border: 0 none; padding: 6px 20px; background: #171717; color: #fff; font-size: 14px; text-transform: none; transition: all 100ms ease-in-out; cursor: pointer; }
|
61
|
+
form input[type=submit]:hover { opacity: .7; }
|
62
|
+
}
|
63
|
+
</style>
|
64
|
+
<body>
|
65
|
+
<form action="#{mounted_on}" method="POST">
|
66
|
+
#{'<p>Wrong password</p>' unless submitted_password.blank?}
|
67
|
+
<input type="password" name="private_access_password" placeholder="Password" />
|
68
|
+
|
69
|
+
<input type="submit" value="Unlock" />
|
70
|
+
</form>
|
71
|
+
</body>
|
72
|
+
</html>
|
73
|
+
HTML
|
74
|
+
end
|
75
|
+
|
76
|
+
end
|
77
|
+
|
78
|
+
end
|
79
|
+
end
|
@@ -5,7 +5,7 @@ module Locomotive::Steam
|
|
5
5
|
|
6
6
|
extend Forwardable
|
7
7
|
|
8
|
-
def_delegators :@translations, :values, :blank
|
8
|
+
def_delegators :@translations, :values, :blank?, :default
|
9
9
|
|
10
10
|
attr_reader :name, :translations
|
11
11
|
|
@@ -39,6 +39,15 @@ module Locomotive::Steam
|
|
39
39
|
@translations.each(&block)
|
40
40
|
end
|
41
41
|
|
42
|
+
def apply(&block)
|
43
|
+
if default
|
44
|
+
@translations = Hash.new(yield(default))
|
45
|
+
else
|
46
|
+
each { |l, _value| self[l] = yield(_value) }
|
47
|
+
end
|
48
|
+
self
|
49
|
+
end
|
50
|
+
|
42
51
|
alias :__translations__ :translations
|
43
52
|
|
44
53
|
alias :to_hash :translations
|
@@ -76,6 +76,7 @@ module Locomotive
|
|
76
76
|
if %i(has_many many_to_many).include?(field.type)
|
77
77
|
# a safe copy of the proxy repository is needed here
|
78
78
|
value = value.dup
|
79
|
+
|
79
80
|
# like this, we do not modify the original local conditions
|
80
81
|
value.local_conditions.merge!(conditions) if conditions
|
81
82
|
end
|
@@ -216,7 +217,9 @@ module Locomotive
|
|
216
217
|
operator = @operators[name]
|
217
218
|
_name = operator ? "#{name}.#{operator}" : name
|
218
219
|
|
219
|
-
if
|
220
|
+
if @conditions.has_key?(_name)
|
221
|
+
value = @conditions[_name]
|
222
|
+
|
220
223
|
# delete old name
|
221
224
|
@conditions.delete(_name)
|
222
225
|
|
data/spec/spec_helper.rb
CHANGED
@@ -3,11 +3,10 @@ require 'codeclimate-test-reporter'
|
|
3
3
|
require 'coveralls'
|
4
4
|
|
5
5
|
SimpleCov.start do
|
6
|
-
formatter SimpleCov::Formatter::MultiFormatter[
|
6
|
+
formatter SimpleCov::Formatter::MultiFormatter.new([
|
7
7
|
SimpleCov::Formatter::HTMLFormatter,
|
8
8
|
CodeClimate::TestReporter::Formatter,
|
9
|
-
Coveralls::SimpleCov::Formatter
|
10
|
-
]
|
9
|
+
Coveralls::SimpleCov::Formatter])
|
11
10
|
|
12
11
|
add_filter 'config/'
|
13
12
|
add_filter 'example/'
|
@@ -146,6 +146,11 @@ describe Locomotive::Steam::ContentEntry do
|
|
146
146
|
context 'localized' do
|
147
147
|
let(:value) { build_i18n_field(en: '2007/06/29', fr: date) }
|
148
148
|
it { expect(subject.translations).to eq('en' => date, 'fr' => date) }
|
149
|
+
context 'with a single value for all the translations' do
|
150
|
+
let(:value) { build_i18n_field('2007/06/29') }
|
151
|
+
it { expect(subject[:fr]).to eq(date) }
|
152
|
+
it { expect(subject[:en]).to eq(date) }
|
153
|
+
end
|
149
154
|
end
|
150
155
|
end
|
151
156
|
|
@@ -38,18 +38,36 @@ describe Locomotive::Steam::Liquid::Drops::ContentEntryCollection do
|
|
38
38
|
|
39
39
|
describe '#first' do
|
40
40
|
before do
|
41
|
-
expect(services.repositories.content_entry).to receive(:all).with(
|
41
|
+
expect(services.repositories.content_entry).to receive(:all).with('visible' => true).and_return(['a', 'b'])
|
42
42
|
end
|
43
43
|
it { expect(drop.first).to eq('a') }
|
44
44
|
end
|
45
45
|
|
46
46
|
describe '#count' do
|
47
47
|
before do
|
48
|
-
expect(services.repositories.content_entry).to receive(:count).with(
|
48
|
+
expect(services.repositories.content_entry).to receive(:count).with('visible' => true).and_return(2)
|
49
49
|
end
|
50
50
|
it { expect(drop.count).to eq 2 }
|
51
51
|
end
|
52
52
|
|
53
|
+
describe 'only applied to the first content type' do
|
54
|
+
|
55
|
+
it 'sets the content type in the context' do
|
56
|
+
expect(services.repositories.content_entry).to receive(:all).with('visible' => true).and_return(['a', 'b'])
|
57
|
+
expect(context['with_scope_content_type']).to eq nil
|
58
|
+
drop.first
|
59
|
+
expect(context['with_scope_content_type']).to eq 'articles'
|
60
|
+
end
|
61
|
+
|
62
|
+
it "doesn't apply the with_scope conditions if it's not the same content type" do
|
63
|
+
context['with_scope_content_type'] = 'projects'
|
64
|
+
expect(services.repositories.content_entry).to receive(:all).with({}).and_return(['a', 'b'])
|
65
|
+
drop.first
|
66
|
+
expect(context['with_scope_content_type']).to eq 'projects'
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
70
|
+
|
53
71
|
end
|
54
72
|
|
55
73
|
end
|
@@ -112,4 +112,30 @@ describe Locomotive::Steam::Liquid::Drops::ContentEntry do
|
|
112
112
|
|
113
113
|
end
|
114
114
|
|
115
|
+
describe '#conditions_for' do
|
116
|
+
|
117
|
+
let(:name) { 'news' }
|
118
|
+
|
119
|
+
subject { drop.send(:conditions_for, name) }
|
120
|
+
|
121
|
+
before { context['with_scope'] = 42 }
|
122
|
+
|
123
|
+
it { is_expected.to eq 42 }
|
124
|
+
|
125
|
+
context 'the with_scope has been used before by another and different content type' do
|
126
|
+
|
127
|
+
before { context['with_scope_content_type'] = 'articles' }
|
128
|
+
it { is_expected.to eq nil }
|
129
|
+
|
130
|
+
end
|
131
|
+
|
132
|
+
context 'the with_scope has been used before by the same content type' do
|
133
|
+
|
134
|
+
before { context['with_scope_content_type'] = 'news' }
|
135
|
+
it { is_expected.to eq 42 }
|
136
|
+
|
137
|
+
end
|
138
|
+
|
139
|
+
end
|
140
|
+
|
115
141
|
end
|
@@ -44,6 +44,12 @@ describe Locomotive::Steam::Liquid::Drops::Site do
|
|
44
44
|
|
45
45
|
it { expect(subject.pages).to eq([{ 'title' => 'About us' }, { 'title' => 'Contact' }]) }
|
46
46
|
|
47
|
+
it "doesn't memoize it" do
|
48
|
+
subject.pages
|
49
|
+
allow(services.repositories.page).to receive(:all).and_return([pages.first])
|
50
|
+
expect(subject.pages).to eq([{ 'title' => 'About us' }])
|
51
|
+
end
|
52
|
+
|
47
53
|
end
|
48
54
|
|
49
55
|
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Locomotive::Steam::Liquid::Filters::Misc do
|
4
|
+
|
5
|
+
include Locomotive::Steam::Liquid::Filters::Base
|
6
|
+
|
7
|
+
describe '#absolute_url' do
|
8
|
+
|
9
|
+
subject { absolute_url(url) }
|
10
|
+
|
11
|
+
context 'absolute url' do
|
12
|
+
|
13
|
+
let(:url) { 'http://www.locomotive.works/themes/background.png' }
|
14
|
+
|
15
|
+
it { is_expected.to eq 'http://www.locomotive.works/themes/background.png' }
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
context 'relative url' do
|
20
|
+
|
21
|
+
before { @context = { 'base_url' => 'http://www.locomotive.works' } }
|
22
|
+
|
23
|
+
let(:url) { 'themes/background.png' }
|
24
|
+
|
25
|
+
it { is_expected.to eq 'http://www.locomotive.works/themes/background.png' }
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
@@ -7,6 +7,15 @@ describe Locomotive::Steam::Liquid::Tags::WithScope do
|
|
7
7
|
let!(:output) { render_template(source, context) }
|
8
8
|
let(:conditions) { context['conditions'] }
|
9
9
|
|
10
|
+
describe 'store the conditions in the context' do
|
11
|
+
|
12
|
+
let(:source) { "{% with_scope active: true, price: 42, title: 'foo', hidden: false %}{% assign conditions = with_scope %}{% assign content_type = with_scope_content_type %}{% endwith_scope %}" }
|
13
|
+
|
14
|
+
it { expect(context['conditions'].keys).to eq(%w(active price title hidden)) }
|
15
|
+
it { expect(context['content_type']).to eq false }
|
16
|
+
|
17
|
+
end
|
18
|
+
|
10
19
|
describe 'decode basic options (boolean, integer, ...)' do
|
11
20
|
|
12
21
|
let(:source) { "{% with_scope active: true, price: 42, title: 'foo', hidden: false %}{% assign conditions = with_scope %}{% endwith_scope %}" }
|
@@ -0,0 +1,103 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
require_relative '../../../lib/locomotive/steam/middlewares/thread_safe'
|
4
|
+
require_relative '../../../lib/locomotive/steam/middlewares/helpers'
|
5
|
+
require_relative '../../../lib/locomotive/steam/middlewares/private_access'
|
6
|
+
|
7
|
+
describe Locomotive::Steam::Middlewares::PrivateAccess do
|
8
|
+
|
9
|
+
let(:password) { nil }
|
10
|
+
let(:site) { instance_double('Site', name: 'Acme Corp', private_access: private_access, password: password) }
|
11
|
+
let(:url) { 'http://models.example.com' }
|
12
|
+
let(:lock_screen) { nil }
|
13
|
+
let(:page_finder) { instance_double('PageFinder', by_handle: lock_screen) }
|
14
|
+
let(:services) { instance_double('Services', page_finder: page_finder) }
|
15
|
+
let(:session) { {} }
|
16
|
+
let(:app) { ->(env) { [200, env, ['app']] } }
|
17
|
+
let(:middleware) { described_class.new(app) }
|
18
|
+
let(:rack_env) { build_env }
|
19
|
+
let(:form) { nil }
|
20
|
+
|
21
|
+
subject { code, env, body = middleware.call(rack_env); body.first }
|
22
|
+
|
23
|
+
describe 'no private access enabled' do
|
24
|
+
|
25
|
+
let(:private_access) { false }
|
26
|
+
|
27
|
+
it { is_expected.to eq 'app' }
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
describe 'private access enabled' do
|
32
|
+
|
33
|
+
let(:private_access) { true }
|
34
|
+
|
35
|
+
context 'no password defined' do
|
36
|
+
|
37
|
+
it { is_expected.not_to eq 'app' }
|
38
|
+
|
39
|
+
describe 'with a custom lock screen page' do
|
40
|
+
|
41
|
+
let(:lock_screen) { instance_double('LockScreenPage', title: 'LockScreen') }
|
42
|
+
|
43
|
+
it { subject; expect(rack_env['steam.page'].title).to eq 'LockScreen' }
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
context 'password defined' do
|
50
|
+
|
51
|
+
let(:password) { 'easyone' }
|
52
|
+
let(:form) { 'private_access_password=easyone' }
|
53
|
+
|
54
|
+
describe 'right password submitted' do
|
55
|
+
|
56
|
+
it { is_expected.to eq 'app' }
|
57
|
+
it { subject; expect(session[:private_access_password]).to eq 'easyone' }
|
58
|
+
|
59
|
+
end
|
60
|
+
|
61
|
+
describe 'right password already stored in the session' do
|
62
|
+
|
63
|
+
let(:form) { '' }
|
64
|
+
let(:session) { { private_access_password: 'easyone' } }
|
65
|
+
|
66
|
+
it { is_expected.to eq 'app' }
|
67
|
+
it { subject; expect(session[:private_access_password]).to eq 'easyone' }
|
68
|
+
|
69
|
+
end
|
70
|
+
|
71
|
+
describe 'wrong password submitted' do
|
72
|
+
|
73
|
+
let(:password) { 'easyone' }
|
74
|
+
let(:form) { 'private_access_password=wrongone' }
|
75
|
+
|
76
|
+
it { is_expected.to match /Wrong password/ }
|
77
|
+
|
78
|
+
end
|
79
|
+
|
80
|
+
describe 'feature disabled by a specific rack env variable' do
|
81
|
+
|
82
|
+
let(:form) { '' }
|
83
|
+
|
84
|
+
before { rack_env['steam.private_access_disabled'] = true }
|
85
|
+
|
86
|
+
it { is_expected.to eq 'app' }
|
87
|
+
|
88
|
+
end
|
89
|
+
|
90
|
+
end
|
91
|
+
|
92
|
+
end
|
93
|
+
|
94
|
+
def build_env
|
95
|
+
env_for(url, params: form).tap do |env|
|
96
|
+
env['steam.site'] = site
|
97
|
+
env['steam.request'] = Rack::Request.new(env)
|
98
|
+
env['steam.services'] = services
|
99
|
+
env['rack.session'] = session
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
end
|
@@ -380,6 +380,13 @@ describe Locomotive::Steam::ContentEntryRepository do
|
|
380
380
|
|
381
381
|
end
|
382
382
|
|
383
|
+
context 'testing a nil value (field.ne => nil)' do
|
384
|
+
|
385
|
+
let(:conditions) { { 'person.ne' => nil } }
|
386
|
+
it { is_expected.to eq([{ _visible: true, content_type_id: 1, 'person_id.ne' => nil }, nil]) }
|
387
|
+
|
388
|
+
end
|
389
|
+
|
383
390
|
end
|
384
391
|
|
385
392
|
context 'many_to_many fields' do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: locomotivecms_steam
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0.
|
4
|
+
version: 1.0.0.rc9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Didier Lafforgue
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2015-12-
|
14
|
+
date: 2015-12-15 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: bundler
|
@@ -515,6 +515,7 @@ files:
|
|
515
515
|
- lib/locomotive/steam/middlewares/logging.rb
|
516
516
|
- lib/locomotive/steam/middlewares/page.rb
|
517
517
|
- lib/locomotive/steam/middlewares/path.rb
|
518
|
+
- lib/locomotive/steam/middlewares/private_access.rb
|
518
519
|
- lib/locomotive/steam/middlewares/renderer.rb
|
519
520
|
- lib/locomotive/steam/middlewares/robots.rb
|
520
521
|
- lib/locomotive/steam/middlewares/site.rb
|
@@ -729,6 +730,7 @@ files:
|
|
729
730
|
- spec/unit/liquid/drops/page_spec.rb
|
730
731
|
- spec/unit/liquid/drops/session_proxy_spec.rb
|
731
732
|
- spec/unit/liquid/drops/site_spec.rb
|
733
|
+
- spec/unit/liquid/filters/base_spec.rb
|
732
734
|
- spec/unit/liquid/filters/date_spec.rb
|
733
735
|
- spec/unit/liquid/filters/html_spec.rb
|
734
736
|
- spec/unit/liquid/filters/json_spec.rb
|
@@ -761,6 +763,7 @@ files:
|
|
761
763
|
- spec/unit/liquid/tags/with_scope_spec.rb
|
762
764
|
- spec/unit/middlewares/dynamic_assets_spec.rb
|
763
765
|
- spec/unit/middlewares/locale_redirection_spec.rb
|
766
|
+
- spec/unit/middlewares/private_access_spec.rb
|
764
767
|
- spec/unit/middlewares/renderer_spec.rb
|
765
768
|
- spec/unit/middlewares/site_spec.rb
|
766
769
|
- spec/unit/middlewares/stack_proxy_spec.rb
|
@@ -809,7 +812,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
809
812
|
version: 1.3.1
|
810
813
|
requirements: []
|
811
814
|
rubyforge_project:
|
812
|
-
rubygems_version: 2.5.
|
815
|
+
rubygems_version: 2.4.5.1
|
813
816
|
signing_key:
|
814
817
|
specification_version: 4
|
815
818
|
summary: The LocomotiveCMS Steam is the rendering stack used by both Wagon and Engine
|
@@ -971,6 +974,7 @@ test_files:
|
|
971
974
|
- spec/unit/liquid/drops/page_spec.rb
|
972
975
|
- spec/unit/liquid/drops/session_proxy_spec.rb
|
973
976
|
- spec/unit/liquid/drops/site_spec.rb
|
977
|
+
- spec/unit/liquid/filters/base_spec.rb
|
974
978
|
- spec/unit/liquid/filters/date_spec.rb
|
975
979
|
- spec/unit/liquid/filters/html_spec.rb
|
976
980
|
- spec/unit/liquid/filters/json_spec.rb
|
@@ -1003,6 +1007,7 @@ test_files:
|
|
1003
1007
|
- spec/unit/liquid/tags/with_scope_spec.rb
|
1004
1008
|
- spec/unit/middlewares/dynamic_assets_spec.rb
|
1005
1009
|
- spec/unit/middlewares/locale_redirection_spec.rb
|
1010
|
+
- spec/unit/middlewares/private_access_spec.rb
|
1006
1011
|
- spec/unit/middlewares/renderer_spec.rb
|
1007
1012
|
- spec/unit/middlewares/site_spec.rb
|
1008
1013
|
- spec/unit/middlewares/stack_proxy_spec.rb
|