logical_model 0.3.5 → 0.3.6
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/logical_model.rb +1 -1
- data/logical_model.gemspec +2 -2
- data/spec/client_spec.rb +45 -17
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.6
|
data/lib/logical_model.rb
CHANGED
@@ -448,7 +448,7 @@ class LogicalModel
|
|
448
448
|
Timeout::timeout(self.class.timeout/1000) do
|
449
449
|
response = Typhoeus::Request.post( self.class.resource_uri, :body => params, :timeout => self.class.timeout )
|
450
450
|
end
|
451
|
-
if response.code == 201
|
451
|
+
if response.code == 201 || response.code == 202
|
452
452
|
log_ok(response)
|
453
453
|
if self.respond_to?('id=')
|
454
454
|
self.id = ActiveSupport::JSON.decode(response.body)["id"]
|
data/logical_model.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "logical_model"
|
8
|
-
s.version = "0.3.
|
8
|
+
s.version = "0.3.6"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Dwayne Macgowan"]
|
12
|
-
s.date = "2012-
|
12
|
+
s.date = "2012-10-05"
|
13
13
|
s.description = "LogicalModel allows to use a resource as a model. It is based on web presentation http://www.slideshare.net/ihower/serviceoriented-design-and-implement-with-rails3"
|
14
14
|
s.email = "dwaynemac@gmail.com"
|
15
15
|
s.extra_rdoc_files = [
|
data/spec/client_spec.rb
CHANGED
@@ -7,23 +7,51 @@ describe "LogicalModel User client" do
|
|
7
7
|
|
8
8
|
describe "#create" do
|
9
9
|
context "with valid attributes" do
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
10
|
+
context "if response is code 201" do
|
11
|
+
before(:each) do
|
12
|
+
mock_post_with(code: 201, body: {'id' => 3}.to_json)
|
13
|
+
@user = User.new({:name => "paul",
|
14
|
+
:email => "paul@pauldix.net",
|
15
|
+
:password => "strongpass",
|
16
|
+
:bio => "rubyist"})
|
17
|
+
@ret = @user.create
|
18
|
+
end
|
19
|
+
it "should create a user" do
|
20
|
+
@user.should_not be_nil
|
21
|
+
end
|
22
|
+
it "should set an id" do
|
23
|
+
@user.id.should_not be_nil
|
24
|
+
end
|
25
|
+
it "should hace the same attributes as passed" do
|
26
|
+
@user.name.should == "paul"
|
27
|
+
@user.email == "paul@pauldix.net"
|
28
|
+
end
|
29
|
+
it "should return true" do
|
30
|
+
@ret.should be_true
|
31
|
+
end
|
32
|
+
end
|
33
|
+
context "if response is code 202" do
|
34
|
+
before(:each) do
|
35
|
+
mock_post_with(code: 202, body: {'id' => 3}.to_json)
|
36
|
+
@user = User.new({:name => "paul",
|
37
|
+
:email => "paul@pauldix.net",
|
38
|
+
:password => "strongpass",
|
39
|
+
:bio => "rubyist"})
|
40
|
+
@ret = @user.create
|
41
|
+
end
|
42
|
+
it "should create a user" do
|
43
|
+
@user.should_not be_nil
|
44
|
+
end
|
45
|
+
it "should set an id" do
|
46
|
+
@user.id.should_not be_nil
|
47
|
+
end
|
48
|
+
it "should hace the same attributes as passed" do
|
49
|
+
@user.name.should == "paul"
|
50
|
+
@user.email == "paul@pauldix.net"
|
51
|
+
end
|
52
|
+
it "should return true" do
|
53
|
+
@ret.should be_true
|
54
|
+
end
|
27
55
|
end
|
28
56
|
end
|
29
57
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logical_model
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.6
|
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: 2012-
|
12
|
+
date: 2012-10-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activemodel
|
@@ -346,7 +346,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
346
346
|
version: '0'
|
347
347
|
segments:
|
348
348
|
- 0
|
349
|
-
hash: -
|
349
|
+
hash: -376720147
|
350
350
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
351
351
|
none: false
|
352
352
|
requirements:
|