arel-helpers 2.8.0 → 2.12.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.
- checksums.yaml +4 -4
- data/Gemfile +1 -14
- data/README.md +27 -1
- data/arel-helpers.gemspec +15 -13
- data/lib/arel-helpers/join_association.rb +87 -29
- data/lib/arel-helpers/query_builder.rb +15 -0
- data/lib/arel-helpers/version.rb +1 -1
- data/spec/aliases_spec.rb +5 -7
- data/spec/arel_table_spec.rb +11 -13
- data/spec/env/models.rb +2 -6
- data/spec/internal/config/database.yml +3 -0
- data/spec/internal/db/combustion_test.sqlite +0 -0
- data/spec/internal/db/schema.rb +34 -0
- data/spec/internal/log/test.log +2979 -0
- data/spec/join_association_spec.rb +101 -57
- data/spec/query_builder_spec.rb +31 -18
- data/spec/spec_helper.rb +10 -20
- metadata +96 -11
- data/spec/env.rb +0 -44
- data/spec/env/migrations.rb +0 -71
data/spec/env.rb
DELETED
@@ -1,44 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
|
-
require 'env/migrations'
|
4
|
-
require 'env/models'
|
5
|
-
|
6
|
-
module ArelHelpers
|
7
|
-
class Env
|
8
|
-
class << self
|
9
|
-
|
10
|
-
def db_dir
|
11
|
-
@db_dir ||= File.join(File.dirname(File.dirname(__FILE__)), "tmp")
|
12
|
-
end
|
13
|
-
|
14
|
-
def db_file
|
15
|
-
@db_file ||= File.join(db_dir, "test.sqlite3")
|
16
|
-
end
|
17
|
-
|
18
|
-
def establish_connection
|
19
|
-
ActiveRecord::Base.establish_connection(
|
20
|
-
:adapter => "sqlite3",
|
21
|
-
:database => db_file
|
22
|
-
)
|
23
|
-
end
|
24
|
-
|
25
|
-
def migrate
|
26
|
-
CreatePostsTable.new.change
|
27
|
-
CreateCommentsTable.new.change
|
28
|
-
CreateAuthorsTable.new.change
|
29
|
-
CreateFavoritesTable.new.change
|
30
|
-
CreateCollabPostsTable.new.change
|
31
|
-
CreateCardsTable.new.change
|
32
|
-
CreateCardLocationsTable.new.change
|
33
|
-
CreateLocationsTable.new.change
|
34
|
-
CreateCommunityTicketsTable.new.change
|
35
|
-
end
|
36
|
-
|
37
|
-
def reset
|
38
|
-
File.unlink(db_file) if File.exist?(db_file)
|
39
|
-
FileUtils.mkdir_p(db_dir)
|
40
|
-
end
|
41
|
-
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
data/spec/env/migrations.rb
DELETED
@@ -1,71 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
|
-
SuperClass = ActiveRecord::VERSION::MAJOR >= 5 && ActiveRecord::VERSION::MINOR >= 1 ? ActiveRecord::Migration[5.1] : ActiveRecord::Migration
|
4
|
-
|
5
|
-
class CreatePostsTable < SuperClass
|
6
|
-
def change
|
7
|
-
create_table :posts do |t|
|
8
|
-
t.column :title, :string
|
9
|
-
end
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
class CreateCommentsTable < SuperClass
|
14
|
-
def change
|
15
|
-
create_table :comments do |t|
|
16
|
-
t.references :post
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
class CreateAuthorsTable < SuperClass
|
22
|
-
def change
|
23
|
-
create_table :authors do |t|
|
24
|
-
t.references :comment
|
25
|
-
t.references :collab_posts
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
class CreateFavoritesTable < SuperClass
|
31
|
-
def change
|
32
|
-
create_table :favorites do |t|
|
33
|
-
t.references :post
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
class CreateCollabPostsTable < SuperClass
|
39
|
-
def change
|
40
|
-
create_table :collab_posts do |t|
|
41
|
-
t.references :authors
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
class CreateCardsTable < SuperClass
|
47
|
-
def change
|
48
|
-
create_table :cards
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
class CreateCardLocationsTable < SuperClass
|
53
|
-
def change
|
54
|
-
create_table :card_locations do |t|
|
55
|
-
t.references :location
|
56
|
-
t.references :card, polymorphic: true
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
class CreateLocationsTable < SuperClass
|
62
|
-
def change
|
63
|
-
create_table :locations
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
class CreateCommunityTicketsTable < SuperClass
|
68
|
-
def change
|
69
|
-
create_table :community_tickets
|
70
|
-
end
|
71
|
-
end
|