fx 0.6.2 → 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 (59) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +58 -0
  3. data/.gitignore +0 -1
  4. data/.rspec +1 -1
  5. data/.standard.yml +3 -0
  6. data/CONTRIBUTING.md +12 -3
  7. data/Gemfile +1 -1
  8. data/README.md +6 -2
  9. data/Rakefile +2 -1
  10. data/bin/setup +0 -4
  11. data/fx.gemspec +20 -22
  12. data/lib/fx/function.rb +4 -4
  13. data/lib/fx/statements/function.rb +14 -8
  14. data/lib/fx/statements/trigger.rb +21 -12
  15. data/lib/fx/version.rb +1 -1
  16. data/lib/fx.rb +3 -3
  17. data/lib/generators/fx/function/function_generator.rb +6 -6
  18. data/lib/generators/fx/trigger/trigger_generator.rb +6 -6
  19. data/spec/acceptance/user_manages_functions_spec.rb +1 -1
  20. data/spec/acceptance/user_manages_triggers_spec.rb +2 -2
  21. data/spec/acceptance_helper.rb +4 -2
  22. data/spec/dummy/Rakefile +4 -4
  23. data/spec/dummy/bin/bundle +2 -2
  24. data/spec/dummy/bin/rails +3 -3
  25. data/spec/dummy/bin/rake +2 -2
  26. data/spec/dummy/config/application.rb +2 -0
  27. data/spec/dummy/config/database.yml +2 -0
  28. data/spec/dummy/config.ru +1 -1
  29. data/spec/features/functions/migrations_spec.rb +1 -1
  30. data/spec/features/functions/revert_spec.rb +4 -4
  31. data/spec/features/triggers/migrations_spec.rb +2 -2
  32. data/spec/features/triggers/revert_spec.rb +8 -8
  33. data/spec/fx/adapters/postgres/triggers_spec.rb +3 -3
  34. data/spec/fx/adapters/postgres_spec.rb +2 -2
  35. data/spec/fx/command_recorder/arguments_spec.rb +4 -4
  36. data/spec/fx/command_recorder_spec.rb +23 -23
  37. data/spec/fx/definition_spec.rb +6 -6
  38. data/spec/fx/function_spec.rb +20 -7
  39. data/spec/fx/schema_dumper/function_spec.rb +9 -9
  40. data/spec/fx/schema_dumper/trigger_spec.rb +3 -3
  41. data/spec/fx/statements/function_spec.rb +17 -17
  42. data/spec/fx/statements/trigger_spec.rb +20 -20
  43. data/spec/fx/trigger_spec.rb +6 -6
  44. data/spec/generators/fx/function/function_generator_spec.rb +3 -3
  45. data/spec/support/definition_helpers.rb +4 -4
  46. data/spec/support/generator_setup.rb +1 -1
  47. data/spec/support/migration_helpers.rb +1 -1
  48. metadata +25 -71
  49. data/.hound.yml +0 -2
  50. data/.rubocop.yml +0 -648
  51. data/.travis.yml +0 -39
  52. data/Appraisals +0 -32
  53. data/bin/appraisal +0 -17
  54. data/gemfiles/rails42.gemfile +0 -9
  55. data/gemfiles/rails50.gemfile +0 -8
  56. data/gemfiles/rails51.gemfile +0 -8
  57. data/gemfiles/rails52.gemfile +0 -8
  58. data/gemfiles/rails60.gemfile +0 -8
  59. data/gemfiles/rails_edge.gemfile +0 -8
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1e391283922484cf5a5b06c7de944c3162a85b7b49546f1fd1a017a6fc762898
4
- data.tar.gz: 73b179c85ebc70977bf4d2afbe45088284a9730138c2a424d940d72fb2ab0a30
3
+ metadata.gz: bfa4dae8b8e550ee4ddc34b4d0d78c50cc085d01662993f0874f804525fdd51f
4
+ data.tar.gz: 6e57a6df8b97e7638de3b05d9204c4bdcf2db90b585dfb617a1c2e3492d9f8b5
5
5
  SHA512:
6
- metadata.gz: 144fcbf71aad79383ee1ae98047b6fc018212ecd3ea2d747f883d7def2c649590b1d04fc77b0a84113fa832a6a0377857cf8482d2290c0c40f6496be0e6db470
7
- data.tar.gz: 057f585e7e83a89aebfda256605813a7db9e7d01b5841f436be0a9f7323540fd5a49999e4bf3bbc6db33ab0342e4ad0727b1b9b16690ed3a1aea00ea3011ea2d
6
+ metadata.gz: c4cf689e5a1847b7ad45b2679dd45046555f750fb7bc8ed9dc2c473da1e6a6eba344a312fa0b33852197ec7c5d81dc92a3ff416939ba8f5435f8a5da16c928df
7
+ data.tar.gz: 1d59049f9bb409bcbb56c3126f9675f1492e0a3d434858d2cb44af8a3d5aba74ee1fe5f78bbc73bab707aae05cfe8d8ed671a4a7e5dc8fa4841df176ebd88c30
@@ -0,0 +1,58 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: master
6
+ pull_request:
7
+ branches: "*"
8
+
9
+ jobs:
10
+ tests:
11
+ name: Ruby ${{ matrix.ruby }}, Rails ${{ matrix.rails }}
12
+ runs-on: ubuntu-latest
13
+
14
+ strategy:
15
+ fail-fast: false
16
+ matrix:
17
+ ruby: ["2.7", "3.0", "3.1", "3.2"]
18
+ rails: ["6.0", "6.1", "7.0"]
19
+ continue-on-error: [false]
20
+ exclude:
21
+ - ruby: "3.2"
22
+ rails: "6.0"
23
+ - ruby: "3.2"
24
+ rails: "6.1"
25
+
26
+ services:
27
+ postgres:
28
+ image: postgres:14
29
+ env:
30
+ POSTGRES_USER: postgres
31
+ POSTGRES_HOST_AUTH_METHOD: trust
32
+ ports:
33
+ - 5432:5432
34
+ # Set health checks to wait until postgres has started
35
+ options: >-
36
+ --health-cmd pg_isready
37
+ --health-interval 10s
38
+ --health-timeout 5s
39
+ --health-retries 5
40
+
41
+ env:
42
+ POSTGRES_USER: postgres
43
+
44
+ steps:
45
+ - uses: actions/checkout@v3
46
+
47
+ - name: Set up Ruby
48
+ uses: ruby/setup-ruby@v1
49
+ with:
50
+ ruby-version: ${{ matrix.ruby }}
51
+ bundler-cache: true
52
+ rubygems: latest
53
+
54
+ - name: Setup environment
55
+ run: bin/setup
56
+
57
+ - name: Run tests
58
+ run: bundle exec rake
data/.gitignore CHANGED
@@ -1,5 +1,4 @@
1
1
  /.bundle/
2
- /gemfiles/*.gemfile.lock
3
2
  /.yardoc
4
3
  /Gemfile.lock
5
4
  /_yardoc/
data/.rspec CHANGED
@@ -1,2 +1,2 @@
1
- --color
1
+ --no-color
2
2
  --require spec_helper
data/.standard.yml ADDED
@@ -0,0 +1,3 @@
1
+ ignore:
2
+ - 'spec/dummy/db/schema.rb'
3
+ - '**/tmp/*'
data/CONTRIBUTING.md CHANGED
@@ -1,12 +1,21 @@
1
1
  # Contributing
2
2
 
3
+ We love contributions from everyone. By participating in this project, you
4
+ agree to abide by our [code of conduct].
5
+
6
+ [code of conduct]: CODE_OF_CONDUCT.md
7
+
8
+ ## Contributing Code
9
+
3
10
  1. Fork the repository.
4
11
  2. Run `bin/setup`, which will install dependencies and create the dummy
5
12
  application database.
6
- 3. Run `bin/appraisal rake` to verify that the tests pass against all
7
- supported versions of Rails.
8
- 4. Make your change with new passing tests, following the existing style.
13
+ 3. Run `rake` to verify that the tests pass against the version of Rails you are
14
+ running locally.
15
+ 4. Make your change with new passing tests, following existing style.
9
16
  5. Write a [good commit message], push your fork, and submit a pull request.
17
+ 6. CI will run the test suite on all configured versions of Ruby and Rails.
18
+ Address any failures.
10
19
 
11
20
  [good commit message]: http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html
12
21
 
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source 'https://rubygems.org'
1
+ source "https://rubygems.org"
2
2
 
3
3
  # Specify your gem's dependencies in fx.gemspec
4
4
  gemspec
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # F(x)
2
2
 
3
- [![Build Status](https://travis-ci.com/teoljungberg/fx.svg?token=AgJn4nPeY6ue2Pvy23JQ&branch=master)](https://travis-ci.com/teoljungberg/fx)
3
+ [![Build Status](https://github.com/teoljungberg/fx/actions/workflows/ci.yml/badge.svg)](https://github.com/teoljungberg/fx/actions/workflows/ci.yml)
4
4
  [![Documentation Quality](http://inch-ci.org/github/teoljungberg/fx.svg?branch=master)](http://inch-ci.org/github/teoljungberg/fx)
5
5
 
6
6
  F(x) adds methods to `ActiveRecord::Migration` to create and manage database
@@ -49,7 +49,7 @@ In our example, this might look something like this:
49
49
  CREATE TRIGGER uppercase_users_name
50
50
  BEFORE INSERT ON users
51
51
  FOR EACH ROW
52
- EXECUTE PROCEDURE uppercase_users_name();
52
+ EXECUTE FUNCTION uppercase_users_name();
53
53
  ```
54
54
 
55
55
  The generated migrations contains `create_function` and `create_trigger`
@@ -108,6 +108,10 @@ end
108
108
  That's how you tell Rails to use the default as a literal SQL for the default
109
109
  column value instead of a plain string.
110
110
 
111
+ ## Plugins/Adapters
112
+
113
+ - [SQLserver](https://github.com/tarellel/fx-sqlserver-adapter)
114
+
111
115
  ## Contributing
112
116
 
113
117
  See [contributing](CONTRIBUTING.md) for more details.
data/Rakefile CHANGED
@@ -1,5 +1,6 @@
1
1
  require "bundler/gem_tasks"
2
2
  require "rspec/core/rake_task"
3
+ require "standard/rake"
3
4
 
4
5
  namespace :dummy do
5
6
  require_relative "spec/dummy/config/application"
@@ -20,4 +21,4 @@ RSpec::Core::RakeTask.new("spec:acceptance") do |task|
20
21
  end
21
22
 
22
23
  desc "Run the specs and acceptance tests"
23
- task default: %w(spec spec:acceptance)
24
+ task default: %w[spec spec:acceptance standard]
data/bin/setup CHANGED
@@ -5,9 +5,5 @@ set -e
5
5
  gem install bundler --conservative
6
6
  bundle check || bundle install
7
7
 
8
- if [ -z "$CI" ]; then
9
- bundle exec appraisal install
10
- fi
11
-
12
8
  bundle exec rake dummy:db:drop
13
9
  bundle exec rake dummy:db:create
data/fx.gemspec CHANGED
@@ -1,38 +1,36 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
1
+ lib = File.expand_path("../lib", __FILE__)
3
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
3
  require "fx/version"
5
4
 
6
5
  Gem::Specification.new do |spec|
7
- spec.name = "fx"
8
- spec.version = Fx::VERSION
9
- spec.authors = ["Teo Ljungberg"]
10
- spec.email = ["teo@teoljungberg.com"]
11
- spec.summary = %q{Support for database functions and triggers in Rails migrations}
12
- spec.description = <<-DESCRIPTION
6
+ spec.name = "fx"
7
+ spec.version = Fx::VERSION
8
+ spec.authors = ["Teo Ljungberg"]
9
+ spec.email = ["teo@teoljungberg.com"]
10
+ spec.summary = "Support for database functions and triggers in Rails migrations"
11
+ spec.description = <<-DESCRIPTION
13
12
  Adds methods to ActiveRecord::Migration to create and manage database functions
14
13
  and triggers in Rails
15
14
  DESCRIPTION
16
- spec.homepage = "https://github.com/teoljungberg/fx"
17
- spec.license = 'MIT'
15
+ spec.homepage = "https://github.com/teoljungberg/fx"
16
+ spec.license = "MIT"
18
17
 
19
- spec.files = `git ls-files -z`.split("\x0")
20
- spec.test_files = spec.files.grep(%r{^spec/})
21
- spec.require_paths = ['lib']
18
+ spec.files = `git ls-files -z`.split("\x0")
19
+ spec.require_paths = ["lib"]
22
20
 
23
- spec.add_development_dependency "appraisal"
24
- spec.add_development_dependency "bundler", '>= 1.5'
21
+ spec.add_development_dependency "ammeter", ">= 1.1.3"
22
+ spec.add_development_dependency "bundler", ">= 1.5"
25
23
  spec.add_development_dependency "database_cleaner"
26
- spec.add_development_dependency "rake"
27
- spec.add_development_dependency "rspec", '>= 3.3'
28
24
  spec.add_development_dependency "pg"
29
25
  spec.add_development_dependency "pry"
30
- spec.add_development_dependency "ammeter", '>= 1.1.3'
31
- spec.add_development_dependency "yard"
26
+ spec.add_development_dependency "rake"
32
27
  spec.add_development_dependency "redcarpet"
28
+ spec.add_development_dependency "rspec", ">= 3.3"
29
+ spec.add_development_dependency "standardrb"
30
+ spec.add_development_dependency "yard"
33
31
 
34
- spec.add_dependency "activerecord", '>= 4.0.0'
35
- spec.add_dependency "railties", '>= 4.0.0'
32
+ spec.add_dependency "activerecord", ">= 6.0.0"
33
+ spec.add_dependency "railties", ">= 6.0.0"
36
34
 
37
- spec.required_ruby_version = ">= 2.1"
35
+ spec.required_ruby_version = ">= 2.7"
38
36
  end
data/lib/fx/function.rb CHANGED
@@ -16,10 +16,10 @@ module Fx
16
16
  end
17
17
 
18
18
  def to_schema
19
- <<-SCHEMA.indent(2)
20
- create_function :#{name}, sql_definition: <<-\SQL
21
- #{definition.indent(4).rstrip}
22
- SQL
19
+ <<~SCHEMA.indent(2)
20
+ create_function :#{name}, sql_definition: <<-'SQL'
21
+ #{definition.indent(4).rstrip}
22
+ SQL
23
23
  SCHEMA
24
24
  end
25
25
  end
@@ -11,7 +11,7 @@ module Fx
11
11
  # find the definition file in `db/functions`. This defaults to `1` if
12
12
  # not provided.
13
13
  # @param sql_definition [String] The SQL query for the function schema.
14
- # If both `sql_defintion` and `version` are provided,
14
+ # If both `sql_definition` and `version` are provided,
15
15
  # `sql_definition` takes prescedence.
16
16
  # @return The database response from executing the create statement.
17
17
  #
@@ -29,11 +29,14 @@ module Fx
29
29
  # $$ LANGUAGE plpgsql;
30
30
  # SQL
31
31
  #
32
- def create_function(name, version: 1, sql_definition: nil)
32
+ def create_function(name, options = {})
33
+ version = options.fetch(:version, 1)
34
+ sql_definition = options[:sql_definition]
35
+
33
36
  if version.nil? && sql_definition.nil?
34
37
  raise(
35
38
  ArgumentError,
36
- "version or sql_definition must be specified",
39
+ "version or sql_definition must be specified"
37
40
  )
38
41
  end
39
42
  sql_definition = sql_definition.strip_heredoc if sql_definition
@@ -53,7 +56,7 @@ module Fx
53
56
  # @example Drop a function, rolling back to version 2 on rollback
54
57
  # drop_function(:uppercase_users_name, revert_to_version: 2)
55
58
  #
56
- def drop_function(name, revert_to_version: nil)
59
+ def drop_function(name, options = {})
57
60
  Fx.database.drop_function(name)
58
61
  end
59
62
 
@@ -64,7 +67,7 @@ module Fx
64
67
  # find the definition file in `db/functions`. This defaults to `1` if
65
68
  # not provided.
66
69
  # @param sql_definition [String] The SQL query for the function schema.
67
- # If both `sql_defintion` and `version` are provided,
70
+ # If both `sql_definition` and `version` are provided,
68
71
  # `sql_definition` takes prescedence.
69
72
  # @return The database response from executing the create statement.
70
73
  #
@@ -86,18 +89,21 @@ module Fx
86
89
  # $$ LANGUAGE plpgsql;
87
90
  # SQL
88
91
  #
89
- def update_function(name, version: nil, sql_definition: nil, revert_to_version: nil)
92
+ def update_function(name, options = {})
93
+ version = options[:version]
94
+ sql_definition = options[:sql_definition]
95
+
90
96
  if version.nil? && sql_definition.nil?
91
97
  raise(
92
98
  ArgumentError,
93
- "version or sql_definition must be specified",
99
+ "version or sql_definition must be specified"
94
100
  )
95
101
  end
96
102
 
97
103
  sql_definition = sql_definition.strip_heredoc if sql_definition
98
104
  sql_definition ||= Fx::Definition.new(
99
105
  name: name,
100
- version: version,
106
+ version: version
101
107
  ).to_sql
102
108
 
103
109
  Fx.database.update_function(name, sql_definition)
@@ -3,7 +3,7 @@ module Fx
3
3
  # Methods that are made available in migrations for managing Fx triggers.
4
4
  module Trigger
5
5
  # @api private
6
- DEFINTION_TYPE = "trigger".freeze
6
+ DEFINITION_TYPE = "trigger".freeze
7
7
 
8
8
  # Create a new database trigger.
9
9
  #
@@ -24,14 +24,18 @@ module Fx
24
24
  # CREATE TRIGGER uppercase_users_name
25
25
  # BEFORE INSERT ON users
26
26
  # FOR EACH ROW
27
- # EXECUTE PROCEDURE uppercase_users_name();
27
+ # EXECUTE FUNCTION uppercase_users_name();
28
28
  # SQL
29
29
  #
30
- def create_trigger(name, version: nil, on: nil, sql_definition: nil)
30
+ def create_trigger(name, options = {})
31
+ version = options[:version]
32
+ _on = options[:on]
33
+ sql_definition = options[:sql_definition]
34
+
31
35
  if version.present? && sql_definition.present?
32
36
  raise(
33
37
  ArgumentError,
34
- "sql_definition and version cannot both be set",
38
+ "sql_definition and version cannot both be set"
35
39
  )
36
40
  end
37
41
 
@@ -43,7 +47,7 @@ module Fx
43
47
  sql_definition ||= Fx::Definition.new(
44
48
  name: name,
45
49
  version: version,
46
- type: DEFINTION_TYPE,
50
+ type: DEFINITION_TYPE
47
51
  ).to_sql
48
52
 
49
53
  Fx.database.create_trigger(sql_definition)
@@ -62,7 +66,8 @@ module Fx
62
66
  # @example Drop a trigger, rolling back to version 3 on rollback
63
67
  # drop_trigger(:log_inserts, on: :users, revert_to_version: 3)
64
68
  #
65
- def drop_trigger(name, on:, revert_to_version: nil)
69
+ def drop_trigger(name, options = {})
70
+ on = options.fetch(:on)
66
71
  Fx.database.drop_trigger(name, on: on)
67
72
  end
68
73
 
@@ -95,21 +100,25 @@ module Fx
95
100
  # CREATE TRIGGER uppercase_users_name
96
101
  # BEFORE INSERT ON users
97
102
  # FOR EACH ROW
98
- # EXECUTE PROCEDURE uppercase_users_name();
103
+ # EXECUTE FUNCTION uppercase_users_name();
99
104
  # SQL
100
105
  #
101
- def update_trigger(name, version: nil, on: nil, sql_definition: nil, revert_to_version: nil)
106
+ def update_trigger(name, options = {})
107
+ version = options[:version]
108
+ on = options[:on]
109
+ sql_definition = options[:sql_definition]
110
+
102
111
  if version.nil? && sql_definition.nil?
103
112
  raise(
104
113
  ArgumentError,
105
- "version or sql_definition must be specified",
114
+ "version or sql_definition must be specified"
106
115
  )
107
116
  end
108
117
 
109
118
  if version.present? && sql_definition.present?
110
119
  raise(
111
120
  ArgumentError,
112
- "sql_definition and version cannot both be set",
121
+ "sql_definition and version cannot both be set"
113
122
  )
114
123
  end
115
124
 
@@ -121,13 +130,13 @@ module Fx
121
130
  sql_definition ||= Fx::Definition.new(
122
131
  name: name,
123
132
  version: version,
124
- type: DEFINTION_TYPE,
133
+ type: DEFINITION_TYPE
125
134
  ).to_sql
126
135
 
127
136
  Fx.database.update_trigger(
128
137
  name,
129
138
  on: on,
130
- sql_definition: sql_definition,
139
+ sql_definition: sql_definition
131
140
  )
132
141
  end
133
142
  end
data/lib/fx/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module Fx
2
2
  # @api private
3
- VERSION = "0.6.2"
3
+ VERSION = "0.8.0"
4
4
  end
data/lib/fx.rb CHANGED
@@ -19,17 +19,17 @@ module Fx
19
19
  def self.load
20
20
  ActiveRecord::Migration::CommandRecorder.send(
21
21
  :include,
22
- Fx::CommandRecorder,
22
+ Fx::CommandRecorder
23
23
  )
24
24
 
25
25
  ActiveRecord::SchemaDumper.send(
26
26
  :prepend,
27
- Fx::SchemaDumper,
27
+ Fx::SchemaDumper
28
28
  )
29
29
 
30
30
  ActiveRecord::ConnectionAdapters::AbstractAdapter.send(
31
31
  :include,
32
- Fx::Statements,
32
+ Fx::Statements
33
33
  )
34
34
  end
35
35
 
@@ -29,12 +29,12 @@ module Fx
29
29
  if updating_existing_function?
30
30
  migration_template(
31
31
  "db/migrate/update_function.erb",
32
- "db/migrate/update_function_#{file_name}_to_version_#{version}.rb",
32
+ "db/migrate/update_function_#{file_name}_to_version_#{version}.rb"
33
33
  )
34
34
  else
35
35
  migration_template(
36
36
  "db/migrate/create_function.erb",
37
- "db/migrate/create_function_#{file_name}.rb",
37
+ "db/migrate/create_function_#{file_name}.rb"
38
38
  )
39
39
  end
40
40
  end
@@ -45,9 +45,9 @@ module Fx
45
45
 
46
46
  no_tasks do
47
47
  def previous_version
48
- @_previous_version ||= Dir.entries(function_definition_path).
49
- map { |name| version_regex.match(name).try(:[], "version").to_i }.
50
- max
48
+ @_previous_version ||= Dir.entries(function_definition_path)
49
+ .map { |name| version_regex.match(name).try(:[], "version").to_i }
50
+ .max
51
51
  end
52
52
 
53
53
  def version
@@ -82,7 +82,7 @@ module Fx
82
82
  private
83
83
 
84
84
  def function_definition_path
85
- @_function_definition_path ||= Rails.root.join(*%w(db functions))
85
+ @_function_definition_path ||= Rails.root.join(*%w[db functions])
86
86
  end
87
87
 
88
88
  def version_regex
@@ -42,9 +42,9 @@ module Fx
42
42
 
43
43
  no_tasks do
44
44
  def previous_version
45
- @_previous_version ||= Dir.entries(trigger_definition_path).
46
- map { |name| version_regex.match(name).try(:[], "version").to_i }.
47
- max
45
+ @_previous_version ||= Dir.entries(trigger_definition_path)
46
+ .map { |name| version_regex.match(name).try(:[], "version").to_i }
47
+ .max
48
48
  end
49
49
 
50
50
  def version
@@ -81,7 +81,7 @@ module Fx
81
81
  if name.nil?
82
82
  raise(
83
83
  ArgumentError,
84
- "Either `table_name:NAME` or `on:NAME` must be specified",
84
+ "Either `table_name:NAME` or `on:NAME` must be specified"
85
85
  )
86
86
  end
87
87
 
@@ -107,12 +107,12 @@ module Fx
107
107
  Fx::Definition.new(
108
108
  name: file_name,
109
109
  version: version,
110
- type: "trigger",
110
+ type: "trigger"
111
111
  )
112
112
  end
113
113
 
114
114
  def trigger_definition_path
115
- @_trigger_definition_path ||= Rails.root.join(*["db", "triggers"])
115
+ @_trigger_definition_path ||= Rails.root.join("db", "triggers")
116
116
  end
117
117
 
118
118
  # Skip creating migration file if:
@@ -19,7 +19,7 @@ describe "User manages functions" do
19
19
  successfully "rails generate fx:function test"
20
20
  verify_identical_definitions(
21
21
  "db/functions/test_v01.sql",
22
- "db/functions/test_v02.sql",
22
+ "db/functions/test_v02.sql"
23
23
  )
24
24
  write_function_definition "test_v02", <<-EOS
25
25
  CREATE OR REPLACE FUNCTION test()
@@ -18,7 +18,7 @@ describe "User manages triggers" do
18
18
  CREATE TRIGGER uppercase_users_name
19
19
  BEFORE INSERT ON users
20
20
  FOR EACH ROW
21
- EXECUTE PROCEDURE uppercase_users_name();
21
+ EXECUTE FUNCTION uppercase_users_name();
22
22
  EOS
23
23
  successfully "rake db:migrate"
24
24
 
@@ -36,7 +36,7 @@ describe "User manages triggers" do
36
36
  CREATE TRIGGER uppercase_users_name
37
37
  BEFORE UPDATE ON users
38
38
  FOR EACH ROW
39
- EXECUTE PROCEDURE uppercase_users_name();
39
+ EXECUTE FUNCTION uppercase_users_name();
40
40
  EOS
41
41
  successfully "rake db:migrate"
42
42
  execute <<-EOS
@@ -12,7 +12,9 @@ RSpec.configure do |config|
12
12
  config.before(:suite) do
13
13
  Dir.chdir("spec/dummy") do
14
14
  system <<-CMD
15
- git init 1>/dev/null &&
15
+ git init -b master 1>/dev/null &&
16
+ git config user.email "fx@example.com"
17
+ git config user.name "Fx"
16
18
  git add -A &&
17
19
  git commit --no-gpg-sign --message 'initial' 1>/dev/null
18
20
  CMD
@@ -24,7 +26,7 @@ RSpec.configure do |config|
24
26
  ActiveRecord::Base.connection.disconnect!
25
27
  system <<-CMD
26
28
  echo &&
27
- rake db:environment:set db:drop db:create &&
29
+ rake db:environment:set db:drop db:create 1>/dev/null &&
28
30
  git add -A &&
29
31
  git reset --hard HEAD 1>/dev/null &&
30
32
  rm -rf .git/ 1>/dev/null
data/spec/dummy/Rakefile CHANGED
@@ -1,13 +1,13 @@
1
1
  # Add your own tasks in files placed in lib/tasks ending in .rake,
2
2
  # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
3
 
4
- require File.expand_path('../config/application', __FILE__)
4
+ require File.expand_path("../config/application", __FILE__)
5
5
 
6
6
  Rails.application.load_tasks
7
7
 
8
- unless Rake::Task.task_defined?('db:environment:set')
9
- desc 'dummy task for rails versions where this task does not exist'
10
- task 'db:environment:set' do
8
+ unless Rake::Task.task_defined?("db:environment:set")
9
+ desc "dummy task for rails versions where this task does not exist"
10
+ task "db:environment:set" do
11
11
  # no-op
12
12
  end
13
13
  end
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env ruby
2
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
3
- load Gem.bin_path('bundler', 'bundle')
2
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", __FILE__)
3
+ load Gem.bin_path("bundler", "bundle")
data/spec/dummy/bin/rails CHANGED
@@ -1,4 +1,4 @@
1
1
  #!/usr/bin/env ruby
2
- APP_PATH = File.expand_path('../../config/application', __FILE__)
3
- require_relative '../config/boot'
4
- require 'rails/commands'
2
+ APP_PATH = File.expand_path("../../config/application", __FILE__)
3
+ require_relative "../config/boot"
4
+ require "rails/commands"
data/spec/dummy/bin/rake CHANGED
@@ -1,4 +1,4 @@
1
1
  #!/usr/bin/env ruby
2
- require_relative '../config/boot'
3
- require 'rake'
2
+ require_relative "../config/boot"
3
+ require "rake"
4
4
  Rake.application.run
@@ -11,5 +11,7 @@ module Dummy
11
11
  config.cache_classes = true
12
12
  config.eager_load = false
13
13
  config.active_support.deprecation = :stderr
14
+
15
+ config.active_record.legacy_connection_handling = false
14
16
  end
15
17
  end
@@ -1,5 +1,7 @@
1
1
  development: &default
2
2
  adapter: postgresql
3
+ host: 127.0.0.1
4
+ user: <%= ENV['POSTGRES_USER'] %>
3
5
  database: dummy_development
4
6
  encoding: unicode
5
7
  pool: 5
data/spec/dummy/config.ru CHANGED
@@ -1,4 +1,4 @@
1
1
  # This file is used by Rack-based servers to start the application.
2
2
 
3
- require ::File.expand_path('../config/environment', __FILE__)
3
+ require ::File.expand_path("../config/environment", __FILE__)
4
4
  run Rails.application
@@ -51,7 +51,7 @@ describe "Function migrations", :db do
51
51
  with_function_definition(
52
52
  name: :test,
53
53
  version: 2,
54
- sql_definition: sql_definition,
54
+ sql_definition: sql_definition
55
55
  ) do
56
56
  migration = Class.new(migration_class) do
57
57
  def change