snapimage 0.2.0 → 0.2.1
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.
- data/lib/snapimage/server.rb +2 -2
- data/lib/snapimage/version.rb +1 -1
- data/spec/snapimage/server_spec.rb +16 -0
- metadata +8 -2
data/lib/snapimage/server.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module SnapImage
|
2
2
|
class Server
|
3
|
-
DIRECTORY_REGEXP = /^[a-z0-9_-]+(\/[a-z0-9_-]+)*$/
|
4
|
-
FILENAME_REGEXP = /^[^\/]+[.](gif|jpg|jpeg|png)$/
|
3
|
+
DIRECTORY_REGEXP = /^[a-z0-9_-]+(\/[a-z0-9_-]+)*$/i
|
4
|
+
FILENAME_REGEXP = /^[^\/]+[.](gif|jpg|jpeg|png)$/i
|
5
5
|
|
6
6
|
# Arguments:
|
7
7
|
# * request:: Rack::Request
|
data/lib/snapimage/version.rb
CHANGED
@@ -72,6 +72,22 @@ describe SnapImage::Server do
|
|
72
72
|
response[2].body.should eq ['{"status_code":200,"url":"http://snapimage.com/public/abc/123/abc123.png","message":"Success"}']
|
73
73
|
end
|
74
74
|
|
75
|
+
it "returns success when uppercase" do
|
76
|
+
@request.stub(:bad_request?).and_return(false)
|
77
|
+
tempfile = double("tempfile")
|
78
|
+
tempfile.stub(:size).and_return(50)
|
79
|
+
file = double("file")
|
80
|
+
file.stub(:filename).and_return("abc123.PNG")
|
81
|
+
file.stub(:tempfile).and_return(tempfile)
|
82
|
+
@request.stub(:file).and_return(file)
|
83
|
+
@request.stub(:[]).with("directory").and_return("ABC/123")
|
84
|
+
@storage.should_receive(:store).with("abc123.PNG", tempfile, directory: "ABC/123").and_return("http://snapimage.com/public/ABC/123/abc123.PNG")
|
85
|
+
response = @server.call
|
86
|
+
response[0].should eq 200
|
87
|
+
response[1]["Content-Type"].should eq "text/json"
|
88
|
+
response[2].body.should eq ['{"status_code":200,"url":"http://snapimage.com/public/ABC/123/abc123.PNG","message":"Success"}']
|
89
|
+
end
|
90
|
+
|
75
91
|
it "returns content type of text/html when non-XHR" do
|
76
92
|
@request.stub(:xhr?).and_return(false)
|
77
93
|
@request.stub(:bad_request?).and_return(false)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: snapimage
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-09-
|
12
|
+
date: 2013-09-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rack
|
@@ -200,12 +200,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
200
200
|
- - ! '>='
|
201
201
|
- !ruby/object:Gem::Version
|
202
202
|
version: '0'
|
203
|
+
segments:
|
204
|
+
- 0
|
205
|
+
hash: 988960603682058261
|
203
206
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
204
207
|
none: false
|
205
208
|
requirements:
|
206
209
|
- - ! '>='
|
207
210
|
- !ruby/object:Gem::Version
|
208
211
|
version: '0'
|
212
|
+
segments:
|
213
|
+
- 0
|
214
|
+
hash: 988960603682058261
|
209
215
|
requirements: []
|
210
216
|
rubyforge_project:
|
211
217
|
rubygems_version: 1.8.23
|