collector 0.1.5 → 0.1.6

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: a6e634cfe44d090ae1ade6406c86595bcb09123b
4
- data.tar.gz: 5ffa356d4b6b394c424c837338aa9cfec1fa0378
3
+ metadata.gz: f528e577d42419e81eaf07fc74f5b6883f505a12
4
+ data.tar.gz: f5c1caf252cbf1bac5a82067d71e17f25737d51d
5
5
  SHA512:
6
- metadata.gz: de32f9ebf2e8d54ee2dcc225c4e5e46e82d021569ee6c5764e2885a4ac9d54b2bffc7afa225558efb3088059820b431a6d40b6e65ce92a2b19c00880e04e7273
7
- data.tar.gz: 1120eb5efde0bdd1d8e9deda7a9ec5d1953821e227a8c1fe80680cbf52ff54522496b6e7322024c2cbadae01213f09d22005e6a6b0fc69f72a6d4a120bd3582e
6
+ metadata.gz: f461a77fb15f478eead83a5f82ec1e401ebeb9597d716839314afdd587e024043c1e6cf41e296b85fa5358ecde8c084735284aef511e6146392ed5ce10aa79a2
7
+ data.tar.gz: 6890cd548912d835d085d863a0be8cc82582589ac7344833eabcd407d93c020cdab0e12d7dd62adbef6e2ba1440585be177a10f1893c9724c19af8e1389b2b17
@@ -41,7 +41,7 @@ module Collector
41
41
 
42
42
  def serialize!(model)
43
43
  attributes = serialize(model)
44
- attributes["_id"] = BSON::ObjectId.from_string(attributes.delete("id")) if attributes["id"]
44
+ attributes["_id"] = normalize_id(attributes.delete("id")) if attributes["id"]
45
45
  attributes.reject! { |key, val| val.nil? }
46
46
  attributes
47
47
  end
@@ -1,3 +1,3 @@
1
1
  module Collector
2
- VERSION = "0.1.5"
2
+ VERSION = "0.1.6"
3
3
  end
@@ -78,11 +78,16 @@ describe Collector::Repository do
78
78
  end
79
79
 
80
80
  describe "serialize!" do
81
- it "normalize id to _id and converts to a BSON::ObjectId" do
81
+ it "normalize id to _id and normalize to an ObjectId" do
82
82
  model = mock(attributes: { id: "50c58f4ab392d4381a000001", foo: "bar" })
83
83
  TestModelRepository.serialize!(model).must_equal({ "_id" => BSON::ObjectId("50c58f4ab392d4381a000001"), "foo" => "bar" })
84
84
  end
85
85
 
86
+ it "normalize id to _id and leave it as a string if it is not an ObjectId" do
87
+ model = mock(attributes: { id: "some-string", foo: "bar" })
88
+ TestModelRepository.serialize!(model).must_equal({ "_id" => "some-string", "foo" => "bar" })
89
+ end
90
+
86
91
  it "returns a model's attributes without nil values" do
87
92
  model = mock(attributes: { foo: "bar", nothing: nil })
88
93
  TestModelRepository.serialize!(model).must_equal({ "foo" => "bar" })
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.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brandon Weiss