Skip to content

Commit b362c22

Browse files
committed
chore: add ApplicationRecord for test
1 parent 194de58 commit b362c22

File tree

1 file changed

+43
-36
lines changed

1 file changed

+43
-36
lines changed

spec/support/models.rb

Lines changed: 43 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
1-
class Tag < ActiveRecord::Base
2-
has_closure_tree :dependent => :destroy, :order => :name
1+
# frozen_string_literal: true
2+
3+
class ApplicationRecord < ActiveRecord::Base
4+
self.abstract_class = true
5+
end
6+
7+
class Tag < ApplicationRecord
8+
has_closure_tree dependent: :destroy, order: :name
39
before_destroy :add_destroyed_tag
410

511
def to_s
@@ -8,11 +14,11 @@ def to_s
814

915
def add_destroyed_tag
1016
# Proof for the tests that the destroy rather than the delete method was called:
11-
DestroyedTag.create(:name => name)
17+
DestroyedTag.create(name:)
1218
end
1319
end
1420

15-
class UUIDTag < ActiveRecord::Base
21+
class UUIDTag < ApplicationRecord
1622
self.primary_key = :uuid
1723
before_create :set_uuid
1824
has_closure_tree dependent: :destroy, order: 'name', parent_column_name: 'parent_uuid'
@@ -28,62 +34,62 @@ def to_s
2834

2935
def add_destroyed_tag
3036
# Proof for the tests that the destroy rather than the delete method was called:
31-
DestroyedTag.create(:name => name)
37+
DestroyedTag.create(name:)
3238
end
3339
end
3440

35-
class DestroyedTag < ActiveRecord::Base
41+
class DestroyedTag < ApplicationRecord
3642
end
3743

38-
class Group < ActiveRecord::Base
44+
class Group < ApplicationRecord
3945
has_closure_tree_root :root_user
4046
end
4147

42-
class Grouping < ActiveRecord::Base
43-
has_closure_tree_root :root_person, class_name: "User", foreign_key: :group_id
48+
class Grouping < ApplicationRecord
49+
has_closure_tree_root :root_person, class_name: 'User', foreign_key: :group_id
4450
end
4551

46-
class UserSet < ActiveRecord::Base
47-
has_closure_tree_root :root_user, class_name: "Useur"
52+
class UserSet < ApplicationRecord
53+
has_closure_tree_root :root_user, class_name: 'Useur'
4854
end
4955

50-
class Team < ActiveRecord::Base
51-
has_closure_tree_root :root_user, class_name: "User", foreign_key: :grp_id
56+
class Team < ApplicationRecord
57+
has_closure_tree_root :root_user, class_name: 'User', foreign_key: :grp_id
5258
end
5359

54-
class User < ActiveRecord::Base
55-
acts_as_tree :parent_column_name => "referrer_id",
56-
:name_column => 'email',
57-
:hierarchy_class_name => 'ReferralHierarchy',
58-
:hierarchy_table_name => 'referral_hierarchies'
60+
class User < ApplicationRecord
61+
acts_as_tree parent_column_name: 'referrer_id',
62+
name_column: 'email',
63+
hierarchy_class_name: 'ReferralHierarchy',
64+
hierarchy_table_name: 'referral_hierarchies'
5965

6066
has_many :contracts, inverse_of: :user
6167
belongs_to :group # Can't use and don't need inverse_of here when using has_closure_tree_root.
6268

6369
def indirect_contracts
64-
Contract.where(:user_id => descendant_ids)
70+
Contract.where(user_id: descendant_ids)
6571
end
6672

6773
def to_s
6874
email
6975
end
7076
end
7177

72-
class Contract < ActiveRecord::Base
78+
class Contract < ApplicationRecord
7379
belongs_to :user, inverse_of: :contracts
7480
belongs_to :contract_type, inverse_of: :contracts
7581
end
7682

77-
class ContractType < ActiveRecord::Base
83+
class ContractType < ApplicationRecord
7884
has_many :contracts, inverse_of: :contract_type
7985
end
8086

81-
class Label < ActiveRecord::Base
87+
class Label < ApplicationRecord
8288
# make sure order doesn't matter
83-
acts_as_tree :order => :column_whereby_ordering_is_inferred, # <- symbol, and not "sort_order"
84-
:numeric_order => true,
85-
:parent_column_name => "mother_id",
86-
:dependent => :destroy
89+
acts_as_tree order: :column_whereby_ordering_is_inferred, # <- symbol, and not "sort_order"
90+
numeric_order: true,
91+
parent_column_name: 'mother_id',
92+
dependent: :destroy
8793

8894
def to_s
8995
"#{self.class}: #{name}"
@@ -99,13 +105,13 @@ class DateLabel < Label
99105
class DirectoryLabel < Label
100106
end
101107

102-
class LabelWithoutRootOrdering < ActiveRecord::Base
108+
class LabelWithoutRootOrdering < ApplicationRecord
103109
# make sure order doesn't matter
104-
acts_as_tree :order => :column_whereby_ordering_is_inferred, # <- symbol, and not "sort_order"
105-
:numeric_order => true,
106-
:dont_order_roots => true,
107-
:parent_column_name => "mother_id",
108-
:hierarchy_table_name => "label_hierarchies"
110+
acts_as_tree order: :column_whereby_ordering_is_inferred, # <- symbol, and not "sort_order"
111+
numeric_order: true,
112+
dont_order_roots: true,
113+
parent_column_name: 'mother_id',
114+
hierarchy_table_name: 'label_hierarchies'
109115

110116
self.table_name = "#{table_name_prefix}labels#{table_name_suffix}"
111117

@@ -114,20 +120,21 @@ def to_s
114120
end
115121
end
116122

117-
class CuisineType < ActiveRecord::Base
123+
class CuisineType < ApplicationRecord
118124
acts_as_tree
119125
end
120126

121127
module Namespace
122128
def self.table_name_prefix
123129
'namespace_'
124130
end
125-
class Type < ActiveRecord::Base
131+
132+
class Type < ApplicationRecord
126133
has_closure_tree dependent: :destroy
127134
end
128135
end
129136

130-
class Metal < ActiveRecord::Base
137+
class Metal < ApplicationRecord
131138
self.table_name = "#{table_name_prefix}metal#{table_name_suffix}"
132139
has_closure_tree order: 'sort_order', name_column: 'value'
133140
self.inheritance_column = 'metal_type'
@@ -139,6 +146,6 @@ class Adamantium < Metal
139146
class Unobtanium < Metal
140147
end
141148

142-
class MenuItem < ActiveRecord::Base
149+
class MenuItem < ApplicationRecord
143150
has_closure_tree touch: true, with_advisory_lock: false
144151
end

0 commit comments

Comments
 (0)