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.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.rubocop.yml +13 -0
- data/.travis.yml +15 -43
- data/Gemfile +10 -10
- data/History.md +8 -0
- data/README.md +36 -0
- data/Rakefile +70 -2
- data/ci/rails-3.2.gemfile +15 -12
- data/ci/rails-4.0.gemfile +12 -12
- data/config.ru +1 -1
- data/lib/generators/sequel/migration/migration_generator.rb +10 -13
- data/lib/generators/sequel/model/model_generator.rb +11 -9
- data/lib/generators/sequel/observer/observer_generator.rb +6 -7
- data/lib/generators/sequel/session_migration/session_migration_generator.rb +30 -0
- data/lib/generators/sequel/session_migration/templates/migration.rb.erb +10 -0
- data/lib/generators/sequel.rb +9 -13
- data/lib/sequel-rails.rb +1 -1
- data/lib/sequel_rails/configuration.rb +29 -35
- data/lib/sequel_rails/migrations.rb +4 -4
- data/lib/sequel_rails/railtie.rb +16 -20
- data/lib/sequel_rails/railties/controller_runtime.rb +2 -8
- data/lib/sequel_rails/railties/database.rake +42 -46
- data/lib/sequel_rails/railties/i18n_support.rb +0 -2
- data/lib/sequel_rails/railties/legacy_model_config.rb +1 -1
- data/lib/sequel_rails/railties/log_subscriber.rb +5 -9
- data/lib/sequel_rails/sequel/database/active_support_notification.rb +4 -6
- data/lib/sequel_rails/sequel/plugins/rails_extensions.rb +2 -3
- data/lib/sequel_rails/session_store.rb +6 -42
- data/lib/sequel_rails/shellwords.rb +3 -3
- data/lib/sequel_rails/storage/abstract.rb +14 -16
- data/lib/sequel_rails/storage/jdbc.rb +8 -10
- data/lib/sequel_rails/storage/mysql.rb +13 -15
- data/lib/sequel_rails/storage/postgres.rb +42 -45
- data/lib/sequel_rails/storage/sqlite.rb +0 -1
- data/lib/sequel_rails/storage.rb +10 -10
- data/lib/sequel_rails/version.rb +1 -1
- data/lib/sequel_rails.rb +3 -3
- data/rubocop-todo.yml +24 -0
- data/sequel-rails.gemspec +21 -19
- data/spec/internal/Rakefile +2 -2
- data/spec/internal/config/initializers/session.rb +1 -1
- data/spec/internal/db/schema.rb.init +6 -0
- data/spec/lib/generators/sequel/migration_spec.rb +77 -77
- data/spec/lib/generators/sequel/session_migration_spec.rb +41 -0
- data/spec/lib/sequel_rails/configuration_spec.rb +161 -161
- data/spec/lib/sequel_rails/jdbc_spec.rb +4 -4
- data/spec/lib/sequel_rails/migrations_spec.rb +29 -29
- data/spec/lib/sequel_rails/railtie_spec.rb +31 -29
- data/spec/lib/sequel_rails/railties/database_rake_spec.rb +16 -15
- data/spec/lib/sequel_rails/railties/log_subscriber_spec.rb +6 -6
- data/spec/lib/sequel_rails/storage/mysql_spec.rb +31 -31
- data/spec/lib/sequel_rails/storage/postgres_spec.rb +67 -67
- data/spec/lib/sequel_rails/storage/sqlite_spec.rb +40 -40
- data/spec/lib/sequel_rails/storage_spec.rb +77 -89
- data/spec/spec_helper.rb +16 -10
- metadata +61 -28
- data/tasks/spec.rake +0 -81
@@ -1,36 +1,36 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
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(
|
7
|
+
destination File.expand_path('../../../../internal/tmp', __FILE__)
|
8
8
|
|
9
9
|
before { prepare_destination }
|
10
10
|
|
11
|
-
it
|
12
|
-
migrations =
|
13
|
-
first_number, second_number = migrations.
|
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(
|
16
|
+
File.basename(file_name).split('_').first
|
17
17
|
end
|
18
|
-
first_number.
|
18
|
+
expect(first_number).to_not eq(second_number)
|
19
19
|
end
|
20
20
|
|
21
|
-
it
|
21
|
+
it 'refuses to generate migration with invalid filename' do
|
22
22
|
expect do
|
23
|
-
run_generator [
|
23
|
+
run_generator ['add_something:datetime']
|
24
24
|
end.to raise_error
|
25
25
|
end
|
26
26
|
|
27
|
-
context
|
28
|
-
before { run_generator [
|
29
|
-
it
|
30
|
-
destination_root.
|
31
|
-
directory
|
32
|
-
directory
|
33
|
-
migration
|
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
|
51
|
-
context
|
52
|
-
before { run_generator [
|
53
|
-
it
|
54
|
-
destination_root.
|
55
|
-
directory
|
56
|
-
directory
|
57
|
-
migration
|
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
|
77
|
-
before { run_generator [
|
78
|
-
it
|
79
|
-
destination_root.
|
80
|
-
directory
|
81
|
-
directory
|
82
|
-
migration
|
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
|
105
|
-
context
|
106
|
-
before { run_generator [
|
107
|
-
it
|
108
|
-
destination_root.
|
109
|
-
directory
|
110
|
-
directory
|
111
|
-
migration
|
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
|
132
|
-
before { run_generator [
|
133
|
-
it
|
134
|
-
destination_root.
|
135
|
-
directory
|
136
|
-
directory
|
137
|
-
migration
|
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
|
153
|
-
before { run_generator [
|
154
|
-
it
|
155
|
-
destination_root.
|
156
|
-
directory
|
157
|
-
directory
|
158
|
-
migration
|
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
|
176
|
-
context
|
177
|
-
before { run_generator [
|
178
|
-
it
|
179
|
-
destination_root.
|
180
|
-
directory
|
181
|
-
directory
|
182
|
-
migration
|
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
|
203
|
-
before { run_generator [
|
204
|
-
it
|
205
|
-
destination_root.
|
206
|
-
directory
|
207
|
-
directory
|
208
|
-
migration
|
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
|
229
|
-
before { run_generator [
|
230
|
-
it
|
231
|
-
destination_root.
|
232
|
-
directory
|
233
|
-
directory
|
234
|
-
migration
|
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
|