groupify 0.8.0 → 0.9.0

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: dcc33f0b1cc986893a05a5fdc5e916bd7e3b9837
4
- data.tar.gz: bbe9793b57fe7c7256193694aed87e7d1de7adf7
3
+ metadata.gz: f4862a4c859c23e06244fdbcb6e4136605c2eaba
4
+ data.tar.gz: fe23526681fcf01e8f927174ee4a1aec4eccd4a7
5
5
  SHA512:
6
- metadata.gz: bfa5473767c6bf658020a14ba3f480d0b04ace3997c34377b4dca702dbeab9c4ef3c11354da9264ea453986b20af09472ea513c7ca807e0bc8d3e7f0111935bd
7
- data.tar.gz: e12229d766b2f5abead3b6d7d6848fb6f7c3b40a7889fe03734e589c35a5b4d017efb0628d902755d51f355264b5b049b160ded876a1fbbfbcd3d0b0f168d1c1
6
+ metadata.gz: c4054d1ae7e9772702820d77ff62636a558c09cf2c8b2518df8f8c9748194995ca54e9033918a4e75f726a6785cca31eb2b14d17c041ccc7f866994f8e00e264
7
+ data.tar.gz: c21e26ab9bd68f1cd1b96c02fdfa29f86ae64a553c42f91869c69c85285f4b968855bda0214c804c4d48048040e8e3529ac803c05124f0f4494e35f6e3d508e3
data/.gitignore CHANGED
@@ -18,3 +18,5 @@ tmp
18
18
  /**/*.lock
19
19
  .idea/
20
20
  .ruby-version
21
+ *.sqlite
22
+ *.log
@@ -1,42 +1,39 @@
1
1
  language: ruby
2
2
  services: mongodb
3
+ bundler_args: --without development
4
+ before_script:
5
+ - sh -c "if [ '$DATABASE' = 'postgresql' ]; then psql -c 'create database groupify_test;' -U postgres; fi"
6
+ - sh -c "if [ '$DATABASE' = 'mysql' ]; then mysql -e 'create database groupify_test;'; fi"
7
+ after_success:
8
+ bundle exec codeclimate-test-reporter
3
9
  env:
4
10
  - DATABASE=sqlite3
5
11
  - DATABASE=sqlite3mem
6
12
  - DATABASE=postgresql
7
13
  - DATABASE=mysql
8
14
  rvm:
9
- - 1.9.3
10
- - 2.0.0
11
- - 2.1.9
12
- - 2.2.5
13
- - 2.3.1
14
- - jruby-19mode
15
- - jruby-9.0.5.0
15
+ - 2.2.6
16
+ - 2.3.4
17
+ - 2.4.1
18
+ - jruby-9.1.5.0
16
19
  - rbx-2
17
20
  gemfile:
18
- - gemfiles/rails_3.2.gemfile
19
21
  - gemfiles/rails_4.0.gemfile
20
22
  - gemfiles/rails_4.1.gemfile
21
23
  - gemfiles/rails_4.2.gemfile
22
24
  - gemfiles/rails_5.0.gemfile
25
+ - gemfiles/rails_5.1.gemfile
23
26
  matrix:
24
- exclude:
25
- - rvm: 1.9.3
26
- gemfile: gemfiles/rails_5.0.gemfile
27
- - rvm: jruby-19mode
28
- gemfile: gemfiles/rails_5.0.gemfile
29
- - rvm: 2.0.0
30
- gemfile: gemfiles/rails_5.0.gemfile
31
- - rvm: 2.1.9
32
- gemfile: gemfiles/rails_5.0.gemfile
33
- - rvm: 2.2.5
34
- gemfile: gemfiles/rails_3.2.gemfile
35
- - rvm: 2.3.1
36
- gemfile: gemfiles/rails_3.2.gemfile
37
27
  allow_failures:
28
+ - rvm: 2.4.1
38
29
  - rvm: rbx-2
39
- - rvm: jruby-9.0.5.0
30
+ - rvm: jruby-9.1.5.0
40
31
  gemfile: gemfiles/rails_5.0.gemfile
32
+ - rvm: jruby-9.1.5.0
33
+ gemfile: gemfiles/rails_5.1.gemfile
34
+
41
35
  sudo: false
42
36
  cache: bundler
37
+ addons:
38
+ code_climate:
39
+ repo_token: 9ba385a9a2a4ccd816cf6768fcde3e9cc163a76b67838e3572be70850ffb5dc9
data/Appraisals CHANGED
@@ -1,8 +1,3 @@
1
- appraise "rails-3.2" do
2
- gem 'activerecord', "~> 3.2"
3
- gem "mongoid", ">= 3.0", "< 4"
4
- end
5
-
6
1
  appraise "rails-4.0" do
7
2
  gem 'activerecord', "~> 4.0.0"
8
3
  gem "mongoid", "~> 4.0"
@@ -21,11 +16,11 @@ appraise "rails-4.2" do
21
16
  end
22
17
 
23
18
  appraise "rails-5.0" do
24
- gem 'activerecord', "~> 5.0.0.rc1"
25
- gem 'activesupport', "~> 5.0.0.rc1"
26
- gem 'railties', "~> 5.0.0.rc1"
27
-
28
- gem 'combustion', '0.5.4'
19
+ gem 'activerecord', "~> 5.0.0"
20
+ gem 'mongoid', '~> 6.0.0'
21
+ end
29
22
 
30
- gem 'mongoid', github: 'mongodb/mongoid', ref: '7c2ff52a0c5292b8e6bf3a9a29bbb19abae3dd5f'
23
+ appraise "rails-5.1" do
24
+ gem 'activerecord', "~> 5.1.0"
25
+ gem 'mongoid', '~> 6.1.0'
31
26
  end
@@ -1,6 +1,14 @@
1
1
  # Change Log
2
2
 
3
- ## [v0.8.0](https://github.com/dwbutler/groupify/tree/v0.8.0) (2016-06-10)
3
+ ## [v0.9.0](https://github.com/dwbutler/groupify/tree/v0.9.0) (2017-05-09)
4
+ [Full Changelog](https://github.com/dwbutler/groupify/compare/v0.8.0...v0.9.0)
5
+
6
+ **Merged pull requests:**
7
+
8
+ - Switch .uniq to .distinct while dropping rails 3.2 Support [\#53](https://github.com/dwbutler/groupify/pull/53) ([rposborne](https://github.com/rposborne))
9
+ - Add timestamps to groups table in migration generator template [\#51](https://github.com/dwbutler/groupify/pull/51) ([juhazi](https://github.com/juhazi))
10
+
11
+ ## [v0.8.0](https://github.com/dwbutler/groupify/tree/v0.8.0) (2016-06-11)
4
12
  [Full Changelog](https://github.com/dwbutler/groupify/compare/v0.7.2...v0.8.0)
5
13
 
6
14
  **Fixed bugs:**
data/Gemfile CHANGED
@@ -2,10 +2,17 @@ source 'https://rubygems.org'
2
2
 
3
3
  group :development do
4
4
  gem 'pry'
5
+ gem "github_changelog_generator"
5
6
  end
6
7
 
7
8
  group :test do
9
+ gem "rspec", ">= 3"
10
+
11
+ gem "database_cleaner", "~> 1.5.3"
12
+ gem "combustion", "0.5.5"
13
+ gem "appraisal"
8
14
  gem 'coveralls', require: false
15
+ gem "codeclimate-test-reporter", require: nil
9
16
  end
10
17
 
11
18
  # Specify your gem's dependencies in groupify.gemspec
data/README.md CHANGED
@@ -9,12 +9,12 @@ model? Use named groups instead to add members to named groups such as
9
9
  ## Compatibility
10
10
 
11
11
  The following ORMs are supported:
12
- * ActiveRecord 3.2, 4.1, 4.2, 5.0
13
- * Mongoid 3.1, 4.0+, 5.0+, 6
12
+ * ActiveRecord 4.x, 5.x
13
+ * Mongoid 4.x, 5.x, 6.x
14
14
 
15
15
  The following Rubies are supported:
16
- * MRI Ruby 1.9.3, 2.0, 2.1, 2.2, 2.3
17
- * JRuby 1.7, 9000
16
+ * MRI Ruby 2.2, 2.3, 2.4
17
+ * JRuby 9000
18
18
 
19
19
  The following databases are supported:
20
20
  * MySQL
@@ -154,18 +154,19 @@ user.in_group?(group)
154
154
  group.add(user, widget, task)
155
155
  ```
156
156
 
157
- ### Add to named groups
157
+ ### Remove from groups
158
158
 
159
159
  ```ruby
160
- user.named_groups << :admin
161
- user.in_named_group?(:admin) # => true
160
+ users.groups.destroy(group) # Destroys this user's group membership for this group
161
+ group.users.delete(user) # Deletes this group's group membership for this user
162
162
  ```
163
163
 
164
- ### Remove from groups
164
+ ### Named groups
165
165
 
166
166
  ```ruby
167
- users.groups.destroy(group) # Destroys this user's group membership for this group
168
- group.users.delete(user) # Deletes this group's group membership for this user
167
+ user.named_groups << :admin
168
+ user.in_named_group?(:admin) # => true
169
+ user.named_groups.destroy(:admin)
169
170
  ```
170
171
 
171
172
  ### Check if two members share any of the same groups:
@@ -222,7 +223,7 @@ within a larger group (say, an organization).
222
223
  group.add(user, as: 'manager')
223
224
 
224
225
  # Works with named groups too
225
- user.named_groups.add user, as: 'manager'
226
+ user.named_groups.add 'Company', as: 'manager'
226
227
 
227
228
  # Query for the groups that a user belongs to with a certain role
228
229
  user.groups.as(:manager)
@@ -357,11 +358,20 @@ class PostPolicy < Struct.new(:user, :post)
357
358
  end
358
359
  ```
359
360
 
360
- ## Upgrading
361
+ ## Backwards-Incompatible Releases
362
+
363
+ ### 0.9+ - Dropped support for Rails 3.2 and Ruby 1.9 - 2.1
364
+
365
+ Groupify 0.9 added support for Rails 5.1, and dropped support for EOL'ed versions of Ruby,
366
+ Rails, ActiveRecord, and Mongoid.
367
+
368
+ ActiveRecord 5.1 no longer supports passing arguments to collection
369
+ associations. Because of this, the undocumented syntax `groups.as(:membership_type)`
370
+ is no longer supported.
361
371
 
362
372
  ### 0.8+ - Name Change for `group_memberships` Associations (ActiveRecord only)
363
373
 
364
- Groupify 0.8+ changed the ActiveRecord adapter to support configuring the same
374
+ Groupify 0.8 changed the ActiveRecord adapter to support configuring the same
365
375
  model as both a group and a group member. To accomplish this, the internal `group_memberships`
366
376
  association was renamed to be different for groups and members. If you were
367
377
  using it, please be aware that you will need to change your code. This
@@ -369,6 +379,7 @@ association is considered to be an internal implementation details and not part
369
379
  of the public API, so please don't rely on it if you can avoid it.
370
380
 
371
381
  ### 0.7+ - Polymorphic Groups (ActiveRecord only)
382
+
372
383
  Groupify < 0.7 required a single `Group` model used for all group memberships.
373
384
  Groupify 0.7+ supports using multiple models as groups by implementing polymorphic associations.
374
385
  Upgrading requires adding a new `group_type` column to the `group_memberships` table and
data/Rakefile CHANGED
@@ -9,10 +9,13 @@ RSpec::Core::RakeTask.new do |t|
9
9
  t.verbose = false
10
10
  end
11
11
 
12
- require 'github_changelog_generator/task'
13
- desc "Regenerate changelog"
14
- GitHubChangelogGenerator::RakeTask.new :changelog do |config|
15
- config.future_release = 'v0.8.0'
12
+ begin
13
+ require 'github_changelog_generator/task'
14
+ desc "Regenerate changelog"
15
+ GitHubChangelogGenerator::RakeTask.new :changelog do |config|
16
+ config.future_release = 'v0.9.0'
17
+ end
18
+ rescue LoadError
16
19
  end
17
20
 
18
21
  task :default => :spec
@@ -0,0 +1,7 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+
4
+ Bundler.require :default, :development
5
+
6
+ Combustion.initialize! :all
7
+ run Combustion::Application
@@ -7,10 +7,16 @@ gem "mongoid", "~> 4.0"
7
7
 
8
8
  group :development do
9
9
  gem "pry"
10
+ gem "github_changelog_generator"
10
11
  end
11
12
 
12
13
  group :test do
13
- gem "coveralls", :require => false
14
+ gem "rspec", ">= 3"
15
+ gem "database_cleaner", "~> 1.5.3"
16
+ gem "combustion", "0.5.5"
17
+ gem "appraisal"
18
+ gem "coveralls", require: false
19
+ gem "codeclimate-test-reporter", require: nil
14
20
  end
15
21
 
16
22
  platforms :jruby do
@@ -26,4 +32,4 @@ platforms :ruby do
26
32
  gem "pg"
27
33
  end
28
34
 
29
- gemspec :path => "../"
35
+ gemspec path: "../"
@@ -7,10 +7,16 @@ gem "mongoid", "~> 4.0"
7
7
 
8
8
  group :development do
9
9
  gem "pry"
10
+ gem "github_changelog_generator"
10
11
  end
11
12
 
12
13
  group :test do
13
- gem "coveralls", :require => false
14
+ gem "rspec", ">= 3"
15
+ gem "database_cleaner", "~> 1.5.3"
16
+ gem "combustion", "0.5.5"
17
+ gem "appraisal"
18
+ gem "coveralls", require: false
19
+ gem "codeclimate-test-reporter", require: nil
14
20
  end
15
21
 
16
22
  platforms :jruby do
@@ -26,4 +32,4 @@ platforms :ruby do
26
32
  gem "pg"
27
33
  end
28
34
 
29
- gemspec :path => "../"
35
+ gemspec path: "../"
@@ -7,10 +7,16 @@ gem "mongoid", "~> 4.0"
7
7
 
8
8
  group :development do
9
9
  gem "pry"
10
+ gem "github_changelog_generator"
10
11
  end
11
12
 
12
13
  group :test do
13
- gem "coveralls", :require => false
14
+ gem "rspec", ">= 3"
15
+ gem "database_cleaner", "~> 1.5.3"
16
+ gem "combustion", "0.5.5"
17
+ gem "appraisal"
18
+ gem "coveralls", require: false
19
+ gem "codeclimate-test-reporter", require: nil
14
20
  end
15
21
 
16
22
  platforms :jruby do
@@ -26,4 +32,4 @@ platforms :ruby do
26
32
  gem "pg"
27
33
  end
28
34
 
29
- gemspec :path => "../"
35
+ gemspec path: "../"
@@ -2,18 +2,21 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "activerecord", "~> 5.0.0.rc1"
6
- gem "activesupport", "~> 5.0.0.rc1"
7
- gem "railties", "~> 5.0.0.rc1"
8
- gem "combustion", "0.5.4"
9
- gem "mongoid", :github => "mongodb/mongoid", :ref => "7c2ff52a0c5292b8e6bf3a9a29bbb19abae3dd5f"
5
+ gem "activerecord", "~> 5.0.0"
6
+ gem "mongoid", "~> 6.0.0"
10
7
 
11
8
  group :development do
12
9
  gem "pry"
10
+ gem "github_changelog_generator"
13
11
  end
14
12
 
15
13
  group :test do
16
- gem "coveralls", :require => false
14
+ gem "rspec", ">= 3"
15
+ gem "database_cleaner", "~> 1.5.3"
16
+ gem "combustion", "0.5.5"
17
+ gem "appraisal"
18
+ gem "coveralls", require: false
19
+ gem "codeclimate-test-reporter", require: nil
17
20
  end
18
21
 
19
22
  platforms :jruby do
@@ -29,4 +32,4 @@ platforms :ruby do
29
32
  gem "pg"
30
33
  end
31
34
 
32
- gemspec :path => "../"
35
+ gemspec path: "../"
@@ -2,15 +2,21 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "activerecord", "~> 3.2"
6
- gem "mongoid", ">= 3.0", "< 4"
5
+ gem "activerecord", "~> 5.1.0"
6
+ gem "mongoid", "~> 6.1.0"
7
7
 
8
8
  group :development do
9
9
  gem "pry"
10
+ gem "github_changelog_generator"
10
11
  end
11
12
 
12
13
  group :test do
13
- gem "coveralls", :require => false
14
+ gem "rspec", ">= 3"
15
+ gem "database_cleaner", "~> 1.5.3"
16
+ gem "combustion", "0.5.5"
17
+ gem "appraisal"
18
+ gem "coveralls", require: false
19
+ gem "codeclimate-test-reporter", require: nil
14
20
  end
15
21
 
16
22
  platforms :jruby do
@@ -26,4 +32,4 @@ platforms :ruby do
26
32
  gem "pg"
27
33
  end
28
34
 
29
- gemspec :path => "../"
35
+ gemspec path: "../"
@@ -19,13 +19,5 @@ Gem::Specification.new do |gem|
19
19
  gem.required_ruby_version = ">= 1.9.3"
20
20
 
21
21
  gem.add_development_dependency "mongoid", ">= 3.1"
22
- gem.add_development_dependency "activerecord", ">= 3.2", "< 5.1"
23
-
24
- gem.add_development_dependency "rspec", ">= 3"
25
-
26
- gem.add_development_dependency "database_cleaner", "~> 1.5.3"
27
- gem.add_development_dependency "combustion", ">= 0.5.4"
28
- gem.add_development_dependency "appraisal"
29
-
30
- gem.add_development_dependency "github_changelog_generator"
22
+ gem.add_development_dependency "activerecord", ">= 3.2", "< 5.2"
31
23
  end
@@ -2,6 +2,8 @@ class GroupifyMigration < ActiveRecord::Migration
2
2
  def change
3
3
  create_table :groups do |t|
4
4
  t.string :type
5
+
6
+ t.timestamps
5
7
  end
6
8
 
7
9
  create_table :group_memberships do |t|
@@ -147,31 +147,12 @@ module Groupify
147
147
  association_name ||= member_klass.model_name.plural.to_sym
148
148
  source_type = member_klass.base_class
149
149
 
150
- if ActiveSupport::VERSION::MAJOR > 3
151
- has_many association_name,
152
- ->{ uniq },
153
- through: :group_memberships_as_group,
154
- source: :member,
155
- source_type: source_type,
156
- extend: MemberAssociationExtensions
157
- else
158
- has_many association_name,
159
- uniq: true,
160
- through: :group_memberships_as_group,
161
- source: :member,
162
- source_type: source_type,
163
- extend: MemberAssociationExtensions
164
- end
165
-
166
- define_method(association_name) do |*args|
167
- opts = args.extract_options!
168
- membership_type = opts[:as]
169
- if membership_type.present?
170
- super().as(membership_type)
171
- else
172
- super()
173
- end
174
- end
150
+ has_many association_name,
151
+ ->{ distinct },
152
+ through: :group_memberships_as_group,
153
+ source: :member,
154
+ source_type: source_type.to_s,
155
+ extend: MemberAssociationExtensions
175
156
  end
176
157
  end
177
158
  end
@@ -21,20 +21,11 @@ module Groupify
21
21
  class_name: Groupify.group_membership_class_name
22
22
  end
23
23
 
24
- if ActiveSupport::VERSION::MAJOR > 3
25
- has_many :groups, ->{ uniq },
26
- through: :group_memberships_as_member,
27
- as: :group,
28
- source_type: @group_class_name,
29
- extend: GroupAssociationExtensions
30
- else
31
- has_many :groups,
32
- uniq: true,
33
- through: :group_memberships_as_member,
34
- as: :group,
35
- source_type: @group_class_name,
36
- extend: GroupAssociationExtensions
37
- end
24
+ has_many :groups, ->{ distinct },
25
+ through: :group_memberships_as_member,
26
+ as: :group,
27
+ source_type: @group_class_name,
28
+ extend: GroupAssociationExtensions
38
29
  end
39
30
 
40
31
  module GroupAssociationExtensions
@@ -112,14 +103,14 @@ module Groupify
112
103
  def in_group(group)
113
104
  return none unless group.present?
114
105
 
115
- joins(:group_memberships_as_member).where(group_memberships: { group_id: group.id }).uniq
106
+ joins(:group_memberships_as_member).where(group_memberships: { group_id: group.id }).distinct
116
107
  end
117
108
 
118
109
  def in_any_group(*groups)
119
110
  groups = groups.flatten
120
111
  return none unless groups.present?
121
112
 
122
- joins(:group_memberships_as_member).where(group_memberships: { group_id: groups.map(&:id) }).uniq
113
+ joins(:group_memberships_as_member).where(group_memberships: { group_id: groups.map(&:id) }).distinct
123
114
  end
124
115
 
125
116
  def in_all_groups(*groups)
@@ -130,7 +121,7 @@ module Groupify
130
121
  group("#{quoted_table_name}.#{connection.quote_column_name('id')}").
131
122
  where(group_memberships: {group_id: groups.map(&:id)}).
132
123
  having("COUNT(#{reflect_on_association(:group_memberships_as_member).klass.quoted_table_name}.#{connection.quote_column_name('group_id')}) = ?", groups.count).
133
- uniq
124
+ distinct
134
125
  end
135
126
 
136
127
  def in_only_groups(*groups)
@@ -140,7 +131,7 @@ module Groupify
140
131
  joins(:group_memberships_as_member).
141
132
  group("#{quoted_table_name}.#{connection.quote_column_name('id')}").
142
133
  having("COUNT(DISTINCT #{reflect_on_association(:group_memberships_as_member).klass.quoted_table_name}.#{connection.quote_column_name('group_id')}) = ?", groups.count).
143
- uniq
134
+ distinct
144
135
  end
145
136
 
146
137
  def shares_any_group(other)
@@ -13,8 +13,6 @@ module Groupify
13
13
  extend ActiveSupport::Concern
14
14
 
15
15
  included do
16
- attr_accessible(:member, :group, :group_name, :membership_type, :as) if ActiveSupport::VERSION::MAJOR < 4
17
-
18
16
  belongs_to :member, polymorphic: true
19
17
  belongs_to :group, polymorphic: true
20
18
  end
@@ -69,14 +69,14 @@ module Groupify
69
69
  def in_named_group(named_group)
70
70
  return none unless named_group.present?
71
71
 
72
- joins(:group_memberships_as_member).where(group_memberships: {group_name: named_group}).uniq
72
+ joins(:group_memberships_as_member).where(group_memberships: {group_name: named_group}).distinct
73
73
  end
74
74
 
75
75
  def in_any_named_group(*named_groups)
76
76
  named_groups.flatten!
77
77
  return none unless named_groups.present?
78
78
 
79
- joins(:group_memberships_as_member).where(group_memberships: {group_name: named_groups.flatten}).uniq
79
+ joins(:group_memberships_as_member).where(group_memberships: {group_name: named_groups.flatten}).distinct
80
80
  end
81
81
 
82
82
  def in_all_named_groups(*named_groups)
@@ -87,7 +87,7 @@ module Groupify
87
87
  group("#{quoted_table_name}.#{connection.quote_column_name('id')}").
88
88
  where(:group_memberships => {:group_name => named_groups}).
89
89
  having("COUNT(DISTINCT #{reflect_on_association(:group_memberships_as_member).klass.quoted_table_name}.#{connection.quote_column_name('group_name')}) = ?", named_groups.count).
90
- uniq
90
+ distinct
91
91
  end
92
92
 
93
93
  def in_only_named_groups(*named_groups)
@@ -97,7 +97,7 @@ module Groupify
97
97
  joins(:group_memberships_as_member).
98
98
  group("#{quoted_table_name}.#{connection.quote_column_name('id')}").
99
99
  having("COUNT(DISTINCT #{reflect_on_association(:group_memberships_as_member).klass.quoted_table_name}.#{connection.quote_column_name('group_name')}) = ?", named_groups.count).
100
- uniq
100
+ distinct
101
101
  end
102
102
 
103
103
  def shares_any_named_group(other)
@@ -1,3 +1,3 @@
1
1
  module Groupify
2
- VERSION = "0.8.0"
2
+ VERSION = "0.9.0"
3
3
  end
@@ -1,18 +1,11 @@
1
1
  require 'active_record'
2
+ require 'combustion'
2
3
 
3
- DATABASE = ENV.fetch('DATABASE', 'sqlite3mem')
4
-
5
- puts "ActiveRecord Version: #{ActiveSupport::VERSION::STRING}, Database: #{DATABASE}"
6
-
7
- require 'yaml'
8
- require 'erb'
9
- ActiveRecord::Base.configurations = YAML::load(ERB.new(IO.read("#{File.dirname(__FILE__)}/db/database.yml")).result)
10
- ActiveRecord::Base.establish_connection(DATABASE.to_sym)
11
4
  ActiveRecord::Migration.verbose = false
5
+ ActiveRecord::Base.logger = Logger.new(STDOUT) if DEBUG
12
6
 
13
- require 'combustion/database'
14
- Combustion::Database.create_database(ActiveRecord::Base.configurations[DATABASE])
15
- load(File.join(File.dirname(__FILE__), "db", "schema.rb"))
7
+ Combustion.initialize! :active_record
8
+ puts "ActiveRecord Version: #{ActiveSupport::VERSION::STRING}, Adapter: #{ActiveRecord::Base.connection.adapter_name}"
16
9
 
17
10
  RSpec.configure do |config|
18
11
  config.before(:suite) do
@@ -26,12 +19,6 @@ RSpec.configure do |config|
26
19
  config.after(:each) do
27
20
  DatabaseCleaner[:active_record].clean
28
21
  end
29
-
30
- config.after(:suite) do
31
- unless ENV['DB'] =~ /sqlite/
32
- Combustion::Database.drop_database(ActiveRecord::Base.configurations[DATABASE])
33
- end
34
- end
35
22
  end
36
23
 
37
24
  require 'groupify/adapter/active_record'
@@ -89,10 +76,6 @@ describe User do
89
76
  it { should respond_to :shares_any_group?}
90
77
  end
91
78
 
92
- if DEBUG
93
- ActiveRecord::Base.logger = Logger.new(STDOUT)
94
- end
95
-
96
79
  describe Groupify::ActiveRecord do
97
80
  let(:user) { User.create! }
98
81
  let(:group) { Group.create! }
@@ -383,7 +366,6 @@ describe Groupify::ActiveRecord do
383
366
  expect(group.members).to include(user)
384
367
  expect(group.users).to include(user)
385
368
 
386
- expect(user.groups(:as => :admin)).to include(group)
387
369
  expect(user.groups.as(:admin)).to include(group)
388
370
  expect(group.members).to include(user)
389
371
  expect(group.users).to include(user)
@@ -398,7 +380,6 @@ describe Groupify::ActiveRecord do
398
380
  expect(group.members.as(:manager)).to include(user)
399
381
  expect(group.users).to include(user)
400
382
 
401
- expect(user.groups(:as => :manager)).to include(group)
402
383
  expect(group.members).to include(user)
403
384
  expect(group.users).to include(user)
404
385
  end
@@ -408,7 +389,6 @@ describe Groupify::ActiveRecord do
408
389
  group.add(user, manager, as: :manager)
409
390
 
410
391
  expect(group.users.as(:manager)).to include(user, manager)
411
- expect(group.users(as: :manager)).to include(user, manager)
412
392
  end
413
393
 
414
394
  it "finds members by membership type" do
@@ -423,10 +403,10 @@ describe Groupify::ActiveRecord do
423
403
  end
424
404
 
425
405
  it "finds the group a member belongs to with a membership type" do
426
- group.add user, as: Manager
406
+ group.add user, as: :manager
427
407
  user.groups.create!
428
408
 
429
- expect(Group.with_member(user).as(Manager)).to eq([group])
409
+ expect(Group.with_member(user).as(:manager)).to eq([group])
430
410
  end
431
411
 
432
412
  it "checks if members belong to any groups with a certain membership type" do
@@ -1,10 +1,14 @@
1
- sqlite3:
1
+ test:
2
+ <%
3
+ case ENV.fetch('DATABASE', 'sqlite3mem')
4
+ when 'sqlite3'
5
+ %>
2
6
  adapter: <%= "jdbc" if defined? JRUBY_VERSION %>sqlite3
3
- database: groupify.sqlite3.db
4
- sqlite3mem:
7
+ database: db/combustion_test.sqlite
8
+ <% when 'sqlite3mem' %>
5
9
  adapter: <%= "jdbc" if defined? JRUBY_VERSION %>sqlite3
6
10
  database: ":memory:"
7
- postgresql:
11
+ <% when 'postgresql' %>
8
12
  adapter: postgresql
9
13
  encoding: unicode
10
14
  database: groupify_test
@@ -12,9 +16,10 @@ postgresql:
12
16
  username: postgres
13
17
  password: postgres
14
18
  min_messages: warning
15
- mysql:
19
+ <% when 'mysql' %>
16
20
  adapter: <%= defined?(JRUBY_VERSION) ? "jdbcmysql" : "mysql2" %>
17
21
  host: localhost
18
22
  username: root
19
23
  password:
20
24
  database: groupify_test
25
+ <% end %>
@@ -0,0 +1,3 @@
1
+ Rails.application.routes.draw do
2
+ #
3
+ end
File without changes
File without changes
@@ -29,7 +29,13 @@ if Mongoid::VERSION < "5"
29
29
  Mongoid::Config.sessions = client_configuration
30
30
  Moped.logger = Logger.new(STDOUT) if DEBUG
31
31
  else
32
- Mongoid::Config.log_level = :debug if DEBUG
32
+ if DEBUG
33
+ Mongoid::Config.log_level = :debug
34
+ Mongoid.logger.level = ::Logger::DEBUG
35
+ else
36
+ Mongoid::Config.log_level = :warn
37
+ Mongoid.logger.level = ::Logger::WARN
38
+ end
33
39
  Mongoid::Config.load_configuration(clients: client_configuration)
34
40
  end
35
41
 
@@ -3,10 +3,11 @@ require 'bundler/setup'
3
3
  require 'simplecov'
4
4
  require 'coveralls'
5
5
 
6
- SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
6
+ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new [
7
7
  SimpleCov::Formatter::HTMLFormatter,
8
8
  Coveralls::SimpleCov::Formatter
9
9
  ]
10
+
10
11
  SimpleCov.start
11
12
 
12
13
  require 'active_support'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: groupify
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - dwbutler
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-06-11 00:00:00.000000000 Z
11
+ date: 2017-05-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mongoid
@@ -33,7 +33,7 @@ dependencies:
33
33
  version: '3.2'
34
34
  - - "<"
35
35
  - !ruby/object:Gem::Version
36
- version: '5.1'
36
+ version: '5.2'
37
37
  type: :development
38
38
  prerelease: false
39
39
  version_requirements: !ruby/object:Gem::Requirement
@@ -43,77 +43,7 @@ dependencies:
43
43
  version: '3.2'
44
44
  - - "<"
45
45
  - !ruby/object:Gem::Version
46
- version: '5.1'
47
- - !ruby/object:Gem::Dependency
48
- name: rspec
49
- requirement: !ruby/object:Gem::Requirement
50
- requirements:
51
- - - ">="
52
- - !ruby/object:Gem::Version
53
- version: '3'
54
- type: :development
55
- prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
57
- requirements:
58
- - - ">="
59
- - !ruby/object:Gem::Version
60
- version: '3'
61
- - !ruby/object:Gem::Dependency
62
- name: database_cleaner
63
- requirement: !ruby/object:Gem::Requirement
64
- requirements:
65
- - - "~>"
66
- - !ruby/object:Gem::Version
67
- version: 1.5.3
68
- type: :development
69
- prerelease: false
70
- version_requirements: !ruby/object:Gem::Requirement
71
- requirements:
72
- - - "~>"
73
- - !ruby/object:Gem::Version
74
- version: 1.5.3
75
- - !ruby/object:Gem::Dependency
76
- name: combustion
77
- requirement: !ruby/object:Gem::Requirement
78
- requirements:
79
- - - ">="
80
- - !ruby/object:Gem::Version
81
- version: 0.5.4
82
- type: :development
83
- prerelease: false
84
- version_requirements: !ruby/object:Gem::Requirement
85
- requirements:
86
- - - ">="
87
- - !ruby/object:Gem::Version
88
- version: 0.5.4
89
- - !ruby/object:Gem::Dependency
90
- name: appraisal
91
- requirement: !ruby/object:Gem::Requirement
92
- requirements:
93
- - - ">="
94
- - !ruby/object:Gem::Version
95
- version: '0'
96
- type: :development
97
- prerelease: false
98
- version_requirements: !ruby/object:Gem::Requirement
99
- requirements:
100
- - - ">="
101
- - !ruby/object:Gem::Version
102
- version: '0'
103
- - !ruby/object:Gem::Dependency
104
- name: github_changelog_generator
105
- requirement: !ruby/object:Gem::Requirement
106
- requirements:
107
- - - ">="
108
- - !ruby/object:Gem::Version
109
- version: '0'
110
- type: :development
111
- prerelease: false
112
- version_requirements: !ruby/object:Gem::Requirement
113
- requirements:
114
- - - ">="
115
- - !ruby/object:Gem::Version
116
- version: '0'
46
+ version: '5.2'
117
47
  description: Adds group and membership functionality to Rails models
118
48
  email:
119
49
  - dwbutler@ucla.edu
@@ -132,12 +62,12 @@ files:
132
62
  - LICENSE
133
63
  - README.md
134
64
  - Rakefile
135
- - gemfiles/rails_3.2.gemfile
65
+ - config.ru
136
66
  - gemfiles/rails_4.0.gemfile
137
67
  - gemfiles/rails_4.1.gemfile
138
68
  - gemfiles/rails_4.2.gemfile
139
69
  - gemfiles/rails_5.0.gemfile
140
- - gemfiles/rails_5.0.gemfile.lock
70
+ - gemfiles/rails_5.1.gemfile
141
71
  - groupify.gemspec
142
72
  - lib/generators/groupify/active_record/initializer/initializer_generator.rb
143
73
  - lib/generators/groupify/active_record/initializer/templates/initializer.rb
@@ -173,8 +103,10 @@ files:
173
103
  - lib/groupify/railtie.rb
174
104
  - lib/groupify/version.rb
175
105
  - spec/active_record_spec.rb
176
- - spec/db/database.yml
177
- - spec/db/schema.rb
106
+ - spec/internal/config/database.yml
107
+ - spec/internal/config/routes.rb
108
+ - spec/internal/db/schema.rb
109
+ - spec/internal/public/favicon.ico
178
110
  - spec/mongoid_spec.rb
179
111
  - spec/spec_helper.rb
180
112
  homepage: https://github.com/dwbutler/groupify
@@ -197,13 +129,15 @@ required_rubygems_version: !ruby/object:Gem::Requirement
197
129
  version: '0'
198
130
  requirements: []
199
131
  rubyforge_project:
200
- rubygems_version: 2.5.1
132
+ rubygems_version: 2.6.11
201
133
  signing_key:
202
134
  specification_version: 4
203
135
  summary: Group functionality for Rails
204
136
  test_files:
205
137
  - spec/active_record_spec.rb
206
- - spec/db/database.yml
207
- - spec/db/schema.rb
138
+ - spec/internal/config/database.yml
139
+ - spec/internal/config/routes.rb
140
+ - spec/internal/db/schema.rb
141
+ - spec/internal/public/favicon.ico
208
142
  - spec/mongoid_spec.rb
209
143
  - spec/spec_helper.rb