sequel-rails 0.7.0 → 0.8.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.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.rubocop.yml +13 -0
  4. data/.travis.yml +15 -43
  5. data/Gemfile +10 -10
  6. data/History.md +8 -0
  7. data/README.md +36 -0
  8. data/Rakefile +70 -2
  9. data/ci/rails-3.2.gemfile +15 -12
  10. data/ci/rails-4.0.gemfile +12 -12
  11. data/config.ru +1 -1
  12. data/lib/generators/sequel/migration/migration_generator.rb +10 -13
  13. data/lib/generators/sequel/model/model_generator.rb +11 -9
  14. data/lib/generators/sequel/observer/observer_generator.rb +6 -7
  15. data/lib/generators/sequel/session_migration/session_migration_generator.rb +30 -0
  16. data/lib/generators/sequel/session_migration/templates/migration.rb.erb +10 -0
  17. data/lib/generators/sequel.rb +9 -13
  18. data/lib/sequel-rails.rb +1 -1
  19. data/lib/sequel_rails/configuration.rb +29 -35
  20. data/lib/sequel_rails/migrations.rb +4 -4
  21. data/lib/sequel_rails/railtie.rb +16 -20
  22. data/lib/sequel_rails/railties/controller_runtime.rb +2 -8
  23. data/lib/sequel_rails/railties/database.rake +42 -46
  24. data/lib/sequel_rails/railties/i18n_support.rb +0 -2
  25. data/lib/sequel_rails/railties/legacy_model_config.rb +1 -1
  26. data/lib/sequel_rails/railties/log_subscriber.rb +5 -9
  27. data/lib/sequel_rails/sequel/database/active_support_notification.rb +4 -6
  28. data/lib/sequel_rails/sequel/plugins/rails_extensions.rb +2 -3
  29. data/lib/sequel_rails/session_store.rb +6 -42
  30. data/lib/sequel_rails/shellwords.rb +3 -3
  31. data/lib/sequel_rails/storage/abstract.rb +14 -16
  32. data/lib/sequel_rails/storage/jdbc.rb +8 -10
  33. data/lib/sequel_rails/storage/mysql.rb +13 -15
  34. data/lib/sequel_rails/storage/postgres.rb +42 -45
  35. data/lib/sequel_rails/storage/sqlite.rb +0 -1
  36. data/lib/sequel_rails/storage.rb +10 -10
  37. data/lib/sequel_rails/version.rb +1 -1
  38. data/lib/sequel_rails.rb +3 -3
  39. data/rubocop-todo.yml +24 -0
  40. data/sequel-rails.gemspec +21 -19
  41. data/spec/internal/Rakefile +2 -2
  42. data/spec/internal/config/initializers/session.rb +1 -1
  43. data/spec/internal/db/schema.rb.init +6 -0
  44. data/spec/lib/generators/sequel/migration_spec.rb +77 -77
  45. data/spec/lib/generators/sequel/session_migration_spec.rb +41 -0
  46. data/spec/lib/sequel_rails/configuration_spec.rb +161 -161
  47. data/spec/lib/sequel_rails/jdbc_spec.rb +4 -4
  48. data/spec/lib/sequel_rails/migrations_spec.rb +29 -29
  49. data/spec/lib/sequel_rails/railtie_spec.rb +31 -29
  50. data/spec/lib/sequel_rails/railties/database_rake_spec.rb +16 -15
  51. data/spec/lib/sequel_rails/railties/log_subscriber_spec.rb +6 -6
  52. data/spec/lib/sequel_rails/storage/mysql_spec.rb +31 -31
  53. data/spec/lib/sequel_rails/storage/postgres_spec.rb +67 -67
  54. data/spec/lib/sequel_rails/storage/sqlite_spec.rb +40 -40
  55. data/spec/lib/sequel_rails/storage_spec.rb +77 -89
  56. data/spec/spec_helper.rb +16 -10
  57. metadata +61 -28
  58. data/tasks/spec.rake +0 -81
@@ -1,36 +1,36 @@
1
- require "spec_helper"
2
- require "generator_spec/test_case"
3
- require "generators/sequel/migration/migration_generator"
1
+ require 'spec_helper'
2
+ require 'generator_spec/test_case'
3
+ require 'generators/sequel/migration/migration_generator'
4
4
 
5
5
  describe Sequel::Generators::MigrationGenerator do
6
6
  include GeneratorSpec::TestCase
7
- destination File.expand_path("../../../../internal/tmp", __FILE__)
7
+ destination File.expand_path('../../../../internal/tmp', __FILE__)
8
8
 
9
9
  before { prepare_destination }
10
10
 
11
- it "generates different ids for simultaneously generated migrations" do
12
- migrations = ["create_authors", "create_users"]
13
- first_number, second_number = migrations.collect do |migration_name|
11
+ it 'generates different ids for simultaneously generated migrations' do
12
+ migrations = %w(create_authors create_users)
13
+ first_number, second_number = migrations.map do |migration_name|
14
14
  run_generator [migration_name]
15
15
  file_name = migration_file_name "db/migrate/#{migration_name}.rb"
16
- File.basename(file_name).split("_").first
16
+ File.basename(file_name).split('_').first
17
17
  end
18
- first_number.should_not == second_number
18
+ expect(first_number).to_not eq(second_number)
19
19
  end
20
20
 
21
- it "refuses to generate migration with invalid filename" do
21
+ it 'refuses to generate migration with invalid filename' do
22
22
  expect do
23
- run_generator ["add_something:datetime"]
23
+ run_generator ['add_something:datetime']
24
24
  end.to raise_error
25
25
  end
26
26
 
27
- context "when name starts with create" do
28
- before { run_generator ["create_authors"] }
29
- it "creates a new migration using change to create the table" do
30
- destination_root.should have_structure {
31
- directory "db" do
32
- directory "migrate" do
33
- migration "create_authors" do
27
+ context 'when name starts with create' do
28
+ before { run_generator ['create_authors'] }
29
+ it 'creates a new migration using change to create the table' do
30
+ expect(destination_root).to have_structure {
31
+ directory 'db' do
32
+ directory 'migrate' do
33
+ migration 'create_authors' do
34
34
  contains <<-CONTENT.strip_heredoc
35
35
  Sequel.migration do
36
36
  change do
@@ -47,14 +47,14 @@ describe Sequel::Generators::MigrationGenerator do
47
47
  end
48
48
  end
49
49
 
50
- context "when name starts with drop" do
51
- context "and does not contains _from_" do
52
- before { run_generator ["drop_author"] }
53
- it "creates a new migration using up/down to drop the table" do
54
- destination_root.should have_structure {
55
- directory "db" do
56
- directory "migrate" do
57
- migration "drop_author" do
50
+ context 'when name starts with drop' do
51
+ context 'and does not contains _from_' do
52
+ before { run_generator ['drop_author'] }
53
+ it 'creates a new migration using up/down to drop the table' do
54
+ expect(destination_root).to have_structure {
55
+ directory 'db' do
56
+ directory 'migrate' do
57
+ migration 'drop_author' do
58
58
  contains <<-CONTENT.strip_heredoc
59
59
  Sequel.migration do
60
60
  up do
@@ -73,13 +73,13 @@ describe Sequel::Generators::MigrationGenerator do
73
73
  }
74
74
  end
75
75
  end
76
- context "and contains _from_" do
77
- before { run_generator ["drop_salary_from_authors"] }
78
- it "creates a new migration using up/down to drop the column from table" do
79
- destination_root.should have_structure {
80
- directory "db" do
81
- directory "migrate" do
82
- migration "drop_salary_from_authors" do
76
+ context 'and contains _from_' do
77
+ before { run_generator ['drop_salary_from_authors'] }
78
+ it 'creates a new migration using up/down to drop the column from table' do
79
+ expect(destination_root).to have_structure {
80
+ directory 'db' do
81
+ directory 'migrate' do
82
+ migration 'drop_salary_from_authors' do
83
83
  contains <<-CONTENT.strip_heredoc
84
84
  Sequel.migration do
85
85
  up do
@@ -101,14 +101,14 @@ describe Sequel::Generators::MigrationGenerator do
101
101
  end
102
102
  end
103
103
 
104
- context "when name starts with add" do
105
- context "and does not contains _to_ nor _from_" do
106
- before { run_generator ["add_new_indexes"] }
107
- it "creates a new migration using up/down" do
108
- destination_root.should have_structure {
109
- directory "db" do
110
- directory "migrate" do
111
- migration "add_new_indexes" do
104
+ context 'when name starts with add' do
105
+ context 'and does not contains _to_ nor _from_' do
106
+ before { run_generator ['add_new_indexes'] }
107
+ it 'creates a new migration using up/down' do
108
+ expect(destination_root).to have_structure {
109
+ directory 'db' do
110
+ directory 'migrate' do
111
+ migration 'add_new_indexes' do
112
112
  contains <<-CONTENT.strip_heredoc
113
113
  Sequel.migration do
114
114
  up do
@@ -128,13 +128,13 @@ describe Sequel::Generators::MigrationGenerator do
128
128
  }
129
129
  end
130
130
  end
131
- context "and contains _to_" do
132
- before { run_generator ["add_salary_to_authors"] }
133
- it "creates a new migration using change to add the column to the table" do
134
- destination_root.should have_structure {
135
- directory "db" do
136
- directory "migrate" do
137
- migration "add_salary_to_authors" do
131
+ context 'and contains _to_' do
132
+ before { run_generator ['add_salary_to_authors'] }
133
+ it 'creates a new migration using change to add the column to the table' do
134
+ expect(destination_root).to have_structure {
135
+ directory 'db' do
136
+ directory 'migrate' do
137
+ migration 'add_salary_to_authors' do
138
138
  contains <<-CONTENT.strip_heredoc
139
139
  Sequel.migration do
140
140
  change do
@@ -149,13 +149,13 @@ describe Sequel::Generators::MigrationGenerator do
149
149
  }
150
150
  end
151
151
  end
152
- context "and contains _from_" do
153
- before { run_generator ["add_salary_from_authors"] }
154
- it "creates a new migration using change to add the column to the table" do
155
- destination_root.should have_structure {
156
- directory "db" do
157
- directory "migrate" do
158
- migration "add_salary_from_authors" do
152
+ context 'and contains _from_' do
153
+ before { run_generator ['add_salary_from_authors'] }
154
+ it 'creates a new migration using change to add the column to the table' do
155
+ expect(destination_root).to have_structure {
156
+ directory 'db' do
157
+ directory 'migrate' do
158
+ migration 'add_salary_from_authors' do
159
159
  contains <<-CONTENT.strip_heredoc
160
160
  Sequel.migration do
161
161
  change do
@@ -172,14 +172,14 @@ describe Sequel::Generators::MigrationGenerator do
172
172
  end
173
173
  end
174
174
 
175
- context "when name starts with remove" do
176
- context "and does not contains _to_ nor _from_" do
177
- before { run_generator ["remove_new_indexes"] }
178
- it "creates a new migration using up/down" do
179
- destination_root.should have_structure {
180
- directory "db" do
181
- directory "migrate" do
182
- migration "remove_new_indexes" do
175
+ context 'when name starts with remove' do
176
+ context 'and does not contains _to_ nor _from_' do
177
+ before { run_generator ['remove_new_indexes'] }
178
+ it 'creates a new migration using up/down' do
179
+ expect(destination_root).to have_structure {
180
+ directory 'db' do
181
+ directory 'migrate' do
182
+ migration 'remove_new_indexes' do
183
183
  contains <<-CONTENT.strip_heredoc
184
184
  Sequel.migration do
185
185
  up do
@@ -199,13 +199,13 @@ describe Sequel::Generators::MigrationGenerator do
199
199
  }
200
200
  end
201
201
  end
202
- context "and contains _to_" do
203
- before { run_generator ["remove_salary_to_authors"] }
204
- it "creates a new migration using up/down to remove the column from the table" do
205
- destination_root.should have_structure {
206
- directory "db" do
207
- directory "migrate" do
208
- migration "remove_salary_to_authors" do
202
+ context 'and contains _to_' do
203
+ before { run_generator ['remove_salary_to_authors'] }
204
+ it 'creates a new migration using up/down to remove the column from the table' do
205
+ expect(destination_root).to have_structure {
206
+ directory 'db' do
207
+ directory 'migrate' do
208
+ migration 'remove_salary_to_authors' do
209
209
  contains <<-CONTENT.strip_heredoc
210
210
  Sequel.migration do
211
211
  up do
@@ -225,13 +225,13 @@ describe Sequel::Generators::MigrationGenerator do
225
225
  }
226
226
  end
227
227
  end
228
- context "and contains _from_" do
229
- before { run_generator ["remove_salary_from_authors"] }
230
- it "creates a new migration using change to remove the column from the table" do
231
- destination_root.should have_structure {
232
- directory "db" do
233
- directory "migrate" do
234
- migration "remove_salary_from_authors" do
228
+ context 'and contains _from_' do
229
+ before { run_generator ['remove_salary_from_authors'] }
230
+ it 'creates a new migration using change to remove the column from the table' do
231
+ expect(destination_root).to have_structure {
232
+ directory 'db' do
233
+ directory 'migrate' do
234
+ migration 'remove_salary_from_authors' do
235
235
  contains <<-CONTENT.strip_heredoc
236
236
  Sequel.migration do
237
237
  up do
@@ -0,0 +1,41 @@
1
+ require 'spec_helper'
2
+ require 'generator_spec/test_case'
3
+ require 'generators/sequel/session_migration/session_migration_generator'
4
+
5
+ describe Sequel::Generators::SessionMigrationGenerator do
6
+ include GeneratorSpec::TestCase
7
+ destination File.expand_path('../../../../internal/tmp', __FILE__)
8
+
9
+ before { prepare_destination }
10
+
11
+ it 'refuses to generate migration with invalid filename' do
12
+ expect do
13
+ run_generator ['add:sessions']
14
+ end.to raise_error
15
+ end
16
+
17
+ it 'creates a new migration for sessions table' do
18
+ run_generator
19
+ expect(destination_root).to have_structure {
20
+ directory 'db' do
21
+ directory 'migrate' do
22
+ migration 'add_sessions_table' do
23
+ contains <<-CONTENT.strip_heredoc
24
+ Sequel.migration do
25
+ change do
26
+ create_table :sessions do
27
+ primary_key :id
28
+ String :session_id, :null => false, :unique => true, :index => true
29
+ String :data, :text => true, :null => false
30
+ DateTime :updated_at, :null => true, :index => true
31
+ end
32
+ end
33
+ end
34
+ CONTENT
35
+ end
36
+ end
37
+ end
38
+ }
39
+ end
40
+
41
+ end