groupdate 2.2.0 → 2.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cc3e5e97ecbb9ce920165a63a9cba725b6f4c0d5
4
- data.tar.gz: 366b811759baa6dfc4918a91428f36a1f503e35e
3
+ metadata.gz: 61482d521349112fbb247de01da256b7d2559574
4
+ data.tar.gz: ef39227bacbce05f6d382f4e7e70c8f3a69eea3d
5
5
  SHA512:
6
- metadata.gz: 0245a5804aca2739f67d6b53552ba584533d237ed14ed47112a8a2995ddc3fa4e3808cc8bb304c58697886fd5a9431870f6f3a1c99e4cdfc57bf815a8b973e6b
7
- data.tar.gz: e2c50ef5c06f46a7a311828a835b271ababe0e6589a6d1374097fa7830ab0416c875a5b49c8f539799d3e73181b6fe42e5a0a58556a14a666736abd953788db3
6
+ metadata.gz: 4b054169e094d93790241c3757e3f6171058e2379655394c8060db79417fb6bcafa39f7612f4462fc3ea2d6befd11dcfa700a1bde9073ab37037d2714db1ca8d
7
+ data.tar.gz: 478d53080c29fd79b2965c7804a76a16451f239151bb839aa26040d874d05f1c0bf83ba730b3f23ba670c6d8ffb35028e69d9f147328c735efca669422ead0f9
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 2.2.1
2
+
3
+ - Fixed ActiveRecord 3 associations
4
+
1
5
  ## 2.2.0
2
6
 
3
7
  - Added support for Arrays and Hashes
data/README.md CHANGED
@@ -149,6 +149,12 @@ Supports the same options as above
149
149
  users.group_by_day(time_zone: time_zone){|u| u.created_at }
150
150
  ```
151
151
 
152
+ Count
153
+
154
+ ```ruby
155
+ Hash[ users.group_by_day{|u| u.created_at }.map{|k, v| [k, v.size] } ]
156
+ ```
157
+
152
158
  ## Installation
153
159
 
154
160
  Add this line to your application’s Gemfile:
@@ -24,6 +24,16 @@ module ActiveRecord
24
24
  end
25
25
  end
26
26
 
27
+ module ActiveRecord
28
+ module Associations
29
+ class CollectionProxy
30
+ if ActiveRecord::VERSION::MAJOR == 3
31
+ delegate *Groupdate::METHODS, :to => :scoped
32
+ end
33
+ end
34
+ end
35
+ end
36
+
27
37
  # hack for **unfixed** rails issue
28
38
  # https://github.com/rails/rails/issues/7121
29
39
  module ActiveRecord
@@ -1,3 +1,3 @@
1
1
  module Groupdate
2
- VERSION = "2.2.0"
2
+ VERSION = "2.2.1"
3
3
  end
data/test/test_helper.rb CHANGED
@@ -18,6 +18,10 @@ ActiveRecord::Base.default_timezone = :utc
18
18
  ActiveRecord::Base.time_zone_aware_attributes = true
19
19
 
20
20
  class User < ActiveRecord::Base
21
+ has_many :posts
22
+ end
23
+
24
+ class Post < ActiveRecord::Base
21
25
  end
22
26
 
23
27
  # migrations
@@ -29,6 +33,11 @@ end
29
33
  t.integer :score
30
34
  t.timestamp :created_at
31
35
  end
36
+
37
+ ActiveRecord::Migration.create_table :posts, :force => true do |t|
38
+ t.references :user
39
+ t.timestamp :created_at
40
+ end
32
41
  end
33
42
 
34
43
  module TestGroupdate
@@ -606,6 +615,13 @@ module TestGroupdate
606
615
  assert_equal ({[1, "Sun"] => 1}), User.group(:score).group_by_week(:created_at, format: "%a").count
607
616
  end
608
617
 
618
+ # associations
619
+
620
+ def test_associations
621
+ user = create_user("2014-03-01 00:00:00 UTC")
622
+ assert_empty user.posts.group_by_day(:created_at).count
623
+ end
624
+
609
625
  # helpers
610
626
 
611
627
  def assert_format(method, expected, format, options = {})
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: groupdate
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.0
4
+ version: 2.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kane
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-22 00:00:00.000000000 Z
11
+ date: 2014-06-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport