activeresource-response 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.travis.yml CHANGED
@@ -3,5 +3,5 @@ rvm:
3
3
  - 1.9.3
4
4
  - jruby-19mode
5
5
  - rbx-19mode
6
- - ruby-head
6
+ - 2.0.0
7
7
  - jruby-head
@@ -0,0 +1,31 @@
1
+ #--
2
+ # Copyright (c) 2012 Igor Fedoronchuk
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining
5
+ # a copy of this software and associated documentation files (the
6
+ # "Software"), to deal in the Software without restriction, including
7
+ # without limitation the rights to use, copy, modify, merge, publish,
8
+ # distribute, sublicense, and/or sell copies of the Software, and to
9
+ # permit persons to whom the Software is furnished to do so, subject to
10
+ # the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be
13
+ # included in all copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ #++
23
+
24
+ module ActiveResourceResponse
25
+ module Lint
26
+ def to_key
27
+ return nil unless persisted?
28
+ super
29
+ end
30
+ end
31
+ end
@@ -59,8 +59,7 @@ module ActiveResourceResponse
59
59
  end
60
60
 
61
61
  def wrap_result(result)
62
-
63
- result = SimpleDelegator.new(result)
62
+ result = SimpleDelegator.new(result) unless result.is_a?(ActiveResource::Base)
64
63
  result.instance_variable_set(:@http_response, connection.http_response)
65
64
  result.singleton_class.send(:define_method, self.http_response_method) do
66
65
  @http_response
@@ -23,6 +23,6 @@
23
23
 
24
24
  module ActiveResourceResponse
25
25
  module Version
26
- VERSION = "1.0.0"
26
+ VERSION = "1.0.1"
27
27
  end
28
28
  end
@@ -151,5 +151,10 @@ class ActiveResourceResponseTest < Test::Unit::TestCase
151
151
  region = Region.find(1)
152
152
  assert region.respond_to?(ActiveResourceResponseBase.http_response_method)
153
153
  end
154
+
155
+ def test_active_model_naming_methods
156
+ street = Country.find(1)
157
+ assert street.class.respond_to?(:model_name)
158
+ end
154
159
 
155
160
  end
data/test/lint_test.rb ADDED
@@ -0,0 +1,56 @@
1
+ #--
2
+ # Copyright (c) 2012 Igor Fedoronchuk
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining
5
+ # a copy of this software and associated documentation files (the
6
+ # "Software"), to deal in the Software without restriction, including
7
+ # without limitation the rights to use, copy, modify, merge, publish,
8
+ # distribute, sublicense, and/or sell copies of the Software, and to
9
+ # permit persons to whom the Software is furnished to do so, subject to
10
+ # the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be
13
+ # included in all copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ #++
23
+
24
+ lib = File.expand_path("#{File.dirname(__FILE__)}/../lib")
25
+ unit_tests = File.expand_path("#{File.dirname(__FILE__)}/../test")
26
+ $:.unshift(lib)
27
+ $:.unshift(unit_tests)
28
+
29
+
30
+ require 'active_resource_response'
31
+ require "fixtures/country"
32
+ require "fixtures/city"
33
+ require "fixtures/region"
34
+ require "fixtures/street"
35
+
36
+ require "active_resource_response/http_mock"
37
+
38
+
39
+ #made pass lint test because of "to_key should return nil when `persisted?` returns false" error
40
+ require "active_resource_response/lint"
41
+ ActiveResource::Base.send :include, ActiveResourceResponse::Lint
42
+
43
+ class ActiveResourceResponseLintTest < Test::Unit::TestCase
44
+
45
+ include ActiveModel::Lint::Tests
46
+
47
+ def setup
48
+ @street = {:street => {:id => 1, :name => "Deribasovskaya", :population => 2300}}
49
+ ActiveResource::HttpMock.respond_to do |mock|
50
+ mock.get "/streets/1.json", {}, @street.to_json, 200, {"X-total"=>'1'}
51
+ end
52
+ @model = Street.find(1)
53
+
54
+ end
55
+ end
56
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activeresource-response
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-08-15 00:00:00.000000000 Z
12
+ date: 2013-10-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activeresource
16
- requirement: &70196300726880 !ruby/object:Gem::Requirement
16
+ requirement: &70103018809720 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 4.0.0
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70196300726880
24
+ version_requirements: *70103018809720
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: test-unit
27
- requirement: &70196300725540 !ruby/object:Gem::Requirement
27
+ requirement: &70103018814480 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70196300725540
35
+ version_requirements: *70103018814480
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rake
38
- requirement: &70196300738620 !ruby/object:Gem::Requirement
38
+ requirement: &70103018825340 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,7 +43,7 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70196300738620
46
+ version_requirements: *70103018825340
47
47
  description: ! 'This gem adds possibility to access http response object from result
48
48
  of ActiveResource::Base find method '
49
49
  email:
@@ -64,6 +64,7 @@ files:
64
64
  - lib/active_resource_response/custom_methods.rb
65
65
  - lib/active_resource_response/http_mock.rb
66
66
  - lib/active_resource_response/http_response.rb
67
+ - lib/active_resource_response/lint.rb
67
68
  - lib/active_resource_response/response_method.rb
68
69
  - lib/active_resource_response/version.rb
69
70
  - lib/activeresource-response.rb
@@ -72,6 +73,7 @@ files:
72
73
  - test/fixtures/country.rb
73
74
  - test/fixtures/region.rb
74
75
  - test/fixtures/street.rb
76
+ - test/lint_test.rb
75
77
  homepage: http://fivell.github.com/activeresource-response/
76
78
  licenses: []
77
79
  post_install_message:
@@ -104,4 +106,5 @@ test_files:
104
106
  - test/fixtures/country.rb
105
107
  - test/fixtures/region.rb
106
108
  - test/fixtures/street.rb
109
+ - test/lint_test.rb
107
110
  has_rdoc: