fakturan_nu 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/fakturan_nu.gemspec +1 -1
- data/test/exceptions_test.rb +10 -0
- data/test/fixtures.rb +17 -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: b13585e5fc6be9909753083863eda66758b826d7
|
4
|
+
data.tar.gz: 9b8a8ce02f6e623bd01f3f7f1ca0bc4b5105d6be
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 91aa5a0c02ec650d3de08b278223fe165b146ab7f21cde3149e592c39ce3c616c90869b41329fbb2198df6136d2ccb5cb9e654d43c5834b14e2b5e01428f5f4c
|
7
|
+
data.tar.gz: 9b2cf0b37560c8b21466f15781c52e0a7401b1469ed312c00a804ad50fdf7b0f179374162a735cee434ffea090e87366c9c129410716b2129a5aa4e3c576a561
|
data/fakturan_nu.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
Gem::Specification.new do |s|
|
3
3
|
s.name = 'fakturan_nu'
|
4
|
-
s.version = '1.1.
|
4
|
+
s.version = '1.1.1'
|
5
5
|
s.date = '2015-04-14'
|
6
6
|
s.summary = 'A ruby client for the Fakturan.nu - API'
|
7
7
|
s.description = 'A ruby client for the Fakturan.nu - API. Fakturan.nu is a webbapp for billing.'
|
data/test/exceptions_test.rb
CHANGED
@@ -70,6 +70,16 @@ module Fakturan
|
|
70
70
|
assert_equal 400, error.status
|
71
71
|
end
|
72
72
|
|
73
|
+
def test_validation_errors_on_associations_when_created_through_params
|
74
|
+
stub_api_request(:post, '/trees').to_return(body: {errors: {apples: [{"0" => {"apples.colour" => [{error: :blank}]}}], "crown.fluffyness" => [{error: :invalid}]}}.to_json, status: 422)
|
75
|
+
|
76
|
+
a = Fakturan::Tree.new({"apples"=>[{"name"=>"zdsdfsdf", "email"=>"", "password"=>"", "firstname"=>"zdsdfsdf", "lastname"=>"zdsdfsdf", "colour"=>""}], "crown"=>{"fluffyness"=>""}})
|
77
|
+
|
78
|
+
assert_equal false, a.save
|
79
|
+
assert_equal (["Apples is invalid", "Crown fluffyness is invalid"]), a.errors.to_a
|
80
|
+
assert_equal (["Fluffyness is invalid"]), a.crown.errors.to_a
|
81
|
+
end
|
82
|
+
|
73
83
|
def test_validation_errors_on_blank_associated_objects
|
74
84
|
stub_api_request(:post, '/trees').to_return(body: {errors: {apples: [{error: :blank}], crown: [{error: :blank}]}}.to_json, status: 422)
|
75
85
|
a = Fakturan::Tree.new()
|
data/test/fixtures.rb
CHANGED
@@ -5,6 +5,23 @@ module Fakturan
|
|
5
5
|
has_one :crown, uri: nil
|
6
6
|
|
7
7
|
accepts_nested_attributes_for :apples, :crown
|
8
|
+
|
9
|
+
# This allows us to create instances through params without using _attributes
|
10
|
+
def apples=(attrs_or_obj)
|
11
|
+
if attrs_or_obj.respond_to?(:each)
|
12
|
+
send(:apples_attributes=, attrs_or_obj)
|
13
|
+
else
|
14
|
+
super
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def crown=(attrs_or_obj)
|
19
|
+
if attrs_or_obj.respond_to?(:each)
|
20
|
+
send(:crown_attributes=, attrs_or_obj)
|
21
|
+
else
|
22
|
+
super
|
23
|
+
end
|
24
|
+
end
|
8
25
|
end
|
9
26
|
|
10
27
|
class Apple < Base
|