superdupe 1.0.1 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
data/lib/superdupe/database.rb
CHANGED
@@ -33,9 +33,10 @@ class Dupe
|
|
33
33
|
# pass in a Dupe::Database::Record object, and this method will store the record
|
34
34
|
# in the appropriate table
|
35
35
|
def insert(record)
|
36
|
-
if !record.kind_of?(Dupe::Database::Record) || !record.__model__
|
36
|
+
if !record.kind_of?(Dupe::Database::Record) || !record.__model__
|
37
37
|
raise ArgumentError, "You may only insert well-defined Dupe::Database::Record objects"
|
38
38
|
end
|
39
|
+
record[:id] ||= (@tables[record.__model__.name].blank? ? 1 : @tables[record.__model__.name].map {|r| r.id}.last + 1)
|
39
40
|
@tables[record.__model__.name] ||= []
|
40
41
|
@tables[record.__model__.name] << record
|
41
42
|
record.__model__.run_after_create_callbacks(record)
|
data/lib/superdupe/mock.rb
CHANGED
@@ -77,7 +77,7 @@ class Dupe
|
|
77
77
|
|
78
78
|
when Dupe::Database::Record
|
79
79
|
new_path = "/#{resp.__model__.name.to_s.pluralize}/#{resp.id}.xml"
|
80
|
-
resp = resp.to_xml_safe(:root => resp.
|
80
|
+
resp = resp.to_xml_safe(:root => resp.demodulize)
|
81
81
|
Dupe.network.log.add_request :post, url, resp
|
82
82
|
return resp, new_path
|
83
83
|
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Ns
|
4
|
+
class Ns::Company < ActiveResource::Base
|
5
|
+
self.site = ''
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
describe Ns::Company do
|
10
|
+
|
11
|
+
context "creating and saving a namespaced resource" do
|
12
|
+
it 'should allow to first instantiate and then save a resource' do
|
13
|
+
Dupe.define :"Ns::Company"
|
14
|
+
Ns::Company.find(:all).size.should be(0)
|
15
|
+
new_customer = Ns::Company.new
|
16
|
+
new_customer.save
|
17
|
+
new_customer.id.should_not be_nil
|
18
|
+
Ns::Company.find(:all).size.should be(1)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: superdupe
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 17
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 1.0.
|
9
|
+
- 3
|
10
|
+
version: 1.0.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Marco Ribi
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2010-09-
|
19
|
+
date: 2010-09-15 00:00:00 +02:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
@@ -72,6 +72,7 @@ files:
|
|
72
72
|
- rails_generators/dupe/templates/load_dupe.rb
|
73
73
|
- spec/lib_specs/active_resource_extensions_spec.rb
|
74
74
|
- spec/lib_specs/namespaced_active_resource_extensions_spec.rb
|
75
|
+
- spec/lib_specs/new_and_save_resource_spec.rb
|
75
76
|
- spec/spec_helper.rb
|
76
77
|
has_rdoc: true
|
77
78
|
homepage: http://github.com/screenconcept/superdupe
|
@@ -110,4 +111,5 @@ summary: A tool that helps you mock services while cuking.
|
|
110
111
|
test_files:
|
111
112
|
- spec/lib_specs/active_resource_extensions_spec.rb
|
112
113
|
- spec/lib_specs/namespaced_active_resource_extensions_spec.rb
|
114
|
+
- spec/lib_specs/new_and_save_resource_spec.rb
|
113
115
|
- spec/spec_helper.rb
|