arel-helpers 2.11.0 → 2.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +3 -2
- data/arel-helpers.gemspec +12 -9
- data/lib/arel-helpers/join_association.rb +61 -34
- 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 +24 -25
- data/spec/spec_helper.rb +10 -19
- metadata +57 -13
- data/spec/env.rb +0 -44
- data/spec/env/migrations.rb +0 -75
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,75 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
|
-
SuperClass = if ActiveRecord::VERSION::MAJOR >= 5
|
4
|
-
ActiveRecord::Migration["#{ActiveRecord::VERSION::MAJOR}.#{ActiveRecord::VERSION::MINOR}".to_f]
|
5
|
-
else
|
6
|
-
ActiveRecord::Migration
|
7
|
-
end
|
8
|
-
|
9
|
-
class CreatePostsTable < SuperClass
|
10
|
-
def change
|
11
|
-
create_table :posts do |t|
|
12
|
-
t.column :title, :string
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
class CreateCommentsTable < SuperClass
|
18
|
-
def change
|
19
|
-
create_table :comments do |t|
|
20
|
-
t.references :post
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
class CreateAuthorsTable < SuperClass
|
26
|
-
def change
|
27
|
-
create_table :authors do |t|
|
28
|
-
t.references :comment
|
29
|
-
t.references :collab_posts
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
class CreateFavoritesTable < SuperClass
|
35
|
-
def change
|
36
|
-
create_table :favorites do |t|
|
37
|
-
t.references :post
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
class CreateCollabPostsTable < SuperClass
|
43
|
-
def change
|
44
|
-
create_table :collab_posts do |t|
|
45
|
-
t.references :authors
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
class CreateCardsTable < SuperClass
|
51
|
-
def change
|
52
|
-
create_table :cards
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
class CreateCardLocationsTable < SuperClass
|
57
|
-
def change
|
58
|
-
create_table :card_locations do |t|
|
59
|
-
t.references :location
|
60
|
-
t.references :card, polymorphic: true
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
class CreateLocationsTable < SuperClass
|
66
|
-
def change
|
67
|
-
create_table :locations
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
class CreateCommunityTicketsTable < SuperClass
|
72
|
-
def change
|
73
|
-
create_table :community_tickets
|
74
|
-
end
|
75
|
-
end
|