collector 0.0.19 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -30,7 +30,9 @@ module Collector
30
30
 
31
31
  def save_without_updating_timestamps(model)
32
32
  attributes = serialize!(model)
33
- collection.save(attributes)
33
+ id = collection.save(attributes)
34
+ model.instance_variable_set("@id", id)
35
+ model
34
36
  end
35
37
 
36
38
  def delete(model)
@@ -1,3 +1,3 @@
1
1
  module Collector
2
- VERSION = "0.0.19"
2
+ VERSION = "0.1.0"
3
3
  end
@@ -3,6 +3,11 @@ require File.expand_path("../../test_helper.rb", __FILE__)
3
3
  describe Collector::Repository do
4
4
 
5
5
  before do
6
+ Object.send(:remove_const, :TestModel) if Object.const_defined?(:TestModel)
7
+ class TestModel
8
+ include Collector::Model
9
+ end
10
+
6
11
  Object.send(:remove_const, :TestRepository) if Object.const_defined?(:TestRepository)
7
12
  class TestRepository
8
13
  include Collector::Repository
@@ -47,6 +52,18 @@ describe Collector::Repository do
47
52
 
48
53
  TestRepository.save_without_updating_timestamps(model)
49
54
  end
55
+
56
+ it "returns the model with the its id set" do
57
+ model = TestModel.new
58
+ TestRepository.expects(:serialize!).with(model).returns({ foo: "bar" })
59
+
60
+ collection = mock { expects(:save).with({ foo: "bar" }).returns("123abc") }
61
+ TestRepository.stubs(:collection).returns(collection)
62
+
63
+ updated_model = TestRepository.save_without_updating_timestamps(model)
64
+ updated_model.must_equal model
65
+ updated_model.id.must_equal "123abc"
66
+ end
50
67
  end
51
68
 
52
69
  describe "delete" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: collector
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.19
4
+ version: 0.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-12-16 00:00:00.000000000 Z
12
+ date: 2013-01-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport