sbsm 1.5.7 → 1.5.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/History.txt +4 -0
- data/lib/sbsm/app.rb +2 -2
- data/lib/sbsm/version.rb +1 -1
- data/test/test_application.rb +43 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dba5e15c9cf2727c59c4b7cfe76f50130e3e0ed6
|
4
|
+
data.tar.gz: 6e20e7c5cc26fac33046dc1163c6499a095067ee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5ed488a5d66ba9297899f60d6b49f56030c063d72beefa81107e82386c51e82fc535701e1c198a80e35744732704240665813909aa9a0e949fba76d5e141b926
|
7
|
+
data.tar.gz: 23e5429ccfc47cd67d052eab84e7d945f3bf3ffe4538bd956445fed7a8db7de7277000d6d9292e120045de1fb236feea9a1f725679c5946488173b0e999d50a9
|
data/History.txt
CHANGED
data/lib/sbsm/app.rb
CHANGED
@@ -108,8 +108,8 @@ module SBSM
|
|
108
108
|
end
|
109
109
|
|
110
110
|
if File.file?(file_name)
|
111
|
-
if File.extname(file_name).length > 0
|
112
|
-
mime_type =
|
111
|
+
if File.extname(file_name).length > 0 && (mime_info = MimeMagic.by_extension(File.extname(file_name)))
|
112
|
+
mime_type = mime_info.type
|
113
113
|
else
|
114
114
|
mime_type = MimeMagic.by_path(file_name)
|
115
115
|
end
|
data/lib/sbsm/version.rb
CHANGED
data/test/test_application.rb
CHANGED
@@ -75,6 +75,48 @@ class AppVariantTest < Minitest::Test
|
|
75
75
|
assert last_response.headers.keys.index('Content-Type')
|
76
76
|
assert_equal('text/html', last_response.headers['Content-Type'])
|
77
77
|
end
|
78
|
+
def test_request_file_with_no_mime_info
|
79
|
+
session_id_mock = '1234'
|
80
|
+
invalid_path = '/window.js.map.dummy'
|
81
|
+
file_name = File.expand_path(File.join('doc', invalid_path))
|
82
|
+
FileUtils.makedirs(File.dirname(file_name))
|
83
|
+
File.open(file_name, 'w+') {|f| f.puts 'dummy'}
|
84
|
+
|
85
|
+
@app = flexmock('file_app', @app)
|
86
|
+
env = { 'HTTP_COOKIE' => "_session_id=#{session_id_mock}" }
|
87
|
+
session_store = SBSM::SessionStore.new(app: @app)
|
88
|
+
session_mock= flexmock('session', session_store[session_id_mock.to_s])
|
89
|
+
session_mock.should_receive(:get_passthru).and_return([invalid_path])
|
90
|
+
@app.should_receive(:session_store).and_return(session_store)
|
91
|
+
|
92
|
+
result = get invalid_path, {}, env
|
93
|
+
|
94
|
+
assert_equal(true, last_response.ok?)
|
95
|
+
assert last_response.headers.keys.index('Content-Type')
|
96
|
+
assert_equal('text/plain', last_response.headers['Content-Type'])
|
97
|
+
FileUtils.rm(file_name)
|
98
|
+
end
|
99
|
+
def test_request_file_with_mime_info
|
100
|
+
session_id_mock = '1234'
|
101
|
+
invalid_path = '/window.png'
|
102
|
+
file_name = File.expand_path(File.join('doc', invalid_path))
|
103
|
+
FileUtils.makedirs(File.dirname(file_name))
|
104
|
+
File.open(file_name, 'w+') {|f| f.puts 'dummy'}
|
105
|
+
|
106
|
+
@app = flexmock('file_app', @app)
|
107
|
+
env = { 'HTTP_COOKIE' => "_session_id=#{session_id_mock}" }
|
108
|
+
session_store = SBSM::SessionStore.new(app: @app)
|
109
|
+
session_mock= flexmock('session', session_store[session_id_mock.to_s])
|
110
|
+
session_mock.should_receive(:get_passthru).and_return([invalid_path])
|
111
|
+
@app.should_receive(:session_store).and_return(session_store)
|
112
|
+
|
113
|
+
result = get invalid_path, {}, env
|
114
|
+
|
115
|
+
assert_equal(true, last_response.ok?)
|
116
|
+
assert last_response.headers.keys.index('Content-Type')
|
117
|
+
assert_equal('image/png', last_response.headers['Content-Type'])
|
118
|
+
FileUtils.rm(file_name)
|
119
|
+
end
|
78
120
|
end
|
79
121
|
|
80
122
|
class AppTestSimple < Minitest::Test
|
@@ -133,6 +175,7 @@ class AppTestSimple < Minitest::Test
|
|
133
175
|
get '/sbsm.css'
|
134
176
|
assert last_response.ok?
|
135
177
|
assert_match css_content, last_response.body
|
178
|
+
FileUtils.rm(css_file)
|
136
179
|
end
|
137
180
|
def test_session_about_then_home
|
138
181
|
skip ('TODO: We should test test_post_feedback')
|