model_from_table 0.0.2 → 0.0.3
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/lib/generators/model_from_table_generator.rb +8 -0
- data/lib/generators/templates/model.rb +3 -0
- data/lib/model_from_table/version.rb +1 -1
- data/test/dummy/db/development.sqlite3 +0 -0
- data/test/dummy/db/migrate/20140728150510_create_tables.rb +5 -0
- data/test/dummy/db/schema.rb +4 -0
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/log/RAILS_ENV=test.log +0 -0
- data/test/dummy/log/development.log +68 -97
- data/test/dummy/log/test.log +290 -646
- data/test/model_from_table_generator_test.rb +12 -0
- data/test/tmp/app/models/song.rb +5 -0
- metadata +6 -2
@@ -52,4 +52,16 @@ class ModelFromTableGeneratorTest < Rails::Generators::TestCase
|
|
52
52
|
assert_match /end/, content
|
53
53
|
end
|
54
54
|
end
|
55
|
+
|
56
|
+
test "set `belongs_to :foo` if table has `foo_id` column" do
|
57
|
+
run_generator
|
58
|
+
|
59
|
+
assert_file 'app/models/song.rb' do |content|
|
60
|
+
assert_match /class Song < ActiveRecord::Base/, content
|
61
|
+
assert_match /self.table_name = "song"/, content
|
62
|
+
assert_match /self.primary_key = "song_code"/, content
|
63
|
+
assert_match /belongs_to :user/, content
|
64
|
+
assert_match /end/, content
|
65
|
+
end
|
66
|
+
end
|
55
67
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: model_from_table
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hidenori Maehara
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-08-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -100,6 +100,7 @@ files:
|
|
100
100
|
- test/dummy/db/migrate/20140728150510_create_tables.rb
|
101
101
|
- test/dummy/db/schema.rb
|
102
102
|
- test/dummy/db/test.sqlite3
|
103
|
+
- test/dummy/log/RAILS_ENV=test.log
|
103
104
|
- test/dummy/log/development.log
|
104
105
|
- test/dummy/log/test.log
|
105
106
|
- test/dummy/public/404.html
|
@@ -110,6 +111,7 @@ files:
|
|
110
111
|
- test/test_helper.rb
|
111
112
|
- test/tmp/app/models/company.rb
|
112
113
|
- test/tmp/app/models/legacy_table.rb
|
114
|
+
- test/tmp/app/models/song.rb
|
113
115
|
- test/tmp/app/models/user.rb
|
114
116
|
homepage: https://github.com/maeharin/model_from_table
|
115
117
|
licenses:
|
@@ -168,6 +170,7 @@ test_files:
|
|
168
170
|
- test/dummy/db/schema.rb
|
169
171
|
- test/dummy/db/test.sqlite3
|
170
172
|
- test/dummy/log/development.log
|
173
|
+
- test/dummy/log/RAILS_ENV=test.log
|
171
174
|
- test/dummy/log/test.log
|
172
175
|
- test/dummy/public/404.html
|
173
176
|
- test/dummy/public/422.html
|
@@ -179,4 +182,5 @@ test_files:
|
|
179
182
|
- test/test_helper.rb
|
180
183
|
- test/tmp/app/models/company.rb
|
181
184
|
- test/tmp/app/models/legacy_table.rb
|
185
|
+
- test/tmp/app/models/song.rb
|
182
186
|
- test/tmp/app/models/user.rb
|