amfetamine 0.3.2 → 0.3.3

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.
@@ -0,0 +1,40 @@
1
+ ## 0.3.3
2
+
3
+ * fix for double Array error messages bug for remote (server) validations [Issue #6]
4
+
5
+ ## 0.3.2
6
+
7
+ * fix for Object#save return value with disabled caching
8
+
9
+ ## 0.3.1
10
+
11
+ * `memcached_instance` Dalli::Client configuration setting changes (it should now start with "memcached://")
12
+
13
+ ## 0.3.0
14
+
15
+ * Caching is now turned off by default in Rails development/test modes
16
+ * Add `class_name` and `foreign_key` options to relationships, which allows mapping resources to local Amfetamine classes with different names
17
+
18
+ ## 0.2.12
19
+
20
+ * Add abillity to deactivate caching, using `disable_caching=` on either the config or an object
21
+ * Starting builds against other ruby versions
22
+
23
+ ## 0.2.11
24
+
25
+ * Rewrote specs to be idempotent when randomized
26
+ * Fixed a lot of specs for travis in general
27
+
28
+ ## 0.2.10
29
+
30
+ * Removed verbosity from tests
31
+ * Dropped support for Ruby 1.8.7
32
+ * Sourcecode is now available on github
33
+
34
+ ## 0.2.9
35
+
36
+ * Cleaning up
37
+
38
+ ## 0.2.8
39
+
40
+ * Attributes are now set dynamically. This **overrides** anything you set on `amfetamine_attributes`. This should reduce a lot of bloat.
@@ -28,8 +28,10 @@ module Amfetamine
28
28
  true
29
29
  when :errors
30
30
  Amfetamine.logger.warn "Errors from response\n #{response[:body]}"
31
- response[:body].each do |attr, mesg|
32
- errors.add(attr.to_sym, mesg )
31
+ response[:body].each do |attr, error_messages|
32
+ error_messages.each do |msg|
33
+ errors.add(attr.to_sym, msg)
34
+ end
33
35
  end
34
36
  false
35
37
  when :server_error
@@ -1,3 +1,3 @@
1
1
  module Amfetamine
2
- VERSION = "0.3.2"
2
+ VERSION = "0.3.3"
3
3
  end
@@ -14,7 +14,7 @@ describe Amfetamine::Base do
14
14
 
15
15
  end
16
16
 
17
- describe "Class dummy, setup with amfetamine::base" do
17
+ describe "Class dummy, setup with Amfetamine::Base" do
18
18
  let(:dummy) { build(:dummy) }
19
19
  let(:dummy2) { build(:dummy) }
20
20
  subject { Dummy}
@@ -83,7 +83,6 @@ describe Amfetamine::Base do
83
83
  it "should create an object if data is correct" do
84
84
  Dummy.prevent_external_connections! do |r|
85
85
  r.post(:code => 201) {}
86
-
87
86
  new_dummy = Dummy.create({:title => 'test', :description => 'blabla'})
88
87
  new_dummy.should be_a(Dummy)
89
88
  new_dummy.should_not be_new
@@ -91,15 +90,22 @@ describe Amfetamine::Base do
91
90
  end
92
91
  end
93
92
 
94
- it "should return errors if data is incorrect" do
93
+ it "sets errors hash if local validations fail" do
94
+ new_dummy = Dummy.create({ title: 'test' })
95
+ new_dummy.should be_new
96
+ new_dummy.errors.messages.should eql({ description: ["can't be blank"] })
97
+ new_dummy.should_not be_cached
98
+ end
99
+
100
+ it "sets errors hash if remote validations fail" do
101
+ error_message = "has already been taken"
95
102
  Dummy.prevent_external_connections! do |r|
96
- r.post(:code => 422) {{:description => ['can\'t be blank']}}
97
- new_dummy = Dummy.create({:title => 'test'})
103
+ r.post(code: 422) { { title: [error_message] } }
104
+ new_dummy = Dummy.create({ title: 'test', description: 'test' })
98
105
  new_dummy.should be_new
99
- new_dummy.errors.messages.should eq({:description => ['can\'t be blank']})
106
+ new_dummy.errors.messages.should eql({ title: [error_message] })
100
107
  new_dummy.should_not be_cached
101
108
  end
102
-
103
109
  end
104
110
  end
105
111
 
@@ -127,15 +133,18 @@ describe Amfetamine::Base do
127
133
  Dummy.disable_caching = false
128
134
  end
129
135
 
130
- it "should show errors if response is not succesful" do
131
- Dummy.prevent_external_connections! do |r|
132
- r.put(:code => 422) { [:title => ['can\'t be blank']]}
136
+ it "sets errors hash if local validations fail" do
137
+ dummy.update_attributes({ title: "" })
138
+ dummy.errors.messages.should eql({ title: ["can't be blank"] })
139
+ end
133
140
 
134
- dummy.update_attributes({:title => ''})
141
+ it "sets errors hash if remote validations fail" do
142
+ error_message = "has already been taken"
143
+ Dummy.prevent_external_connections! do |r|
144
+ r.put(code: 422) { { title: [error_message] } }
145
+ dummy.update_attributes({ title: "abc" })
146
+ dummy.errors.messages.should eql({ title: [error_message] })
135
147
  end
136
-
137
- dummy.should_not be_new
138
- dummy.errors.messages.should eq({:title => ['can\'t be blank']})
139
148
  end
140
149
 
141
150
  it "should not do a request if the data doesn't change" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: amfetamine
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-09-13 00:00:00.000000000 Z
13
+ date: 2012-09-14 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rspec
@@ -280,7 +280,7 @@ files:
280
280
  - .rspec
281
281
  - .travis.yml
282
282
  - .vagrant
283
- - CHANGELOG
283
+ - CHANGELOG.md
284
284
  - Gemfile
285
285
  - README.md
286
286
  - Rakefile
@@ -333,7 +333,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
333
333
  version: '0'
334
334
  segments:
335
335
  - 0
336
- hash: 2740467481176466622
336
+ hash: 1384160561817165326
337
337
  required_rubygems_version: !ruby/object:Gem::Requirement
338
338
  none: false
339
339
  requirements:
@@ -342,7 +342,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
342
342
  version: '0'
343
343
  segments:
344
344
  - 0
345
- hash: 2740467481176466622
345
+ hash: 1384160561817165326
346
346
  requirements: []
347
347
  rubyforge_project: amfetamine
348
348
  rubygems_version: 1.8.24
data/CHANGELOG DELETED
@@ -1,28 +0,0 @@
1
- 0.3.2
2
- - fix for Object#save return value with disabled caching
3
-
4
- 0.3.1
5
- - memcached_instance Dalli::Client configuration setting changes (it should now start with "memcached://")
6
-
7
- 0.3.0
8
- - Caching is now turned off by default in Rails development/test modes
9
- - Add `class_name` and `foreign_key` options to relationships, which allows mapping resources to local Amfetamine classes with different names
10
-
11
- 0.2.12
12
- - Add abillity to deactivate caching, using disable_caching= on either the config or an object.
13
- - Starting builds against other ruby versions
14
-
15
- 0.2.11
16
- - Rewrote specs to be idempotent when randomized
17
- - Fixed a lot of specs for travis in general
18
-
19
- 0.2.10
20
- - Removed verbosity from tests
21
- - Dropped support for Ruby 1.8.7
22
- - Sourcecode is now available on github
23
-
24
- 0.2.9
25
- - Cleaning up
26
-
27
- 0.2.8
28
- - Attributes are now set dynamically. This OVERIDES anything you set on 'amfetamine_attributes'. This should reduce a lot of bloat.