fakturan_nu 1.1.0 → 1.1.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bb8aaece005780b6c5dcb3c76e27099268892c1e
4
- data.tar.gz: 2991573e89a82de2fb2d211aff1a2e9693ebdf1c
3
+ metadata.gz: b13585e5fc6be9909753083863eda66758b826d7
4
+ data.tar.gz: 9b8a8ce02f6e623bd01f3f7f1ca0bc4b5105d6be
5
5
  SHA512:
6
- metadata.gz: eff15b4eb0b0c6644ddb5027530b6e2cc3c34282e45a5d6a1d639ba44fecd2a3fe52c4c8b9beeada2f5f9893033f30d32913dab4bc3fdd96ff822c5da124ee4f
7
- data.tar.gz: f574a12863ac0225d212d4efef0b98678d7d0fb591ce988aba66e6f8bdd3a3725574512437b0217d2e01fb100d6f839c8f1398430f5d75041f515346e6287b35
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.0'
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.'
@@ -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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fakturan_nu
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan Bourque Olivegren