rolify 4.1.1 → 6.0.0

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.
Files changed (55) hide show
  1. checksums.yaml +5 -5
  2. data/.github/workflows/activerecord.yml +27 -0
  3. data/.github/workflows/mongoid.yml +32 -0
  4. data/.hakiri.yml +1 -0
  5. data/Appraisals +42 -0
  6. data/CHANGELOG.rdoc +52 -8
  7. data/CONTRIBUTORS +11 -0
  8. data/Gemfile +6 -14
  9. data/LICENSE +1 -1
  10. data/README.md +72 -26
  11. data/Rakefile +6 -1
  12. data/gemfiles/activerecord_4.gemfile +20 -0
  13. data/gemfiles/activerecord_5.gemfile +22 -0
  14. data/gemfiles/activerecord_6.gemfile +22 -0
  15. data/gemfiles/mongoid_5.gemfile +20 -0
  16. data/gemfiles/mongoid_6.gemfile +19 -0
  17. data/gemfiles/mongoid_7.gemfile +20 -0
  18. data/lib/generators/active_record/rolify_generator.rb +45 -11
  19. data/lib/generators/active_record/templates/migration.rb +2 -3
  20. data/lib/generators/active_record/templates/model.rb +15 -0
  21. data/lib/generators/rolify/templates/initializer.rb +4 -1
  22. data/lib/rolify.rb +3 -4
  23. data/lib/rolify/adapters/active_record/resource_adapter.rb +14 -8
  24. data/lib/rolify/adapters/active_record/role_adapter.rb +40 -17
  25. data/lib/rolify/adapters/mongoid/role_adapter.rb +38 -8
  26. data/lib/rolify/configure.rb +4 -2
  27. data/lib/rolify/dynamic.rb +2 -16
  28. data/lib/rolify/finders.rb +6 -1
  29. data/lib/rolify/matchers.rb +2 -2
  30. data/lib/rolify/resource.rb +1 -1
  31. data/lib/rolify/role.rb +11 -2
  32. data/lib/rolify/version.rb +1 -1
  33. data/rolify.gemspec +15 -7
  34. data/spec/common_helper.rb +16 -0
  35. data/spec/generators/rolify/rolify_activerecord_generator_spec.rb +112 -6
  36. data/spec/generators_helper.rb +9 -2
  37. data/spec/rolify/config_spec.rb +2 -0
  38. data/spec/rolify/custom_spec.rb +1 -1
  39. data/spec/rolify/resource_spec.rb +6 -0
  40. data/spec/rolify/shared_examples/shared_examples_for_finders.rb +50 -32
  41. data/spec/rolify/shared_examples/shared_examples_for_has_role.rb +65 -0
  42. data/spec/rolify/utils_spec.rb +19 -0
  43. data/spec/spec_helper.rb +19 -6
  44. data/spec/support/adapters/active_record.rb +4 -3
  45. data/spec/support/adapters/mongoid.rb +19 -2
  46. data/spec/support/adapters/{mongoid.yml → mongoid_5.yml} +2 -2
  47. data/spec/support/adapters/mongoid_6.yml +6 -0
  48. data/spec/support/adapters/mongoid_7.yml +6 -0
  49. data/spec/support/adapters/utils/active_record.rb +12 -0
  50. data/spec/support/adapters/utils/mongoid.rb +13 -0
  51. metadata +60 -26
  52. data/.travis.yml +0 -25
  53. data/gemfiles/Gemfile.rails-3.2 +0 -27
  54. data/gemfiles/Gemfile.rails-4.0 +0 -33
  55. data/gemfiles/Gemfile.rails-4.1 +0 -37
@@ -4,47 +4,65 @@ shared_examples_for :finders do |param_name, param_method|
4
4
  it { should respond_to(:with_role).with(1).argument }
5
5
  it { should respond_to(:with_role).with(2).arguments }
6
6
 
7
- context "with a global role" do
8
- it { subject.with_role("admin".send(param_method)).should eq([ root ]) }
9
- it { subject.with_role("moderator".send(param_method)).should be_empty }
10
- it { subject.with_role("visitor".send(param_method)).should be_empty }
11
- end
12
-
13
- context "with a class scoped role" do
14
- context "on Forum class" do
15
- it { subject.with_role("admin".send(param_method), Forum).should eq([ root ]) }
16
- it { subject.with_role("moderator".send(param_method), Forum).should eq([ modo ]) }
17
- it { subject.with_role("visitor".send(param_method), Forum).should be_empty }
7
+ context "when resource setting: strict is set to false" do
8
+ context "with a global role" do
9
+ it { subject.with_role("admin".send(param_method)).should eq([ root ]) }
10
+ it { subject.with_role("moderator".send(param_method)).should be_empty }
11
+ it { subject.with_role("visitor".send(param_method)).should be_empty }
18
12
  end
19
13
 
20
- context "on Group class" do
21
- it { subject.with_role("admin".send(param_method), Group).should eq([ root ]) }
22
- it { subject.with_role("moderator".send(param_method), Group).should eq([ root ]) }
23
- it { subject.with_role("visitor".send(param_method), Group).should be_empty }
14
+ context "with a class scoped role" do
15
+ context "on Forum class" do
16
+ it { subject.with_role("admin".send(param_method), Forum).should eq([ root ]) }
17
+ it { subject.with_role("moderator".send(param_method), Forum).should eq([ modo ]) }
18
+ it { subject.with_role("visitor".send(param_method), Forum).should be_empty }
19
+ end
20
+
21
+ context "on Group class" do
22
+ it { subject.with_role("admin".send(param_method), Group).should eq([ root ]) }
23
+ it { subject.with_role("moderator".send(param_method), Group).should eq([ root ]) }
24
+ it { subject.with_role("visitor".send(param_method), Group).should be_empty }
25
+ end
24
26
  end
25
- end
26
27
 
27
- context "with an instance scoped role" do
28
- context "on Forum.first instance" do
29
- it { subject.with_role("admin".send(param_method), Forum.first).should eq([ root ]) }
30
- it { subject.with_role("moderator".send(param_method), Forum.first).should eq([ modo ]) }
31
- it { subject.with_role("visitor".send(param_method), Forum.first).should be_empty }
28
+ context "with an instance scoped role" do
29
+ context "on Forum.first instance" do
30
+ it { subject.with_role("admin".send(param_method), Forum.first).should eq([ root ]) }
31
+ it { subject.with_role("moderator".send(param_method), Forum.first).should eq([ modo ]) }
32
+ it { subject.with_role("visitor".send(param_method), Forum.first).should be_empty }
33
+ end
34
+
35
+ context "on Forum.last instance" do
36
+ it { subject.with_role("admin".send(param_method), Forum.last).should eq([ root ]) }
37
+ it { subject.with_role("moderator".send(param_method), Forum.last).should eq([ modo ]) }
38
+ it { subject.with_role("visitor".send(param_method), Forum.last).should include(root, visitor) } # =~ doesn't pass using mongoid, don't know why...
39
+ end
40
+
41
+ context "on Group.first instance" do
42
+ it { subject.with_role("admin".send(param_method), Group.first).should eq([ root ]) }
43
+ it { subject.with_role("moderator".send(param_method), Group.first).should eq([ root ]) }
44
+ it { subject.with_role("visitor".send(param_method), Group.first).should eq([ modo ]) }
45
+ end
46
+
47
+ context "on Company.first_instance" do
48
+ it { subject.with_role("owner".send(param_method), Company.first).should eq([ owner ]) }
49
+ end
32
50
  end
51
+ end
33
52
 
34
- context "on Forum.last instance" do
35
- it { subject.with_role("admin".send(param_method), Forum.last).should eq([ root ]) }
36
- it { subject.with_role("moderator".send(param_method), Forum.last).should eq([ modo ]) }
37
- it { subject.with_role("visitor".send(param_method), Forum.last).should include(root, visitor) } # =~ doesn't pass using mongoid, don't know why...
53
+ context "when resource setting: strict is set to true" do
54
+ before(:context) do
55
+ user_class.strict_rolify = true
38
56
  end
39
-
40
- context "on Group.first instance" do
41
- it { subject.with_role("admin".send(param_method), Group.first).should eq([ root ]) }
42
- it { subject.with_role("moderator".send(param_method), Group.first).should eq([ root ]) }
43
- it { subject.with_role("visitor".send(param_method), Group.first).should eq([ modo ]) }
57
+ after(:context) do
58
+ user_class.strict_rolify = false
44
59
  end
45
60
 
46
- context "on Company.first_instance" do
47
- it { subject.with_role("owner".send(param_method), Company.first).should eq([ owner ]) }
61
+ context "with an instance scoped role" do
62
+ context "on Forum.first instance" do
63
+ it { subject.with_role("admin".send(param_method), Forum.first).should be_empty }
64
+ it { subject.with_role("moderator".send(param_method), Forum.first).should be_empty }
65
+ end
48
66
  end
49
67
  end
50
68
  end
@@ -3,10 +3,16 @@ shared_examples_for "#has_role?_examples" do |param_name, param_method|
3
3
  context "with a global role", :scope => :global do
4
4
  it { subject.has_role?("admin".send(param_method)).should be_truthy }
5
5
 
6
+ it { subject.has_cached_role?("admin".send(param_method)).should be_truthy }
7
+
6
8
  context "on resource request" do
7
9
  it { subject.has_role?("admin".send(param_method), Forum.first).should be_truthy }
8
10
  it { subject.has_role?("admin".send(param_method), Forum).should be_truthy }
9
11
  it { subject.has_role?("admin".send(param_method), :any).should be_truthy }
12
+
13
+ it { subject.has_cached_role?("admin".send(param_method), Forum.first).should be_truthy }
14
+ it { subject.has_cached_role?("admin".send(param_method), Forum).should be_truthy }
15
+ it { subject.has_cached_role?("admin".send(param_method), :any).should be_truthy }
10
16
  end
11
17
 
12
18
  context "with another global role" do
@@ -14,19 +20,29 @@ shared_examples_for "#has_role?_examples" do |param_name, param_method|
14
20
 
15
21
  it { subject.has_role?("global".send(param_method)).should be_falsey }
16
22
  it { subject.has_role?("global".send(param_method), :any).should be_falsey }
23
+
24
+ it { subject.has_cached_role?("global".send(param_method)).should be_falsey }
25
+ it { subject.has_cached_role?("global".send(param_method), :any).should be_falsey }
17
26
  end
18
27
 
19
28
  it "should not get an instance scoped role" do
20
29
  subject.has_role?("moderator".send(param_method), Group.first).should be_falsey
30
+
31
+ subject.has_cached_role?("moderator".send(param_method), Group.first).should be_falsey
21
32
  end
22
33
 
23
34
  it "should not get a class scoped role" do
24
35
  subject.has_role?("manager".send(param_method), Forum).should be_falsey
36
+
37
+ subject.has_cached_role?("manager".send(param_method), Forum).should be_falsey
25
38
  end
26
39
 
27
40
  context "using inexisting role" do
28
41
  it { subject.has_role?("dummy".send(param_method)).should be_falsey }
29
42
  it { subject.has_role?("dumber".send(param_method), Forum.first).should be_falsey }
43
+
44
+ it { subject.has_cached_role?("dummy".send(param_method)).should be_falsey }
45
+ it { subject.has_cached_role?("dumber".send(param_method), Forum.first).should be_falsey }
30
46
  end
31
47
  end
32
48
 
@@ -35,15 +51,23 @@ shared_examples_for "#has_role?_examples" do |param_name, param_method|
35
51
  it { subject.has_role?("manager".send(param_method), Forum).should be_truthy }
36
52
  it { subject.has_role?("manager".send(param_method), Forum.first).should be_truthy }
37
53
  it { subject.has_role?("manager".send(param_method), :any).should be_truthy }
54
+
55
+ it { subject.has_cached_role?("manager".send(param_method), Forum).should be_truthy }
56
+ it { subject.has_cached_role?("manager".send(param_method), Forum.first).should be_truthy }
57
+ it { subject.has_cached_role?("manager".send(param_method), :any).should be_truthy }
38
58
  end
39
59
 
40
60
  it "should not get a scoped role when asking for a global" do
41
61
  subject.has_role?("manager".send(param_method)).should be_falsey
62
+
63
+ subject.has_cached_role?("manager".send(param_method)).should be_falsey
42
64
  end
43
65
 
44
66
  it "should not get a global role" do
45
67
  role_class.create(:name => "admin")
46
68
  subject.has_role?("admin".send(param_method)).should be_falsey
69
+
70
+ subject.has_cached_role?("admin".send(param_method)).should be_falsey
47
71
  end
48
72
 
49
73
  context "with another class scoped role" do
@@ -52,6 +76,9 @@ shared_examples_for "#has_role?_examples" do |param_name, param_method|
52
76
 
53
77
  it { subject.has_role?("member".send(param_method), Forum).should be_falsey }
54
78
  it { subject.has_role?("member".send(param_method), :any).should be_falsey }
79
+
80
+ it { subject.has_cached_role?("member".send(param_method), Forum).should be_falsey }
81
+ it { subject.has_cached_role?("member".send(param_method), :any).should be_falsey }
55
82
  end
56
83
 
57
84
  context "on another resource with the same name" do
@@ -59,6 +86,9 @@ shared_examples_for "#has_role?_examples" do |param_name, param_method|
59
86
 
60
87
  it { subject.has_role?("manager".send(param_method), Group).should be_falsey }
61
88
  it { subject.has_role?("manager".send(param_method), :any).should be_truthy }
89
+
90
+ it { subject.has_cached_role?("manager".send(param_method), Group).should be_falsey }
91
+ it { subject.has_cached_role?("manager".send(param_method), :any).should be_truthy }
62
92
  end
63
93
 
64
94
  context "on another resource with another name" do
@@ -66,12 +96,18 @@ shared_examples_for "#has_role?_examples" do |param_name, param_method|
66
96
 
67
97
  it { subject.has_role?("defenders".send(param_method), Group).should be_falsey }
68
98
  it { subject.has_role?("defenders".send(param_method), :any).should be_falsey }
99
+
100
+ it { subject.has_cached_role?("defenders".send(param_method), Group).should be_falsey }
101
+ it { subject.has_cached_role?("defenders".send(param_method), :any).should be_falsey }
69
102
  end
70
103
  end
71
104
 
72
105
  context "using inexisting role" do
73
106
  it { subject.has_role?("dummy".send(param_method), Forum).should be_falsey }
74
107
  it { subject.has_role?("dumber".send(param_method)).should be_falsey }
108
+
109
+ it { subject.has_cached_role?("dummy".send(param_method), Forum).should be_falsey }
110
+ it { subject.has_cached_role?("dumber".send(param_method)).should be_falsey }
75
111
  end
76
112
  end
77
113
 
@@ -84,19 +120,33 @@ shared_examples_for "#has_role?_examples" do |param_name, param_method|
84
120
  m.add_role("moderator", Forum.first)
85
121
  m.has_role?("moderator".send(param_method), :any).should be_truthy
86
122
  }
123
+
124
+ it { subject.has_cached_role?("moderator".send(param_method), Forum.first).should be_truthy }
125
+ it { subject.has_cached_role?("moderator".send(param_method), :any).should be_truthy }
126
+ it {
127
+ m = subject.class.new
128
+ m.add_role("moderator", Forum.first)
129
+ m.has_cached_role?("moderator".send(param_method), :any).should be_truthy
130
+ }
87
131
  end
88
132
 
89
133
  it "should not get an instance scoped role when asking for a global" do
90
134
  subject.has_role?("moderator".send(param_method)).should be_falsey
135
+
136
+ subject.has_cached_role?("moderator".send(param_method)).should be_falsey
91
137
  end
92
138
 
93
139
  it "should not get an instance scoped role when asking for a class scoped" do
94
140
  subject.has_role?("moderator".send(param_method), Forum).should be_falsey
141
+
142
+ subject.has_cached_role?("moderator".send(param_method), Forum).should be_falsey
95
143
  end
96
144
 
97
145
  it "should not get a global role" do
98
146
  role_class.create(:name => "admin")
99
147
  subject.has_role?("admin".send(param_method)).should be_falsey
148
+
149
+ subject.has_cached_role?("admin".send(param_method)).should be_falsey
100
150
  end
101
151
 
102
152
  context "with another instance scoped role" do
@@ -105,6 +155,9 @@ shared_examples_for "#has_role?_examples" do |param_name, param_method|
105
155
 
106
156
  it { subject.has_role?("member".send(param_method), Forum.first).should be_falsey }
107
157
  it { subject.has_role?("member".send(param_method), :any).should be_falsey }
158
+
159
+ it { subject.has_cached_role?("member".send(param_method), Forum.first).should be_falsey }
160
+ it { subject.has_cached_role?("member".send(param_method), :any).should be_falsey }
108
161
  end
109
162
 
110
163
  context "on another resource of the same type but with the same role name" do
@@ -112,6 +165,9 @@ shared_examples_for "#has_role?_examples" do |param_name, param_method|
112
165
 
113
166
  it { subject.has_role?("moderator".send(param_method), Forum.last).should be_falsey }
114
167
  it { subject.has_role?("moderator".send(param_method), :any).should be_truthy }
168
+
169
+ it { subject.has_cached_role?("moderator".send(param_method), Forum.last).should be_falsey }
170
+ it { subject.has_cached_role?("moderator".send(param_method), :any).should be_truthy }
115
171
  end
116
172
 
117
173
  context "on another resource of different type but with the same role name" do
@@ -119,6 +175,9 @@ shared_examples_for "#has_role?_examples" do |param_name, param_method|
119
175
 
120
176
  it { subject.has_role?("moderator".send(param_method), Group.last).should be_falsey }
121
177
  it { subject.has_role?("moderator".send(param_method), :any).should be_truthy }
178
+
179
+ it { subject.has_cached_role?("moderator".send(param_method), Group.last).should be_falsey }
180
+ it { subject.has_cached_role?("moderator".send(param_method), :any).should be_truthy }
122
181
  end
123
182
 
124
183
  context "on another resource of the same type and with another role name" do
@@ -126,6 +185,9 @@ shared_examples_for "#has_role?_examples" do |param_name, param_method|
126
185
 
127
186
  it { subject.has_role?("member".send(param_method), Forum.last).should be_falsey }
128
187
  it { subject.has_role?("member".send(param_method), :any).should be_falsey }
188
+
189
+ it { subject.has_cached_role?("member".send(param_method), Forum.last).should be_falsey }
190
+ it { subject.has_cached_role?("member".send(param_method), :any).should be_falsey }
129
191
  end
130
192
 
131
193
  context "on another resource of different type and with another role name" do
@@ -133,6 +195,9 @@ shared_examples_for "#has_role?_examples" do |param_name, param_method|
133
195
 
134
196
  it { subject.has_role?("member".send(param_method), Group.first).should be_falsey }
135
197
  it { subject.has_role?("member".send(param_method), :any).should be_falsey }
198
+
199
+ it { subject.has_cached_role?("member".send(param_method), Group.first).should be_falsey }
200
+ it { subject.has_cached_role?("member".send(param_method), :any).should be_falsey }
136
201
  end
137
202
  end
138
203
  end
@@ -0,0 +1,19 @@
1
+ require "spec_helper"
2
+
3
+ describe Rolify::Utils do
4
+ class Harness
5
+ extend Rolify::Utils
6
+ define_method(:new_method) { |*_args| true }
7
+ deprecate :old_method, :new_method
8
+ end
9
+
10
+ let(:harness) { Harness.new }
11
+
12
+ context '#deprecate' do
13
+ it 'calls new method with same arguments' do
14
+ expect(harness).to receive(:warn).once
15
+ expect(harness).to receive(:new_method).once.with(1, 2, 3)
16
+ harness.old_method(1, 2, 3)
17
+ end
18
+ end
19
+ end
data/spec/spec_helper.rb CHANGED
@@ -1,5 +1,5 @@
1
- require "codeclimate-test-reporter"
2
- CodeClimate::TestReporter.start
1
+ require "simplecov"
2
+ SimpleCov.start
3
3
 
4
4
  require 'rubygems'
5
5
  require "bundler/setup"
@@ -11,6 +11,8 @@ begin
11
11
  require 'its'
12
12
  rescue LoadError
13
13
  end
14
+ require 'database_cleaner'
15
+
14
16
  require 'coveralls'
15
17
  Coveralls.wear_merged!
16
18
 
@@ -19,10 +21,7 @@ ENV['ADAPTER'] ||= 'active_record'
19
21
  load File.dirname(__FILE__) + "/support/adapters/#{ENV['ADAPTER']}.rb"
20
22
  load File.dirname(__FILE__) + '/support/data.rb'
21
23
 
22
- begin
23
- require 'pry'
24
- rescue LoadError
25
- end
24
+
26
25
 
27
26
  def reset_defaults
28
27
  Rolify.use_defaults
@@ -47,3 +46,17 @@ def silence_warnings(&block)
47
46
  $VERBOSE = warn_level
48
47
  result
49
48
  end
49
+
50
+ RSpec.configure do |config|
51
+ config.expect_with(:rspec) { |c| c.syntax = [:should, :expect] }
52
+
53
+ config.before(:suite) do
54
+ DatabaseCleaner.strategy = :truncation
55
+ DatabaseCleaner.start
56
+ end
57
+
58
+ config.after(:suite) do |example|
59
+ DatabaseCleaner.clean
60
+ end
61
+
62
+ end
@@ -1,7 +1,8 @@
1
- require 'active_record'
1
+ load File.dirname(__FILE__) + '/utils/active_record.rb'
2
+
3
+ extend_rspec_with_activerecord_specific_matchers
4
+ establish_connection
2
5
 
3
- RSpec::Matchers::BuiltIn::OperatorMatcher.register(ActiveRecord::Relation, '=~', RSpec::Matchers::BuiltIn::MatchArray)
4
- ActiveRecord::Base.establish_connection(:adapter => "sqlite3", :database => ":memory:")
5
6
  ActiveRecord::Base.extend Rolify
6
7
 
7
8
  load File.dirname(__FILE__) + '/../schema.rb'
@@ -1,6 +1,11 @@
1
- require 'mongoid'
1
+ load File.dirname(__FILE__) + '/utils/mongoid.rb'
2
2
 
3
- Mongoid.load!("spec/support/adapters/mongoid.yml", :test)
3
+ load_mongoid_config
4
+
5
+ begin
6
+ Mongo::Logger.logger.level = ::Logger::FATAL
7
+ rescue NameError
8
+ end
4
9
 
5
10
  ::Mongoid::Document.module_eval do
6
11
  def self.included(base)
@@ -13,6 +18,8 @@ Rolify.use_mongoid
13
18
  # Standard user and role classes
14
19
  class User
15
20
  include Mongoid::Document
21
+ default_scope -> { order_by id: 'asc' }
22
+
16
23
  rolify
17
24
 
18
25
  field :login, :type => String
@@ -21,6 +28,7 @@ end
21
28
  # Standard user and role classes
22
29
  class StrictUser
23
30
  include Mongoid::Document
31
+ default_scope -> { order_by id: 'asc' }
24
32
  rolify strict: true
25
33
 
26
34
  field :login, :type => String
@@ -48,6 +56,7 @@ end
48
56
  # Resourcifed and rolifed at the same time
49
57
  class HumanResource
50
58
  include Mongoid::Document
59
+ default_scope -> { order_by id: 'asc' }
51
60
  resourcify :resources
52
61
  rolify
53
62
 
@@ -74,6 +83,7 @@ end
74
83
  # Custom role and class names
75
84
  class Customer
76
85
  include Mongoid::Document
86
+ default_scope -> { order_by id: 'asc' }
77
87
  rolify :role_cname => "Privilege"
78
88
 
79
89
  field :login, :type => String
@@ -81,6 +91,7 @@ end
81
91
 
82
92
  class Privilege
83
93
  include Mongoid::Document
94
+ default_scope -> { order_by id: 'asc' }
84
95
  has_and_belongs_to_many :customers
85
96
  belongs_to :resource, :polymorphic => true
86
97
  scopify
@@ -100,6 +111,7 @@ end
100
111
  module Admin
101
112
  class Moderator
102
113
  include Mongoid::Document
114
+ default_scope -> { order_by id: 'asc' }
103
115
  rolify :role_cname => "Admin::Right"
104
116
 
105
117
  field :login, :type => String
@@ -107,6 +119,7 @@ module Admin
107
119
 
108
120
  class Right
109
121
  include Mongoid::Document
122
+ default_scope -> { order_by id: 'asc' }
110
123
  has_and_belongs_to_many :moderators, :class_name => 'Admin::Moderator'
111
124
  belongs_to :resource, :polymorphic => true
112
125
  scopify
@@ -126,6 +139,7 @@ end
126
139
  # Resources classes
127
140
  class Forum
128
141
  include Mongoid::Document
142
+ default_scope -> { order_by id: 'asc' }
129
143
  #resourcify done during specs setup to be able to use custom user classes
130
144
 
131
145
  field :name, :type => String
@@ -133,6 +147,7 @@ end
133
147
 
134
148
  class Group
135
149
  include Mongoid::Document
150
+ default_scope -> { order_by id: 'asc' }
136
151
  #resourcify done during specs setup to be able to use custom user classes
137
152
 
138
153
  field :name, :type => String
@@ -145,6 +160,7 @@ end
145
160
 
146
161
  class Team
147
162
  include Mongoid::Document
163
+ default_scope -> { order_by id: 'asc' }
148
164
  #resourcify done during specs setup to be able to use custom user classes
149
165
 
150
166
  field :team_code, :type => Integer
@@ -153,6 +169,7 @@ end
153
169
 
154
170
  class Organization
155
171
  include Mongoid::Document
172
+ default_scope -> { order_by id: 'asc' }
156
173
  end
157
174
 
158
175
  class Company < Organization