locomotivecms_steam 1.2.0.rc3 → 1.2.0

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: eec023af794726f45fcdf70d6cb85b9874a8b56e
4
- data.tar.gz: 67d5c5968b4597655ead417285dfa9163204d819
3
+ metadata.gz: 55dc6e31d1bf0a7b9713eec9c4e60a825afe2803
4
+ data.tar.gz: c541108e250a7c1b9d4d052bc852d5cac4c9d8f4
5
5
  SHA512:
6
- metadata.gz: e6e0cab759ddd568f92f50dd88a4e1116b09f2ac959908dcf0067da5c4e2d90236fa75d3beabb7c8070fdaee9a8d7015d677b74d29aeb84c00beec500a7ff125
7
- data.tar.gz: 86e838bd1b3db3ff5cd16465c1a0fb2d2ded0000368cbaca310409fc8fd93a93b90bb42e3252dd94313336f27fa7a3e5d3253dc6fd6af1499280ee652a89485e
6
+ metadata.gz: ad6e4a7821c20f1c4029f5dcbcb234fda822d0f65f2f8e2d68c49510a7603933643730224854b35ea9d955c760526a25ed1c3ab5f70524cc2a38d2a889fb8d69
7
+ data.tar.gz: 604e238795bcba4e957f6b662c4aec28a9d6b4c325e0070f2da3bf1a862795b9ff92a1578dbf504ef7fc1293166d54ad51e05d56b423b70561f2edfca3ee0782
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- locomotivecms_steam (1.2.0.rc3)
4
+ locomotivecms_steam (1.2.0)
5
5
  RedCloth (~> 4.3.2)
6
6
  autoprefixer-rails (~> 6.3.3.1)
7
7
  chronic (~> 0.10.2)
@@ -36,7 +36,8 @@ GEM
36
36
  minitest (~> 5.1)
37
37
  thread_safe (~> 0.3, >= 0.3.4)
38
38
  tzinfo (~> 1.1)
39
- addressable (2.4.0)
39
+ addressable (2.5.0)
40
+ public_suffix (~> 2.0, >= 2.0.2)
40
41
  attr_extras (4.4.0)
41
42
  autoprefixer-rails (6.3.3.1)
42
43
  execjs
@@ -121,7 +122,7 @@ GEM
121
122
  multi_xml (0.5.5)
122
123
  nokogiri (1.6.8.1)
123
124
  mini_portile2 (~> 2.1.0)
124
- nokogumbo (1.4.9)
125
+ nokogumbo (1.4.10)
125
126
  nokogiri
126
127
  origin (2.2.0)
127
128
  pony (1.11)
@@ -133,6 +134,7 @@ GEM
133
134
  pry-byebug (3.3.0)
134
135
  byebug (~> 8.0)
135
136
  pry (~> 0.10)
137
+ public_suffix (2.0.4)
136
138
  puma (3.6.0)
137
139
  rack (2.0.1)
138
140
  rack-cache (1.6.1)
@@ -145,7 +147,7 @@ GEM
145
147
  rack_csrf (2.5.0)
146
148
  rack (>= 1.1.0)
147
149
  rake (10.4.2)
148
- rb-fsevent (0.9.7)
150
+ rb-fsevent (0.9.8)
149
151
  rb-inotify (0.9.7)
150
152
  ffi (>= 0.5.0)
151
153
  rspec (3.4.0)
@@ -33,7 +33,9 @@ module Locomotive::Steam
33
33
  # - the type of response asked by the browser (html or json)
34
34
  #
35
35
  def navigation_behavior(entry)
36
- if entry.errors.empty?
36
+ if entry.nil?
37
+ raise 'TODO'
38
+ elsif entry.errors.empty?
37
39
  navigation_success(entry)
38
40
  else
39
41
  navigation_error(entry)
@@ -74,7 +76,7 @@ module Locomotive::Steam
74
76
 
75
77
  def entry_to_query_string(entry)
76
78
  service_params = [
77
- services.csrf_protection.field,
79
+ csrf_field,
78
80
  CONTENT_TYPE_PARAM,
79
81
  SUBMITTED_TYPE_PARAM,
80
82
  SUBMITTED_PARAM,
@@ -139,7 +141,7 @@ module Locomotive::Steam
139
141
  #
140
142
  #
141
143
  def create_entry(slug)
142
- if entry = services.entry_submission.submit(slug, entry_attributes)
144
+ if entry = entry_submission.submit(slug, entry_attributes)
143
145
  entry
144
146
  else
145
147
  raise %{Unknown content type "#{slug}" or public_submission_enabled property not true}
@@ -150,7 +152,7 @@ module Locomotive::Steam
150
152
  #
151
153
  def fetch_entry
152
154
  if (type_slug = params[SUBMITTED_TYPE_PARAM]) && (slug = params[SUBMITTED_PARAM])
153
- if entry = services.entry_submission.find(type_slug, slug)
155
+ if entry = entry_submission.find(type_slug, slug)
154
156
  store_in_liquid(entry)
155
157
  end
156
158
  end
@@ -163,7 +165,7 @@ module Locomotive::Steam
163
165
  # @return [ Array ] The rack response depending on the validation status and the requested format
164
166
  #
165
167
  def json_response(entry, status = 200)
166
- json = services.entry_submission.to_json(entry)
168
+ json = entry_submission.to_json(entry)
167
169
  render_response(json, status, 'application/json')
168
170
  end
169
171
 
@@ -171,6 +173,14 @@ module Locomotive::Steam
171
173
  HashConverter.to_sym(params[:entry] || params[:content] || {})
172
174
  end
173
175
 
176
+ def entry_submission
177
+ services.entry_submission
178
+ end
179
+
180
+ def csrf_field
181
+ services.csrf_protection.field
182
+ end
183
+
174
184
  end
175
185
 
176
186
  end
@@ -3,6 +3,6 @@
3
3
  # 1.0.0-alpha < 1.0.0-alpha.1 < 1.0.0-alpha.beta < 1.0.0-beta < 1.0.0-beta.2 < 1.0.0-beta.11 < 1.0.0-rc.1 < 1.0.0
4
4
  module Locomotive
5
5
  module Steam
6
- VERSION = '1.2.0.rc3'
6
+ VERSION = '1.2.0'
7
7
  end
8
8
  end
@@ -0,0 +1,53 @@
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/entry_submission'
6
+
7
+ describe Locomotive::Steam::Middlewares::EntrySubmission do
8
+
9
+ let(:app) { ->(env) { [200, env, ['app']] } }
10
+ let(:site) { instance_double('Site', default_locale: 'en', locales: ['en']) }
11
+ let(:middleware) { described_class.new(app) }
12
+ let(:service) { instance_double('EntrySubmission') }
13
+ let(:services) { instance_double('Services', entry_submission: service, :locale= => 'en') }
14
+ let(:session) { {} }
15
+ let(:method) { 'POST' }
16
+
17
+ before do
18
+ allow_any_instance_of(described_class).to receive(:csrf_field).and_return('csrf_field')
19
+ end
20
+
21
+ describe '#call' do
22
+
23
+ let(:rack_env) { build_env }
24
+
25
+ before do
26
+ expect(service).to receive(:submit).with('contacts', { email: 'john@doe.net' }).and_return(entry)
27
+ end
28
+
29
+ subject { middleware.call(rack_env) }
30
+
31
+ context 'the creation of a content entry returns nil' do
32
+
33
+ let(:form) { { content_type_slug: 'contacts', content: { email: 'john@doe.net' } } }
34
+ let(:entry) { nil }
35
+
36
+ it 'raises an exception' do
37
+ expect { subject }.to raise_exception('Unknown content type "contacts" or public_submission_enabled property not true')
38
+ end
39
+
40
+ end
41
+
42
+ end
43
+
44
+ def build_env
45
+ env_for('http://example.com/contact-us', params: form, method: method).tap do |env|
46
+ env['steam.request'] = Rack::Request.new(env)
47
+ env['steam.site'] = site
48
+ env['steam.services'] = services
49
+ env['rack.session'] = session
50
+ end
51
+ end
52
+
53
+ end
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.2.0.rc3
4
+ version: 1.2.0
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: 2016-10-26 00:00:00.000000000 Z
14
+ date: 2016-11-22 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: bundler
@@ -794,6 +794,7 @@ files:
794
794
  - spec/unit/liquid/tags/snippet_spec.rb
795
795
  - spec/unit/liquid/tags/with_scope_spec.rb
796
796
  - spec/unit/middlewares/dynamic_assets_spec.rb
797
+ - spec/unit/middlewares/entry_submission_spec.rb
797
798
  - spec/unit/middlewares/helpers_spec.rb
798
799
  - spec/unit/middlewares/locale_redirection_spec.rb
799
800
  - spec/unit/middlewares/page_spec.rb
@@ -845,9 +846,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
845
846
  version: '2.0'
846
847
  required_rubygems_version: !ruby/object:Gem::Requirement
847
848
  requirements:
848
- - - ">"
849
+ - - ">="
849
850
  - !ruby/object:Gem::Version
850
- version: 1.3.1
851
+ version: '0'
851
852
  requirements: []
852
853
  rubyforge_project:
853
854
  rubygems_version: 2.4.5.1
@@ -1055,6 +1056,7 @@ test_files:
1055
1056
  - spec/unit/liquid/tags/snippet_spec.rb
1056
1057
  - spec/unit/liquid/tags/with_scope_spec.rb
1057
1058
  - spec/unit/middlewares/dynamic_assets_spec.rb
1059
+ - spec/unit/middlewares/entry_submission_spec.rb
1058
1060
  - spec/unit/middlewares/helpers_spec.rb
1059
1061
  - spec/unit/middlewares/locale_redirection_spec.rb
1060
1062
  - spec/unit/middlewares/page_spec.rb