sk-api 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.
@@ -1,4 +1,4 @@
1
- require 'spec/spec_helper'
1
+ require 'spec_helper'
2
2
 
3
3
  describe SKApi::Resources::Client, "in general" do
4
4
 
@@ -52,28 +52,7 @@ describe SKApi::Resources::Client, "in general" do
52
52
  @client.organisation = ''
53
53
  @client.save.should == false
54
54
  @client.errors.count.should == 1
55
- @client.errors.on_base.should == "Organisation or lastname must be present."
56
- end
57
-
58
- it "should validate raw json object with schema" do
59
- client = SKApi::Resources::Client.find(@client.id)
60
- # convert to json and read raw without activeresource assigning classes
61
- json = client.to_json
62
- obj = ActiveSupport::JSON.decode(json)
63
- # puts obj['client']['organisation']
64
- lambda {
65
- JSON::Schema.validate(obj['client'], SKApi::Resources::Client.schema)
66
- }.should_not raise_error
67
- end
68
-
69
- it "should validate raw json object with to_hash_with_schema" do
70
- client = SKApi::Resources::Client.find(@client.id)
71
- # convert to json and read raw without activeresource assigning classes
72
- hash_obj = SKApi::Resources::Client.to_hash_from_schema(client)
73
- # hash_obj.should == ''
74
- lambda {
75
- JSON::Schema.validate(hash_obj['client'], SKApi::Resources::Client.schema)
76
- }.should_not raise_error
55
+ @client.errors.full_messages.should == ["Organisation or lastname must be present."]
77
56
  end
78
57
 
79
58
  end
@@ -1,4 +1,4 @@
1
- require 'spec/spec_helper'
1
+ require 'spec_helper'
2
2
 
3
3
  describe SKApi::Resources::CreditNote, "in general" do
4
4
 
@@ -30,28 +30,12 @@ describe SKApi::Resources::CreditNote, "in general" do
30
30
  @doc.notes_before.should_not be_empty
31
31
  @doc.new?.should be_false
32
32
  end
33
-
34
- it "should fail create a doc" do
35
- doc = SKApi::Resources::CreditNote.new()
36
- doc.save.should == false
37
- doc.errors.count.should == 1
38
- doc.errors.on(:client_id).should == "can't be blank"
39
- end
40
33
 
41
34
  it "should find a doc" do
42
35
  doc = SKApi::Resources::CreditNote.find(@doc.id)
43
36
  doc.title.should == @doc.title
44
37
  end
45
38
 
46
- it "should validate raw json object with schema" do
47
- doc = SKApi::Resources::CreditNote.find(@doc.id)
48
- # convert to json and read raw without activeresource assigning classes
49
- json = doc.to_json
50
- obj = ActiveSupport::JSON.decode(json)
51
- lambda {
52
- JSON::Schema.validate(obj['credit_note'], SKApi::Resources::CreditNote.schema)
53
- }.should_not raise_error
54
- end
55
39
 
56
40
  it "should edit a doc" do
57
41
  # @doc.lock_version.should == 0 # dont work cause doc is saved twice, for recalc of totals
@@ -59,17 +43,11 @@ describe SKApi::Resources::CreditNote, "in general" do
59
43
  @doc.notes_before = 'You will recieve the amout of:'
60
44
  @doc.notes_before = 'Payment made to you bank Account'
61
45
  @doc.title = 'Changed doc title'
62
-
46
+
63
47
  @doc.save.should be_true
64
48
  @doc.lock_version.should > old_lock_version # because save returns the data
65
49
  end
66
50
 
67
- it "should fail edit a doc" do
68
- @doc.client_id = ''
69
- @doc.save.should == false
70
- @doc.errors.count.should == 1
71
- @doc.errors.on(:client_id).should == "can't be blank"
72
- end
73
51
  end
74
52
 
75
53
  describe SKApi::Resources::CreditNote, "with line items" do
@@ -1,4 +1,4 @@
1
- require 'spec/spec_helper'
1
+ require 'spec_helper'
2
2
 
3
3
  describe SKApi::Resources::Invoice, "in general" do
4
4
 
@@ -55,13 +55,6 @@ describe SKApi::Resources::Invoice, "a new invoice" do
55
55
  doc.destroy
56
56
  end
57
57
 
58
- it "should fail create a doc" do
59
- doc = SKApi::Resources::Invoice.new()
60
- doc.save.should == false
61
- doc.errors.count.should == 1
62
- doc.errors.on(:client_id).should == "can't be blank"
63
- end
64
-
65
58
  end
66
59
 
67
60
  describe SKApi::Resources::Invoice, "Edit an invoice" do
@@ -94,12 +87,6 @@ describe SKApi::Resources::Invoice, "Edit an invoice" do
94
87
  @doc.notes_before.should == 'You will recieve the amout of:'
95
88
  end
96
89
 
97
- it "should fail edit without a client" do
98
- @doc.client_id = ''
99
- @doc.save.should == false
100
- @doc.errors.count.should == 1
101
- @doc.errors.on(:client_id).should == "can't be blank"
102
- end
103
90
  end
104
91
 
105
92
  describe SKApi::Resources::Invoice, "with line items" do
@@ -1,4 +1,4 @@
1
- require 'spec/spec_helper'
1
+ require 'spec_helper'
2
2
 
3
3
  describe SKApi::Resources::Product, "in general" do
4
4
 
@@ -28,11 +28,11 @@ describe SKApi::Resources::Product, "in general" do
28
28
  product.errors.count.should == 1
29
29
  product.errors.full_messages.should == ["Name can't be blank"]
30
30
  end
31
-
32
- it "should fail create a product without price" do
33
- product = SKApi::Resources::Product.new(:name => 'No brain')
34
- product.save.should == false
35
- product.errors.full_messages.should == ["Price can't be blank"]
31
+
32
+ it "should fail create a product with empty price" do
33
+ product = SKApi::Resources::Product.new(:name => 'No brain', :price =>' ')
34
+ product.save.should be_false
35
+ product.errors.full_messages.should == ["Price can't be blank", "Price is not a number"]
36
36
  end
37
37
 
38
38
  it "should find a product by id" do
@@ -51,25 +51,7 @@ describe SKApi::Resources::Product, "in general" do
51
51
  @product.name = ''
52
52
  @product.save.should == false
53
53
  @product.errors.count.should == 1
54
- @product.errors.on(:name).should == "can't be blank"
54
+ @product.errors.full_messages.should == ["Name can't be blank"]
55
55
  end
56
56
 
57
- it "should validate raw json object with schema" do
58
- product = SKApi::Resources::Product.find(@product.id)
59
- # convert to json and read raw without activeresource assigning classes
60
- json = product.to_json
61
- obj = ActiveSupport::JSON.decode(json)
62
- lambda {
63
- JSON::Schema.validate(obj['product'], SKApi::Resources::Product.schema)
64
- }.should_not raise_error
65
- end
66
-
67
- it "should validate raw json object with to_hash_with_schema" do
68
- product = SKApi::Resources::Product.find(@product.id)
69
- # convert to json and read raw without activeresource assigning classes
70
- hash_obj = SKApi::Resources::Product.to_hash_from_schema(product)
71
- lambda {
72
- JSON::Schema.validate(hash_obj['product'], SKApi::Resources::Product.schema)
73
- }.should_not raise_error
74
- end
75
57
  end
@@ -1,7 +1,6 @@
1
1
  require 'rubygems'
2
- require 'spec'
2
+ require 'rspec'
3
3
  require "#{File.dirname(__FILE__)}/../lib/sk_api"
4
- require File.dirname(__FILE__) + '/../vendor/jsonschema-1.0.0/lib/jsonschema'
5
4
 
6
5
  puts "Testing with ActiveResource Version: #{ActiveResource::VERSION::STRING}. Make sure this matches the version in your app. .. Yes this sucks!"
7
6
 
@@ -20,6 +19,9 @@ SKApi::CONNECTION = {
20
19
  :site => "http://demo.salesking.local:3000/api/",
21
20
  :user => "demo@salesking.eu",
22
21
  :password => "demo",
22
+ #:site => "https://demo.dev.salesking.eu/api/",
23
+ #:user => "demo@salesking.eu",
24
+ #:password => "",
23
25
  :format => :json
24
26
  } unless defined?(SKApi::CONNECTION)
25
27
  SKApi::Resources::Base.set_connection(SKApi::CONNECTION)
@@ -1,4 +1,4 @@
1
- require 'spec/spec_helper'
1
+ require 'spec_helper'
2
2
 
3
3
  describe SKApi::Utils::FieldMap do
4
4
 
@@ -8,14 +8,14 @@ describe SKApi::Utils::FieldMap do
8
8
  @map = SKApi::Utils::FieldMap.new(@loc_obj, @rem_obj, map_hash)
9
9
  end
10
10
 
11
- it "should create a mapping" do
11
+ it "should create a mapping" do
12
12
  @map.outdated?.should be_false # both objects are empty
13
13
  end
14
14
 
15
- it "should find outdated fields" do
15
+ it "should find outdated fields" do
16
16
  @loc_obj.firstname = 'theo'
17
17
  @map.outdated?.should be_true
18
- @map.outdated.first[:loc_key].should == :firstname
18
+ @map.outdated.first[:loc_key].should == :firstname
19
19
  end
20
20
 
21
21
  it "should update outdated remote fields" do
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sk-api
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
5
- prerelease: false
4
+ hash: 17
5
+ prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 1
9
- - 0
10
- version: 1.1.0
9
+ - 1
10
+ version: 1.1.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Georg Leciejewski
@@ -15,13 +15,67 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-11-07 00:00:00 +01:00
19
- default_executable:
18
+ date: 2010-11-07 00:00:00 Z
20
19
  dependencies:
21
20
  - !ruby/object:Gem::Dependency
21
+ type: :runtime
22
+ requirement: &id001 !ruby/object:Gem::Requirement
23
+ none: false
24
+ requirements:
25
+ - - <
26
+ - !ruby/object:Gem::Version
27
+ hash: 5
28
+ segments:
29
+ - 3
30
+ version: "3"
31
+ version_requirements: *id001
32
+ prerelease: false
33
+ name: activeresource
34
+ - !ruby/object:Gem::Dependency
35
+ type: :development
36
+ requirement: &id002 !ruby/object:Gem::Requirement
37
+ none: false
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ hash: 3
42
+ segments:
43
+ - 0
44
+ version: "0"
45
+ version_requirements: *id002
46
+ prerelease: false
47
+ name: rdoc
48
+ - !ruby/object:Gem::Dependency
49
+ type: :development
50
+ requirement: &id003 !ruby/object:Gem::Requirement
51
+ none: false
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ hash: 3
56
+ segments:
57
+ - 0
58
+ version: "0"
59
+ version_requirements: *id003
60
+ prerelease: false
22
61
  name: rspec
62
+ - !ruby/object:Gem::Dependency
63
+ type: :development
64
+ requirement: &id004 !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ hash: 3
70
+ segments:
71
+ - 0
72
+ version: "0"
73
+ version_requirements: *id004
23
74
  prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
75
+ name: simplecov
76
+ - !ruby/object:Gem::Dependency
77
+ type: :development
78
+ requirement: &id005 !ruby/object:Gem::Requirement
25
79
  none: false
26
80
  requirements:
27
81
  - - ">="
@@ -30,8 +84,25 @@ dependencies:
30
84
  segments:
31
85
  - 0
32
86
  version: "0"
87
+ version_requirements: *id005
88
+ prerelease: false
89
+ name: xml-simple
90
+ - !ruby/object:Gem::Dependency
33
91
  type: :development
34
- version_requirements: *id001
92
+ requirement: &id006 !ruby/object:Gem::Requirement
93
+ none: false
94
+ requirements:
95
+ - - ">="
96
+ - !ruby/object:Gem::Version
97
+ hash: 63
98
+ segments:
99
+ - 0
100
+ - 9
101
+ - 2
102
+ version: 0.9.2
103
+ version_requirements: *id006
104
+ prerelease: false
105
+ name: rake
35
106
  description: Interact with SalesKing
36
107
  email: gl@salesking.eu
37
108
  executables: []
@@ -42,12 +113,11 @@ extra_rdoc_files:
42
113
  - README.rdoc
43
114
  files:
44
115
  - .gitignore
116
+ - Gemfile
45
117
  - MIT-LICENSE
46
118
  - Manifest
47
119
  - README.rdoc
48
120
  - Rakefile
49
- - VERSION
50
- - init.rb
51
121
  - lib/patches/README
52
122
  - lib/patches/ar2/base.rb
53
123
  - lib/patches/ar2/validations.rb
@@ -63,6 +133,7 @@ files:
63
133
  - lib/sk_api.rb
64
134
  - lib/utils/field_map.rb
65
135
  - lib/utils/serializer.rb
136
+ - lib/version.rb
66
137
  - sk-api.gemspec
67
138
  - spec/resources/client_spec.rb
68
139
  - spec/resources/credit_note_spec.rb
@@ -70,19 +141,12 @@ files:
70
141
  - spec/resources/product_spec.rb
71
142
  - spec/spec_helper.rb
72
143
  - spec/utils/field_map_spec.rb
73
- - tasks/sk_api_tasks.rake
74
- - vendor/jsonschema-1.0.0/README.rdoc
75
- - vendor/jsonschema-1.0.0/Rakefile
76
- - vendor/jsonschema-1.0.0/lib/jsonschema.rb
77
- - vendor/jsonschema-1.0.0/ruby-jsonschema.gemspec
78
- - vendor/jsonschema-1.0.0/test/jsonschema_test.rb
79
- has_rdoc: true
80
144
  homepage: http://github.com/salesking/sk-api
81
145
  licenses: []
82
146
 
83
147
  post_install_message:
84
- rdoc_options:
85
- - --charset=UTF-8
148
+ rdoc_options: []
149
+
86
150
  require_paths:
87
151
  - lib
88
152
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -106,14 +170,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
106
170
  requirements: []
107
171
 
108
172
  rubyforge_project:
109
- rubygems_version: 1.3.7
173
+ rubygems_version: 1.8.24
110
174
  signing_key:
111
175
  specification_version: 3
112
176
  summary: Interact with SalesKing
113
- test_files:
114
- - spec/resources/client_spec.rb
115
- - spec/resources/credit_note_spec.rb
116
- - spec/resources/invoice_spec.rb
117
- - spec/resources/product_spec.rb
118
- - spec/spec_helper.rb
119
- - spec/utils/field_map_spec.rb
177
+ test_files: []
178
+
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 1.1.0
data/init.rb DELETED
@@ -1 +0,0 @@
1
- require "#{File.dirname(__FILE__)}/lib/sk_api"
@@ -1,4 +0,0 @@
1
- # desc "Explaining what the task does"
2
- # task :sk_api_base do
3
- # # Task goes here
4
- # end
@@ -1,94 +0,0 @@
1
- = Ruby/jsonschema
2
-
3
- * http://github.com/Constellation/jsonchema
4
-
5
- == DESCRIPTION:
6
-
7
- json schema library ruby porting
8
- from http://code.google.com/p/jsonschema/
9
-
10
- == SYNOPSIS:
11
- ruby code
12
- require 'jsonschema'
13
- schema = {
14
- "type" => "object",
15
- "properties" => {
16
- "prop01" => {
17
- "type" => "number",
18
- "maximum" => 10
19
- },
20
- "prop02" => {
21
- "type" => "integer",
22
- "maximum" => 20
23
- }
24
- }
25
- }
26
- data = {
27
- "prop01"=> 5,
28
- "prop02"=> 10
29
- }
30
- JSON::Schema.validate(data, schema)
31
-
32
- if you have json library
33
- require 'json'
34
- require 'jsonschema'
35
- schema = File.open("path/to/schema.json", "rb"){|f| JSON.parse(f.read)}
36
- data = File.open("path/to/data.json", "rb"){|f| JSON.parse(f.read)}
37
- JSON::Schema.validate(data, schema)
38
-
39
- == INSTALL:
40
-
41
- gem source -a http://gemcutter.org
42
- sudo gem install jsonschema
43
-
44
- == LICENSE:
45
-
46
- Ruby/jsonschema
47
- (The MIT License)
48
-
49
- Copyright (c) 2009 Constellation
50
-
51
- Permission is hereby granted, free of charge, to any person obtaining
52
- a copy of this software and associated documentation files (the
53
- 'Software'), to deal in the Software without restriction, including
54
- without limitation the rights to use, copy, modify, merge, publish,
55
- distribute, sublicense, and/or sell copies of the Software, and to
56
- permit persons to whom the Software is furnished to do so, subject to
57
- the following conditions:
58
-
59
- The above copyright notice and this permission notice shall be
60
- included in all copies or substantial portions of the Software.
61
-
62
- THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
63
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
64
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
65
- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
66
- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
67
- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
68
- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
69
-
70
-
71
- jsonschema
72
- http://code.google.com/p/jsonschema/
73
- (The MIT License)
74
-
75
- Copyright (c) 2008 Ian Lewis, Yusuke Muraoka
76
-
77
- Permission is hereby granted, free of charge, to any person obtaining a copy of
78
- this software and associated documentation files (the "Software"), to deal in
79
- the Software without restriction, including without limitation the rights to
80
- use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
81
- of the Software, and to permit persons to whom the Software is furnished to do
82
- so, subject to the following conditions:
83
-
84
- The above copyright notice and this permission notice shall be included in all
85
- copies or substantial portions of the Software.
86
-
87
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
88
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
89
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
90
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
91
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
92
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
93
- SOFTWARE.
94
-