localtower 0.1.7 → 0.1.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,70 @@
1
+ require 'spec_helper'
2
+
3
+ describe ::Localtower::Generators::ServiceObjects::InsertDefaults do
4
+
5
+ let(:latest_migration) do
6
+ Tempfile.new('foo').tap do |file|
7
+ file.puts base_file_content
8
+ file.rewind
9
+ end
10
+ end
11
+
12
+ let(:attributes) {
13
+ [
14
+ { 'first' => "true" },
15
+ { 'third' => "nil" },
16
+ { 'fourth' => "false" },
17
+ { 'fifth' => "0" }
18
+ ]
19
+ }
20
+
21
+ let(:base_file_content) {
22
+ <<-MIGRATION.strip_heredoc
23
+ class CreateTests < ActiveRecord::Migration[5.0]
24
+ def change
25
+ create_table :tests do |t|
26
+ t.string :first
27
+ t.integer :second
28
+ t.string :third
29
+ t.string :fourth
30
+ t.integer :fifth
31
+
32
+ t.timestamps
33
+ end
34
+ add_index :tests, :first
35
+ end
36
+ end
37
+ MIGRATION
38
+ }
39
+
40
+ let(:expected_file_structure_array) {
41
+ [
42
+ "class CreateTests < ActiveRecord::Migration[5.0]\n",
43
+ " def change\n",
44
+ " create_table :tests do |t|\n",
45
+ " t.string :first, default: true\n",
46
+ " t.integer :second\n",
47
+ " t.string :third, default: nil\n",
48
+ " t.string :fourth, default: false\n",
49
+ " t.integer :fifth, default: 0\n",
50
+ "\n",
51
+ " t.timestamps\n",
52
+ " end\n",
53
+ " add_index :tests, :first\n",
54
+ " end\n",
55
+ "end\n"
56
+ ]
57
+ }
58
+
59
+ let(:service) { described_class.new(attributes) }
60
+
61
+ before do
62
+ allow(service).to receive(:latest_migration).and_return(latest_migration)
63
+ service.call
64
+ end
65
+
66
+ it 'inserts default values for attributes' do
67
+ lines_array = File.readlines(latest_migration)
68
+ expect(lines_array).to match_array expected_file_structure_array
69
+ end
70
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: localtower
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Damian Le Nouaille
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-03-14 00:00:00.000000000 Z
11
+ date: 2017-03-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -160,6 +160,7 @@ files:
160
160
  - lib/localtower/generators/migration.rb
161
161
  - lib/localtower/generators/model.rb
162
162
  - lib/localtower/generators/relation.rb
163
+ - lib/localtower/generators/service_objects/insert_defaults.rb
163
164
  - lib/localtower/status.rb
164
165
  - lib/localtower/tools.rb
165
166
  - lib/localtower/version.rb
@@ -204,6 +205,9 @@ files:
204
205
  - public/light-bootstrap-dashboard-master/assets/js/demo.js
205
206
  - public/light-bootstrap-dashboard-master/assets/js/jquery-1.10.2.js
206
207
  - public/light-bootstrap-dashboard-master/assets/js/light-bootstrap-dashboard.js
208
+ - public/logo-localtower-white-300.png
209
+ - public/logo-localtower-white.png
210
+ - public/logo-localtower.png
207
211
  - public/screenshots/v0.1.1/1_schema.png
208
212
  - public/screenshots/v0.1.1/2_models_1.png
209
213
  - public/screenshots/v0.1.1/2_models_2.png
@@ -298,6 +302,7 @@ files:
298
302
  - spec/lib/localtower/generators/migration_spec.rb
299
303
  - spec/lib/localtower/generators/model_spec.rb
300
304
  - spec/lib/localtower/generators/relation_spec.rb
305
+ - spec/lib/localtower/generators/service_objects/insert_defaults_spec.rb
301
306
  - spec/lib/localtower/tools_spec.rb
302
307
  - spec/spec_helper.rb
303
308
  homepage: https://github.com/damln/localtower
@@ -409,5 +414,6 @@ test_files:
409
414
  - spec/lib/localtower/generators/migration_spec.rb
410
415
  - spec/lib/localtower/generators/model_spec.rb
411
416
  - spec/lib/localtower/generators/relation_spec.rb
417
+ - spec/lib/localtower/generators/service_objects/insert_defaults_spec.rb
412
418
  - spec/lib/localtower/tools_spec.rb
413
419
  - spec/spec_helper.rb