sbsm 1.5.8 → 1.5.9

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: dba5e15c9cf2727c59c4b7cfe76f50130e3e0ed6
4
- data.tar.gz: 6e20e7c5cc26fac33046dc1163c6499a095067ee
3
+ metadata.gz: 6f2ae1755e50072d0307ecbe9c57c67c1b4a891a
4
+ data.tar.gz: 1b2e7d58d1b60cc487248e1123a8422cf051fd4a
5
5
  SHA512:
6
- metadata.gz: 5ed488a5d66ba9297899f60d6b49f56030c063d72beefa81107e82386c51e82fc535701e1c198a80e35744732704240665813909aa9a0e949fba76d5e141b926
7
- data.tar.gz: 23e5429ccfc47cd67d052eab84e7d945f3bf3ffe4538bd956445fed7a8db7de7277000d6d9292e120045de1fb236feea9a1f725679c5946488173b0e999d50a9
6
+ metadata.gz: 1e092d40cc433c228137788cbc01e79a2e31cb03d3c84ae51d6ad0c3c686241aead506e2baeabe841c58dc0b226616ab444324961e7607ab8e5034eb66157924
7
+ data.tar.gz: a430f249b35eed0d1b7514f352a8b4dfe27cd7f1d60efec3d4ca856884eb8756f7e28b81184b392707247f156923431d9b9a6d671935b60453cef4cba4591383
@@ -1,3 +1,9 @@
1
+ === 1.5.9 / 30.08.2017
2
+
3
+ * Fix recognition whether we are using HTTPS or not
4
+ * Fix using http_headers in views
5
+ * Allow non standard HTTP-Port
6
+
1
7
  === 1.5.8 / 8.08.2017
2
8
 
3
9
  * Fix recognizing mime type for unusual extensions
@@ -54,7 +54,8 @@ module SBSM
54
54
  self::class::HTML_ATTRIBUTES.fetch(key.to_sym, {}).dup rescue {}
55
55
  end
56
56
  def base_url
57
- [@session.http_protocol + ':/', @session.server_name, @language, @flavor].compact.join("/")
57
+ maybe_port = @session.server_port ? (":" + @session.server_port ) : ''
58
+ [@session.http_protocol + ':/', @session.server_name + maybe_port, @language, @flavor].compact.join("/")
58
59
  end
59
60
  def direct_event
60
61
  @session.direct_event
@@ -88,7 +89,7 @@ module SBSM
88
89
  @languages ||= self::class::DICTIONARIES.keys.sort
89
90
  end
90
91
  def language_url(language)
91
- [@session.http_protocol + ':/', @session.server_name, language, @flavor].compact.join("/")
92
+ base_url
92
93
  end
93
94
  def lookup(key, *args, &block)
94
95
  _lookup(key, *args) || (block.call if block)
@@ -166,9 +167,8 @@ module SBSM
166
167
  end
167
168
  end
168
169
  def _collect_resource(base, part, rstr)
169
- [ @session.http_protocol + ':/',
170
- @session.server_name,
171
- base, part, rstr].flatten.compact.join('/')
170
+ maybe_port = @session.server_port ? (":" + @session.server_port ) : ''
171
+ [ @session.http_protocol + ':/', @session.server_name + maybe_port, base, part, rstr].flatten.compact.join('/')
172
172
  end
173
173
  def set_dictionary(language)
174
174
  @dictionary = self::class::DICTIONARIES[language] || {}
@@ -213,7 +213,6 @@ module SBSM
213
213
  @rack_request = rack_request
214
214
  @request_path ||= rack_request.path
215
215
  @post_content = nil
216
-
217
216
  if rack_request.request_method.eql?('POST')
218
217
  rack_request.params.each do |k, v|
219
218
  # needed to test POST requests generated by curl (first parameter) or ARC (second parameter)
@@ -463,7 +462,7 @@ module SBSM
463
462
  {'Content-Type' => 'text/plain'}
464
463
  end
465
464
  def http_protocol
466
- @http_protocol ||= if(@server_port && @server_port == 443) || ENV['SERVER_PORT']
465
+ @http_protocol ||= if(@server_port && @server_port.to_i == 443) || ENV['SERVER_PORT']
467
466
  'https'
468
467
  else
469
468
  'http'
@@ -112,7 +112,7 @@ module SBSM
112
112
  end
113
113
  end
114
114
  seconds = (Time.now.to_i - now.to_i)
115
- SBSM.warn sprintf("Cleaned #{old_size - @@sessions.size} sessions. Took %d seconds", seconds)
115
+ # SBSM.warn sprintf("Cleaned #{old_size - @@sessions.size} sessions. Took %d seconds", seconds)
116
116
  end
117
117
  def SessionStore.sessions
118
118
  @@sessions
@@ -135,7 +135,8 @@ module SBSM
135
135
  def http_headers
136
136
  return @http_headers if @http_headers
137
137
  name = view
138
- name ? view.http_headers : {}
138
+ result = name ? view.http_headers : {}
139
+ result
139
140
  end
140
141
  def info?
141
142
  !@infos.empty?
@@ -1,3 +1,3 @@
1
1
  module SBSM
2
- VERSION = '1.5.8'
2
+ VERSION = '1.5.9'
3
3
  end
@@ -69,15 +69,20 @@ module Demo
69
69
  info.join("\n")
70
70
  end
71
71
  end
72
+ class AboutView
73
+ def initialize(model, session)
74
+ end
75
+ def to_html(cgi)
76
+ 'About SBSM: TDD ist great!'
77
+ end
78
+ end
72
79
  class AboutState < GlobalState
73
80
  DIRECT_EVENT = :about
81
+ VIEW = AboutView
74
82
  def initialize(session, user)
75
83
  SBSM.info "AboutState #{session}"
76
84
  super(session, user)
77
85
  end
78
- def to_html(cgi)
79
- 'About SBSM: TDD ist great!'
80
- end
81
86
  end
82
87
  class RedirectState < GlobalState
83
88
  DIRECT_EVENT = :redirect
@@ -239,4 +244,4 @@ module Demo
239
244
  session_class: session_class)
240
245
  end
241
246
  end
242
- end
247
+ end
@@ -16,19 +16,27 @@ RUN_ALL_TESTS=true unless defined?(RUN_ALL_TESTS)
16
16
 
17
17
  # Overriding some stuff from the simple_sbsm
18
18
  module Demo
19
+ class View_AboutState
20
+ def initialize(model, session)
21
+ end
22
+ def http_headers
23
+ { "foo" => "bar" }
24
+ end
25
+ def to_html(cgi)
26
+ "<br>customized to_html<br>"
27
+ end
28
+ end
29
+
19
30
  class AboutState < GlobalState
20
31
  DIRECT_EVENT = :about
32
+ VIEW = View_AboutState
21
33
  def initialize(session, user)
22
34
  SBSM.info "AboutState #{session}"
23
35
  super(session, user)
24
36
  session.login
25
37
  end
26
- def http_headers
27
- { "foo" => "bar" }
28
- end
29
38
  end
30
39
 
31
-
32
40
  DEMO_PERSISTENT_COOKIE_NAME = 'demo-simple-sbsm'
33
41
  class Demo::CustomizedSBSM_COOKIE < SBSM::App
34
42
  PERSISTENT_COOKIE_NAME = DEMO_PERSISTENT_COOKIE_NAME
@@ -201,6 +209,7 @@ class CustomizedAppSessionValidatorLnf < Minitest::Test
201
209
  end
202
210
  assert last_response.ok?
203
211
  assert_equal 'bar', last_response.headers['foo']
212
+ assert_equal '<br>customized to_html<br>', last_response.body
204
213
  end
205
214
 
206
215
  def test_process_state
@@ -69,6 +69,9 @@ class StubLookandfeelSession
69
69
  def flavor
70
70
  "gcc"
71
71
  end
72
+ def server_port
73
+ "1234"
74
+ end
72
75
  def server_name
73
76
  "test.com"
74
77
  end
@@ -127,7 +130,7 @@ class TestLookandfeel < Minitest::Test
127
130
  assert_equal({}, @lookandfeel.attributes(:undefined))
128
131
  end
129
132
  def test_resource
130
- assert_equal('http://test.com/resources/gcc/bar', @lookandfeel.resource(:foo))
133
+ assert_equal('http://test.com:1234/resources/gcc/bar', @lookandfeel.resource(:foo))
131
134
  end
132
135
  def test_lookup
133
136
  assert_equal('dictbar', @lookandfeel.lookup(:foo))
@@ -161,18 +164,18 @@ class TestLookandfeel < Minitest::Test
161
164
  assert_equal(expected, time.rfc1123)
162
165
  end
163
166
  def test_base_url
164
- assert_equal("http://test.com/de/gcc", @lookandfeel.base_url)
167
+ assert_equal("http://test.com:1234/de/gcc", @lookandfeel.base_url)
165
168
  end
166
169
  def test_event_url
167
- assert_match(/http:\/\/test.com\/de\/gcc\/foo\/state_id\/\d\/bar\/baz/,@lookandfeel.event_url(:foo, {:bar => 'baz'}))
170
+ assert_match(/http:\/\/test.com:1234\/de\/gcc\/foo\/state_id\/\d\/bar\/baz/,@lookandfeel.event_url(:foo, {:bar => 'baz'}))
168
171
  end
169
172
  def test_event_url__crawler
170
173
  @session.is_crawler = true
171
- assert_equal("http://test.com/de/gcc/foo/bar/baz",
174
+ assert_equal("http://test.com:1234/de/gcc/foo/bar/baz",
172
175
  @lookandfeel.event_url(:foo, {:bar => 'baz'}))
173
176
  end
174
177
  def test_event_url__state_id_given
175
- assert_equal("http://test.com/de/gcc/foo/bar/baz/state_id/mine",
178
+ assert_equal("http://test.com:1234/de/gcc/foo/bar/baz/state_id/mine",
176
179
  @lookandfeel.event_url(:foo, [:bar, 'baz', :state_id, 'mine']))
177
180
  end
178
181
  def test_format_price
@@ -214,10 +217,10 @@ class TestLookandfeelWrapper < Minitest::Test
214
217
  end
215
218
  def test_resource1
216
219
  lnf = SBSM::LookandfeelWrapper.new(@lookandfeel)
217
- assert_equal('http://test.com/resources/gcc/bar', lnf.resource(:foo))
220
+ assert_equal('http://test.com:1234/resources/gcc/bar', lnf.resource(:foo))
218
221
  end
219
222
  def test_resource2
220
- assert_equal('http://test.com/resources/gcc/foo', @wrapped.resource(:foo))
223
+ assert_equal('http://test.com:1234/resources/gcc/foo', @wrapped.resource(:foo))
221
224
  end
222
225
  def test_attributes1
223
226
  lnf = SBSM::LookandfeelWrapper.new(@lookandfeel)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sbsm
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.8
4
+ version: 1.5.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Masaomi Hatakeyama, Zeno R.R. Davatz
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-08-08 00:00:00.000000000 Z
11
+ date: 2017-08-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack