locomotivecms_steam 1.5.0 → 1.5.1

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
  SHA256:
3
- metadata.gz: fa05c0dc0b32bc49ebf656666399a7f113d074776c8ee477262a4513d32f8cb1
4
- data.tar.gz: 6e8b0f85fddc936a5d40ae83b1d4cb8bdf00afbfcb53db4f736bd5bfaaf64961
3
+ metadata.gz: b39383656db0b143ed8aa7df54aa656ed34d7104ea4b201a5be7ad87bc6c5005
4
+ data.tar.gz: 83e94cde0a6206f0cab0c2908cf1159a1c389cc55f4534c8883d0843b22ececa
5
5
  SHA512:
6
- metadata.gz: 1501b73e5f9494159ae306cba9b1198ffcbc494ae5f123f7e3ac04d5d72c4d0790fc54160cdbaae1da4875d7dafbac4ff75aacf1814af0e32d910d4610b227c7
7
- data.tar.gz: 8ff17b310eb98131cd895dbf714e3bb8b801085aa4bc88fa78d3caf2f5a688f221335ef7f2df8738f8b63a787014930ca8194324a58bff58dd71ba7ec0e8e7a1
6
+ metadata.gz: c04b7ed843d8c66d1eff244521db444db057ccf40a67b71fff9cced61d5107a2d63c6417856a77af1f48d42a223d9af92ae567a65940a0705c216e6e506c9c97
7
+ data.tar.gz: fa161306ac9c4752c2693cffca31d737bc4a622055a104ae226c7f44bd0ace67ab69f1201690bfcb23aea7ea436452257d2d35deeb7ddcba18839fe5169dd250
data/Gemfile CHANGED
@@ -9,7 +9,7 @@ group :development do
9
9
  # gem 'duktape', github: 'judofyr/duktape.rb', ref: '20ef6a5'
10
10
  # gem 'duktape', github: 'did/duktape.rb', branch: 'any-fixnum'
11
11
 
12
- gem 'puma', '~> 4.3.0'
12
+ gem 'puma', '~> 4.3.1'
13
13
  gem 'haml', '~> 5.0.4'
14
14
 
15
15
  gem 'rack-mini-profiler', '~> 0.10.1'
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- locomotivecms_steam (1.5.0)
4
+ locomotivecms_steam (1.5.1)
5
5
  RedCloth (~> 4.3.2)
6
6
  autoprefixer-rails (~> 8.0.0)
7
7
  bcrypt (~> 3.1.11)
@@ -33,7 +33,7 @@ GEM
33
33
  remote: https://rubygems.org/
34
34
  specs:
35
35
  RedCloth (4.3.2)
36
- activesupport (5.2.3)
36
+ activesupport (5.2.4.1)
37
37
  concurrent-ruby (~> 1.0, >= 1.0.2)
38
38
  i18n (>= 0.7, < 2)
39
39
  minitest (~> 5.1)
@@ -82,7 +82,7 @@ GEM
82
82
  rack (>= 1.3)
83
83
  duktape (2.0.1.1)
84
84
  execjs (2.7.0)
85
- ffi (1.11.2)
85
+ ffi (1.11.3)
86
86
  flamegraph (0.9.5)
87
87
  haml (5.0.4)
88
88
  temple (>= 0.8.0)
@@ -124,17 +124,17 @@ GEM
124
124
  multi_json (1.13.1)
125
125
  multi_xml (0.6.0)
126
126
  nio4r (2.5.2)
127
- nokogiri (1.10.5)
127
+ nokogiri (1.10.7)
128
128
  mini_portile2 (~> 2.4.0)
129
129
  nokogumbo (1.5.0)
130
130
  nokogiri
131
131
  origin (2.3.1)
132
132
  pony (1.13.1)
133
133
  mail (>= 2.0)
134
- public_suffix (4.0.1)
135
- puma (4.3.0)
134
+ public_suffix (4.0.2)
135
+ puma (4.3.1)
136
136
  nio4r (~> 2.0)
137
- rack (2.0.7)
137
+ rack (2.0.8)
138
138
  rack-cache (1.7.2)
139
139
  rack (>= 0.4)
140
140
  rack-mini-profiler (0.10.7)
@@ -146,7 +146,7 @@ GEM
146
146
  rack (>= 1.1.0)
147
147
  rake (13.0.1)
148
148
  rb-fsevent (0.10.3)
149
- rb-inotify (0.10.0)
149
+ rb-inotify (0.10.1)
150
150
  ffi (~> 1.0)
151
151
  rspec (3.7.0)
152
152
  rspec-core (~> 3.7.0)
@@ -184,7 +184,7 @@ GEM
184
184
  tilt (2.0.10)
185
185
  timecop (0.9.1)
186
186
  tins (1.22.2)
187
- tzinfo (1.2.5)
187
+ tzinfo (1.2.6)
188
188
  thread_safe (~> 0.1)
189
189
  uglifier (4.1.20)
190
190
  execjs (>= 0.3.0, < 3)
@@ -203,7 +203,7 @@ DEPENDENCIES
203
203
  memory_profiler
204
204
  mongo (~> 2.8.0)
205
205
  origin (~> 2.3.1)
206
- puma (~> 4.3.0)
206
+ puma (~> 4.3.1)
207
207
  rack-mini-profiler (~> 0.10.1)
208
208
  rack-test (~> 0.8.2)
209
209
  rake (~> 13.0.1)
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2018 NoCoffee
3
+ Copyright (c) 2020 NoCoffee
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy of
6
6
  this software and associated documentation files (the "Software"), to deal in
data/README.md CHANGED
@@ -94,4 +94,4 @@ Note: you do not need to prefix with bundle exec as the docky-ruby image already
94
94
 
95
95
  ## License
96
96
 
97
- Copyright (c) 2019 NoCoffee. MIT Licensed, see MIT-LICENSE for details.
97
+ Copyright (c) 2020 NoCoffee. MIT Licensed, see MIT-LICENSE for details.
@@ -11,6 +11,10 @@ module Locomotive
11
11
  def load(scope)
12
12
  attributes = _load(File.join(site_path, 'config', 'site.yml'))
13
13
 
14
+ # NOTE: we can't use the locales and default_local methods here
15
+ # since the loading is not done yet.
16
+ locales, default_locale = attributes[:locales], attributes[:locales].first
17
+
14
18
  (attributes[:domains] ||= []).concat(%w(0.0.0.0 localhost))
15
19
 
16
20
  attributes[:picture] = File.expand_path(File.join(site_path, 'icon.png'))
@@ -19,6 +23,12 @@ module Locomotive
19
23
 
20
24
  attributes.merge!(load_from_env)
21
25
 
26
+ # special treatment for the sections_content which may or may not be translated
27
+ sections_content = attributes[:sections_content]
28
+ if sections_content.present? && locales.size == 1 && sections_content[default_locale].nil?
29
+ attributes[:sections_content] = { default_locale => sections_content }
30
+ end
31
+
22
32
  [attributes]
23
33
  end
24
34
 
@@ -97,6 +97,7 @@ module Locomotive::Steam
97
97
  break # no to go further
98
98
  end
99
99
  end
100
+
100
101
  accepted
101
102
  end
102
103
  end # filtered
@@ -1,8 +1,10 @@
1
1
  # Enhance the IF condition to write the following statement:
2
2
  #
3
3
  # {% if value is present %}Value is not blank{% endif %}
4
+ # {% if 'Hello world' starts_with 'Hello' %}Value starts with 'hello'{% endif %}
4
5
  #
5
- Liquid::Condition.operators['is'.freeze] = lambda { |cond, left, right| cond.send(:equal_variables, left, right) }
6
+ Liquid::Condition.operators['is'.freeze] = proc { |cond, left, right| cond.send(:equal_variables, left, right) }
7
+ Liquid::Condition.operators['starts_with'.freeze] = proc { |_cond, left, right| left.present? && right.present? && left.starts_with?(right) }
6
8
 
7
9
  module Liquid
8
10
 
@@ -5,37 +5,55 @@ module Locomotive
5
5
 
6
6
  class Snippet < ::Liquid::Include
7
7
 
8
- attr_reader :name
8
+ attr_reader :template_name
9
9
 
10
10
  def initialize(tag_name, markup, options)
11
11
  super
12
12
 
13
- # we use a convention to differentiate sections from snippets
14
- @name = evaluate_snippet_name
15
- @template_name_expr = "snippets--#{@name}"
13
+ if markup =~ Syntax
14
+ @template_name = $1
15
+ end
16
16
  end
17
17
 
18
18
  def parse(tokens)
19
- ActiveSupport::Notifications.instrument('steam.parse.include', page: parse_context[:page], name: name)
19
+ ActiveSupport::Notifications.instrument('steam.parse.include', page: parse_context[:page], name: template_name)
20
20
 
21
21
  # look for editable elements (only used by the Engine)
22
22
  # In the next version of Locomotive (v5), we won't support the editable elements
23
- if parse_context[:snippet_finder] && snippet = parse_context[:snippet_finder].find(name)
24
- parse_context[:parser]._parse(snippet, parse_context.merge(snippet: name))
23
+ #
24
+ # NOTE: it doesn't support dynamically choosen template
25
+ #
26
+ if parse_context[:snippet_finder] && snippet = parse_context[:snippet_finder].find(template_name)
27
+ parse_context[:parser]._parse(snippet, parse_context.merge(snippet: template_name))
25
28
  end
26
29
  end
27
30
 
28
31
  def render(context)
29
32
  # parse_context (previously @options) doesn't include the page key if cache is on
30
33
  parse_context[:page] = context.registers[:page]
31
- super
34
+
35
+ begin
36
+ super
37
+ rescue ::Liquid::ArgumentError
38
+ # NOTE: Locomotive site developers should always use quotes (or doubles quotes) for the name of a snippet.
39
+ # Unfortunately, a lot of sites don't use them. So here is a little patch to not break those sites.
40
+ Locomotive::Common::Logger.warn("Use quotes if the name of your snippet (#{template_name}) is not dynamic.")
41
+
42
+ @template_name_expr = template_name
43
+
44
+ super
45
+ end
32
46
  end
33
47
 
34
48
  private
35
49
 
36
- def evaluate_snippet_name
37
- (!template_name_expr.is_a?(String) && template_name_expr.send(:state).first) ||
38
- template_name_expr
50
+ def read_template_from_file_system(context)
51
+ file_system = context.registers[:file_system] || Liquid::Template.file_system
52
+
53
+ # we use a convention to differentiate sections from snippets
54
+ template_path = "snippets--#{context.evaluate(@template_name_expr)}"
55
+
56
+ file_system.read_template_file(template_path)
39
57
  end
40
58
 
41
59
  end
@@ -24,6 +24,7 @@ module Locomotive
24
24
 
25
25
  # a slight different from the Shopify implementation because we allow stuff like `started_at.le`
26
26
  TagAttributes = /([a-zA-Z_0-9\.]+)\s*\:\s*(#{ArrayFragment}|#{RegexpFragment}|#{::Liquid::QuotedFragment})/o.freeze
27
+ SingleVariable = /(#{::Liquid::VariableSignature}+)/om.freeze
27
28
 
28
29
  REGEX_OPTIONS = {
29
30
  'i' => Regexp::IGNORECASE,
@@ -31,14 +32,21 @@ module Locomotive
31
32
  'x' => Regexp::EXTENDED
32
33
  }.freeze
33
34
 
34
- attr_reader :attributes
35
+ attr_reader :attributes, :attributes_var_name
35
36
 
36
37
  def initialize(tag_name, markup, options)
37
38
  super
38
39
 
40
+ # simple hash?
39
41
  parse_attributes(markup) { |value| parse_attribute(value) }
40
42
 
41
- if attributes.empty?
43
+ if attributes.empty? && markup =~ SingleVariable
44
+ # alright, maybe we'vot got a single variable built
45
+ # with the Action liquid tag instead?
46
+ @attributes_var_name = Regexp.last_match(1)
47
+ end
48
+
49
+ if attributes.empty? && attributes_var_name.blank?
42
50
  raise ::Liquid::SyntaxError.new("Syntax Error in 'with_scope' - Valid syntax: with_scope <name_1>: <value_1>, ..., <name_n>: <value_n>")
43
51
  end
44
52
  end
@@ -69,6 +77,8 @@ module Locomotive
69
77
  end
70
78
 
71
79
  def evaluate_attributes(context)
80
+ @attributes = context[attributes_var_name] || {} if attributes_var_name.present?
81
+
72
82
  HashWithIndifferentAccess.new.tap do |hash|
73
83
  attributes.each do |key, value|
74
84
  # _slug instead of _permalink
@@ -17,7 +17,7 @@ module Locomotive::Steam
17
17
  # extract the slug of the content entry
18
18
  %r(^#{page.fullpath.gsub(Locomotive::Steam::WILDCARD, '([^\/]+)')}$) =~ path
19
19
 
20
- if entry = fetch_content_entry($1)
20
+ if entry = fetch_content_entry($1 || params['id'])
21
21
  # the entry will be available in the template under different keys
22
22
  ['content_entry', 'entry', entry.content_type.slug.singularize].each do |key|
23
23
  liquid_assigns[key] = entry
@@ -58,7 +58,7 @@ module Locomotive::Steam::Middlewares
58
58
  end
59
59
 
60
60
  def params
61
- @params ||= if request.content_type == 'application/json' && (request.post? || request.put?)
61
+ @params ||= if request.content_type&.start_with?('application/json') && (request.post? || request.put?)
62
62
  request.body.rewind
63
63
  JSON.parse(request.body.read).with_indifferent_access
64
64
  else
@@ -91,7 +91,7 @@ module Locomotive::Steam
91
91
 
92
92
  first = { order_by: _local_conditions.delete(:order_by) }.delete_if { |_, v| v.blank? }
93
93
 
94
- [first, *conditions.flatten].inject({}) do |memo, hash|
94
+ [first, *conditions.flatten].inject(HashWithIndifferentAccess.new) do |memo, hash|
95
95
  memo.merge!(hash) unless hash.blank?
96
96
  memo
97
97
  end.merge(_local_conditions)
@@ -3,6 +3,6 @@
3
3
  # 1.0.0.alpha < 1.0.0.alpha1 < 1.0.0.beta < 1.0.0.beta2 < 1.0.0.beta11 < 1.0.0.rc1 < 1.0.0
4
4
  module Locomotive
5
5
  module Steam
6
- VERSION = '1.5.0'
6
+ VERSION = '1.5.1'
7
7
  end
8
8
  end
@@ -6,7 +6,7 @@
6
6
  email: 'jane@doe.net'
7
7
  password: 'anotherone'
8
8
  _auth_reset_token: '420000000000000'
9
- _auth_reset_sent_at: '2020-01-01T15:00:00.000Z'
9
+ _auth_reset_sent_at: '2030-01-01T15:00:00.000Z'
10
10
 
11
11
  - "Mickey":
12
12
  email: 'mickey@doe.net'
@@ -1,3 +1,10 @@
1
1
  {
2
- "name": "My awesome site"
2
+ "name": "My awesome site",
3
+ "sections_content": {
4
+ "header": {
5
+ "settings": {
6
+ "title": "Hello world"
7
+ }
8
+ }
9
+ }
3
10
  }
@@ -32,6 +32,13 @@ describe Locomotive::Steam::Adapters::Filesystem::YAMLLoaders::Site do
32
32
  expect(subject[:name]).to eq('My awesome site')
33
33
  end
34
34
 
35
+ it 'localizes the sections_content from the production environment' do
36
+ allow(loader).to receive(:_load).with(File.join(site_path, 'config', 'site.yml')).and_return(name: 'Test', locales: ['fr'])
37
+ allow(loader).to receive(:_load).with(File.join(site_path, 'config', 'metafields_schema.yml')).and_return(nil)
38
+ expect(subject[:sections_content]).to eq('fr' => { 'header' => { 'settings' => {
39
+ 'title' => 'Hello world' } } })
40
+ end
41
+
35
42
  end
36
43
 
37
44
  end
@@ -1,6 +1,55 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Liquid::StandardFilters do
3
+ describe ::Liquid::Condition do
4
+
5
+ let(:context) { Liquid::Context.new }
6
+ let(:condition) { described_class.new(left, op, right) }
7
+
8
+ subject { condition.evaluate(context) }
9
+
10
+ describe 'custom proc operator: starts_with' do
11
+
12
+ let(:op) { 'starts_with' }
13
+ let(:left) { 'Hello world' }
14
+ let(:right) { 'Hello' }
15
+
16
+ it { is_expected.to eq true }
17
+
18
+ context "the left variable doesn't start with the right variable" do
19
+ let(:right) { 'hello' }
20
+ it { is_expected.to eq false }
21
+ end
22
+
23
+ context 'the left variable is nil' do
24
+ let(:left) { nil }
25
+ it { is_expected.to eq false }
26
+ end
27
+
28
+ context 'the right variable is nil' do
29
+ let(:right) { nil }
30
+ it { is_expected.to eq false }
31
+ end
32
+
33
+ end
34
+
35
+ describe 'custom proc operator: is' do
36
+
37
+ let(:op) { 'is' }
38
+ let(:left) { 42 }
39
+ let(:right) { 42 }
40
+
41
+ it { is_expected.to eq true }
42
+
43
+ context "the left variable doesn't equal to the right variable" do
44
+ let(:right) { nil }
45
+ it { is_expected.to eq false }
46
+ end
47
+
48
+ end
49
+
50
+ end
51
+
52
+ describe ::Liquid::StandardFilters do
4
53
 
5
54
  describe '#to_number' do
6
55
 
@@ -2,14 +2,15 @@ require 'spec_helper'
2
2
 
3
3
  describe Locomotive::Steam::Liquid::Tags::Snippet do
4
4
 
5
- let(:request) { instance_double('Request', env: {}) }
6
- let(:services) { Locomotive::Steam::Services.build_instance(request) }
7
- let(:finder) { services.snippet_finder }
8
- let(:file_system) { Locomotive::Steam::Liquid::FileSystem.new(snippet_finder: finder) }
9
- let(:snippet) { instance_double('Snippet', template: nil, :template= => nil, liquid_source: 'built by NoCoffee') }
10
- let(:source) { 'Locomotive {% include footer %}' }
5
+ let(:request) { instance_double('Request', env: {}) }
6
+ let(:services) { Locomotive::Steam::Services.build_instance(request) }
7
+ let(:finder) { services.snippet_finder }
8
+ let(:file_system) { Locomotive::Steam::Liquid::FileSystem.new(snippet_finder: finder) }
9
+ let(:snippet_source) { 'built by NoCoffee' }
10
+ let(:snippet) { instance_double('Snippet', template: nil, :template= => nil, liquid_source: snippet_source) }
11
+ let(:source) { 'Locomotive {% include footer %}' }
11
12
 
12
- before { allow(finder).to receive(:find).and_return(snippet) }
13
+ before { allow(finder).to receive(:find).with('footer').and_return(snippet) }
13
14
 
14
15
  describe 'parsing' do
15
16
 
@@ -33,15 +34,16 @@ describe Locomotive::Steam::Liquid::Tags::Snippet do
33
34
 
34
35
  describe 'rendering' do
35
36
 
36
- let(:context) { ::Liquid::Context.new({}, {}, { services: services, file_system: file_system }) }
37
+ let(:assigns) { {} }
38
+ let(:context) { ::Liquid::Context.new(assigns, {}, { services: services, file_system: file_system }) }
37
39
 
38
40
  subject { render_template(source, context) }
39
41
 
40
42
  it { is_expected.to eq 'Locomotive built by NoCoffee' }
41
43
 
42
- context 'rendering error (action) found in the snippet' do
44
+ context 'a rendering error (action) has been found in the snippet' do
43
45
 
44
- let(:snippet) { instance_double('Snippet', template: nil, :template= => nil, liquid_source: '{% action "Hello world" %}a.b(+}{% endaction %}') }
46
+ let(:snippet_source) { '{% action "Hello world" %}a.b(+}{% endaction %}' }
45
47
 
46
48
  it 'raises a TemplateError' do
47
49
  expect { subject }.to raise_exception(Locomotive::Steam::TemplateError)
@@ -49,6 +51,15 @@ describe Locomotive::Steam::Liquid::Tags::Snippet do
49
51
 
50
52
  end
51
53
 
54
+ context 'use a variable as the name of the snippet' do
55
+
56
+ let(:assigns) { { 'my_snippet' => 'footer' } }
57
+ let(:source) { 'Locomotive {% include my_snippet %}' }
58
+
59
+ it { is_expected.to eq 'Locomotive built by NoCoffee' }
60
+
61
+ end
62
+
52
63
  end
53
64
 
54
65
  end
@@ -33,6 +33,25 @@ describe Locomotive::Steam::Liquid::Tags::WithScope do
33
33
 
34
34
  end
35
35
 
36
+ describe 'pass directly a hash built with the Action liquid tag for example' do
37
+
38
+ let(:assigns) { { 'my_filters' => { active: true, price: 42, title: "/like this/ix", hidden: false } } }
39
+
40
+ let(:source) { "{% with_scope my_filters %}{% assign conditions = with_scope %}{% assign content_type = with_scope_content_type %}{% endwith_scope %}" }
41
+
42
+ it { expect(context['conditions'].keys).to eq(%w(active price title hidden)) }
43
+ it { expect(conditions['active']).to eq true }
44
+ it { expect(conditions['title']).to eq(/like this/ix) }
45
+
46
+ context "the variable doesn't exist" do
47
+
48
+ let(:assigns) { { } }
49
+ it { expect(context['conditions']).to eq({}) }
50
+
51
+ end
52
+
53
+ end
54
+
36
55
  describe 'decode basic options (boolean, integer, ...)' do
37
56
 
38
57
  let(:source) { "{% with_scope active: true, price: 42, title: 'foo', hidden: false %}{% assign conditions = with_scope %}{% endwith_scope %}" }
@@ -55,11 +55,11 @@ describe Locomotive::Steam::Middlewares::Cache do
55
55
 
56
56
  let(:response) { nil }
57
57
 
58
- before { expect(cache).to receive(:read).with('1c538f12ddad36b3fd5cb7211aac60a2').and_return(response) }
58
+ before { expect(cache).to receive(:read).with('49876cf5daaa47d21daccd3b805b5b79').and_return(response) }
59
59
 
60
60
  context 'the cache is empty' do
61
61
 
62
- before { expect(cache).to receive(:write).with('1c538f12ddad36b3fd5cb7211aac60a2', Marshal.dump([200, {}, ["Hello world!"]])) }
62
+ before { expect(cache).to receive(:write).with('49876cf5daaa47d21daccd3b805b5b79', Marshal.dump([200, {}, ["Hello world!"]])) }
63
63
 
64
64
  it 'tells the CDN to cache the page and also cache it internally' do
65
65
  is_expected.to eq ['max-age=0, s-maxage=3600, public, must-revalidate', 'Accept-Language']
@@ -69,7 +69,7 @@ describe Locomotive::Steam::Middlewares::Cache do
69
69
 
70
70
  subject { send_request[:env]['steam.cache_etag'] }
71
71
 
72
- it { is_expected.to eq '1c538f12ddad36b3fd5cb7211aac60a2' }
72
+ it { is_expected.to eq '49876cf5daaa47d21daccd3b805b5b79' }
73
73
 
74
74
  end
75
75
 
@@ -104,7 +104,7 @@ describe Locomotive::Steam::Middlewares::Cache do
104
104
 
105
105
  context 'based on the ETag' do
106
106
 
107
- let(:etag) { '1c538f12ddad36b3fd5cb7211aac60a2' }
107
+ let(:etag) { '49876cf5daaa47d21daccd3b805b5b79' }
108
108
 
109
109
  it 'returns a 304 (Not modified) without no cache headers' do
110
110
  expect(subject.first).to eq 304
@@ -39,6 +39,31 @@ describe Locomotive::Steam::Models::Repository do
39
39
 
40
40
  end
41
41
 
42
+ describe '#prepare_conditions' do
43
+
44
+ let(:conditions) { [{ 'band_id' => 42, 'order_by' => 'created_at.desc' }] }
45
+
46
+ subject { repository.prepare_conditions(*conditions) }
47
+
48
+ it { is_expected.to eq({ 'band_id' => 42, 'order_by' => 'created_at.desc' }) }
49
+
50
+ context 'with local conditions' do
51
+
52
+ let(:local_conditions) { { parent_id: 1, order_by: { position: 'asc' } } }
53
+
54
+ before { repository.local_conditions = local_conditions }
55
+
56
+ it { is_expected.to eq({ 'parent_id' => 1, 'band_id' => 42, 'order_by' => 'created_at.desc' }) }
57
+
58
+ it "doesn't modify the local conditions" do
59
+ subject
60
+ expect(local_conditions).to eq({ parent_id: 1, order_by: { position: 'asc' } })
61
+ end
62
+
63
+ end
64
+
65
+ end
66
+
42
67
  class ArticleRepository
43
68
  include Locomotive::Steam::Models::Repository
44
69
  end
@@ -378,7 +378,7 @@ describe Locomotive::Steam::ContentEntryRepository do
378
378
 
379
379
  subject { repository.with(type).send(:conditions_without_order_by, conditions) }
380
380
 
381
- it { is_expected.to eq([{ _visible: true, content_type_id: 1 }, nil]) }
381
+ it { is_expected.to eq([{ '_visible' => true, 'content_type_id' => 1 }, nil]) }
382
382
 
383
383
  context 'select fields' do
384
384
 
@@ -389,7 +389,7 @@ describe Locomotive::Steam::ContentEntryRepository do
389
389
  let(:_fields) { instance_double('Fields', selects: [field], belongs_to: [], many_to_many: [], dates_and_date_times: []) }
390
390
  let(:conditions) { { 'category' => value } }
391
391
 
392
- it { is_expected.to eq([{ _visible: true, content_type_id: 1, 'category_id' => 42 }, nil]) }
392
+ it { is_expected.to eq([{ '_visible' => true, 'content_type_id' => 1, 'category_id' => 42 }, nil]) }
393
393
 
394
394
  end
395
395
 
@@ -400,7 +400,7 @@ describe Locomotive::Steam::ContentEntryRepository do
400
400
  let(:_fields) { instance_double('Fields', selects: [], belongs_to: [], many_to_many: [], dates_and_date_times: [field]) }
401
401
  let(:conditions) { { 'launched_at' => value } }
402
402
 
403
- it { is_expected.to eq([{ _visible: true, content_type_id: 1, 'launched_at' => Date.parse('2009/09/10') }, nil]) }
403
+ it { is_expected.to eq([{ '_visible' => true, 'content_type_id' => 1, 'launched_at' => Date.parse('2009/09/10') }, nil]) }
404
404
 
405
405
  end
406
406
 
@@ -413,7 +413,7 @@ describe Locomotive::Steam::ContentEntryRepository do
413
413
  let(:_fields) { instance_double('Fields', selects: [], belongs_to: [], many_to_many: [], dates_and_date_times: [field]) }
414
414
  let(:conditions) { { 'launched_at' => value } }
415
415
 
416
- it { is_expected.to eq([{ _visible: true, content_type_id: 1, 'launched_at' => Time.zone.parse('2007/06/29 21:15:00').to_datetime }, nil]) }
416
+ it { is_expected.to eq([{ '_visible' => true, 'content_type_id' => 1, 'launched_at' => Time.zone.parse('2007/06/29 21:15:00').to_datetime }, nil]) }
417
417
 
418
418
  end
419
419
 
@@ -424,13 +424,13 @@ describe Locomotive::Steam::ContentEntryRepository do
424
424
  let(:_fields) { instance_double('Fields', selects: [], belongs_to: [field], many_to_many: [], dates_and_date_times: []) }
425
425
  let(:conditions) { { 'person' => value } }
426
426
 
427
- it { is_expected.to eq([{ _visible: true, content_type_id: 1, 'person_id' => 42 }, nil]) }
427
+ it { is_expected.to eq([{ '_visible' => true, 'content_type_id' => 1, 'person_id' => 42 }, nil]) }
428
428
 
429
429
  context 'the target value is a content entry' do
430
430
 
431
431
  let(:value) { instance_double('TargetContentEntry', _id: 1) }
432
432
 
433
- it { is_expected.to eq([{ _visible: true, content_type_id: 1, 'person_id' => 1 }, nil]) }
433
+ it { is_expected.to eq([{ '_visible' => true, 'content_type_id' => 1, 'person_id' => 1 }, nil]) }
434
434
 
435
435
  end
436
436
 
@@ -438,7 +438,7 @@ describe Locomotive::Steam::ContentEntryRepository do
438
438
 
439
439
  let(:value) { { '_id' => 42 } }
440
440
 
441
- it { is_expected.to eq([{ _visible: true, content_type_id: 1, 'person_id' => 42 }, nil]) }
441
+ it { is_expected.to eq([{ '_visible' => true, 'content_type_id' => 1, 'person_id' => 42 }, nil]) }
442
442
 
443
443
  end
444
444
 
@@ -447,21 +447,21 @@ describe Locomotive::Steam::ContentEntryRepository do
447
447
  let(:value) { [instance_double('TargetContentEntry', _id: 1), instance_double('TargetContentEntry', _id: 2)] }
448
448
  let(:conditions) { { 'person.in' => value } }
449
449
 
450
- it { is_expected.to eq([{ _visible: true, content_type_id: 1, 'person_id.in' => [1, 2] }, nil]) }
450
+ it { is_expected.to eq([{ '_visible' => true, 'content_type_id' => 1, 'person_id.in' => [1, 2] }, nil]) }
451
451
 
452
452
  end
453
453
 
454
454
  context 'testing a nil value (field => nil)' do
455
455
 
456
456
  let(:value) { nil }
457
- it { is_expected.to eq([{ _visible: true, content_type_id: 1, 'person_id' => nil }, nil]) }
457
+ it { is_expected.to eq([{ '_visible' => true, 'content_type_id' => 1, 'person_id' => nil }, nil]) }
458
458
 
459
459
  end
460
460
 
461
461
  context 'testing a nil value (field.ne => nil)' do
462
462
 
463
463
  let(:conditions) { { 'person.ne' => nil } }
464
- it { is_expected.to eq([{ _visible: true, content_type_id: 1, 'person_id.ne' => nil }, nil]) }
464
+ it { is_expected.to eq([{ '_visible' => true, 'content_type_id' => 1, 'person_id.ne' => nil }, nil]) }
465
465
 
466
466
  end
467
467
 
@@ -474,13 +474,13 @@ describe Locomotive::Steam::ContentEntryRepository do
474
474
  let(:_fields) { instance_double('Fields', selects: [], belongs_to: [], many_to_many: [field], dates_and_date_times: []) }
475
475
  let(:conditions) { { 'tags.in' => value } }
476
476
 
477
- it { is_expected.to eq([{ _visible: true, content_type_id: 1, 'tag_ids.in' => [42] }, nil]) }
477
+ it { is_expected.to eq([{ '_visible' => true, 'content_type_id' => 1, 'tag_ids.in' => [42] }, nil]) }
478
478
 
479
479
  context 'the target value is a content entry' do
480
480
 
481
481
  let(:value) { [instance_double('TargetContentEntry', _id: 1), 42] }
482
482
 
483
- it { is_expected.to eq([{ _visible: true, content_type_id: 1, 'tag_ids.in' => [1, 42] }, nil]) }
483
+ it { is_expected.to eq([{ '_visible' => true, 'content_type_id' => 1, 'tag_ids.in' => [1, 42] }, nil]) }
484
484
 
485
485
  end
486
486
 
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.5.0
4
+ version: 1.5.1
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: 2019-11-20 00:00:00.000000000 Z
14
+ date: 2020-01-05 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: rake
@@ -971,7 +971,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
971
971
  - !ruby/object:Gem::Version
972
972
  version: '0'
973
973
  requirements: []
974
- rubygems_version: 3.0.3
974
+ rubygems_version: 3.0.6
975
975
  signing_key:
976
976
  specification_version: 4
977
977
  summary: The LocomotiveCMS Steam is the rendering stack used by both Wagon and Engine