scenic 1.5.1 → 1.5.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4e48c4898ced79e149309b431569eff692ef95ff075a57ad0a02f2b80b59a262
4
- data.tar.gz: 7de8b684edffe599452d125aaed7f32111bfc4f99ef4b7e475ca0b2882c7c137
3
+ metadata.gz: 4da3d3cd88cae9dfaee68959a899fddbe617a1c711fa03ec36fc40cefba90315
4
+ data.tar.gz: 74b8894aee096545789a61bbd6d2dcbc276949d7f6d5fe62b06128a9751df49f
5
5
  SHA512:
6
- metadata.gz: 5a3f7c1e233cd63be18a94ac39c44f36baff1f1c1ba6cdcc71aa31063c52c2220b3321455a2e904366c157ed419d0a20454dccfdd22e66e42508584865f0aabe
7
- data.tar.gz: 0ee497506b13cdf2b64c49aea4b18fc351cf620b902acb962a8c9b5281c319b37b473f56ecfbcb873f4561e521780a54c6c6269d43ac841cfc4a3508213a61af
6
+ metadata.gz: 886b10ebffb2a4a612bdb68ca519c38f0e5114d14850cfe7f3d4e985209f69530c18249bab750f4fe6b9b8fee98adc4675cb08f14cd56e1faf2693f1910d38fb
7
+ data.tar.gz: faa4bfbf6812f81ad9efc27a70e79ccb66e1679db69824a551f7494c11482361660aa9780900aa45ad3609ab37074ac83aea85a5cf62dcc4808772259a2a37cb
@@ -0,0 +1,71 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: main
6
+ pull_request:
7
+ branches: "*"
8
+
9
+ jobs:
10
+ build:
11
+ name: Ruby ${{ matrix.ruby }}, Rails ${{ matrix.rails }}
12
+
13
+ strategy:
14
+ fail-fast: false
15
+ matrix:
16
+ ruby: ["2.7", "3.0"]
17
+ rails: ["6.0", "6.1", "master"]
18
+ continue-on-error: [false]
19
+
20
+ runs-on: ubuntu-latest
21
+
22
+ services:
23
+ postgres:
24
+ image: postgres
25
+ env:
26
+ POSTGRES_USER: "postgres"
27
+ POSTGRES_PASSWORD: "postgres"
28
+ ports:
29
+ - 5432:5432
30
+ options: >-
31
+ --health-cmd pg_isready
32
+ --health-interval 10s
33
+ --health-timeout 5s
34
+ --health-retries 5
35
+
36
+ env:
37
+ RAILS_VERSION: ${{ matrix.rails }}
38
+ POSTGRES_USER: "postgres"
39
+ POSTGRES_PASSWORD: "postgres"
40
+
41
+ steps:
42
+ - name: Checkout
43
+ uses: actions/checkout@v2
44
+
45
+ - name: Install Ruby ${{ matrix.ruby }}
46
+ uses: ruby/setup-ruby@v1.61.1
47
+ with:
48
+ ruby-version: ${{ matrix.ruby }}
49
+
50
+ - name: Install dependent libraries
51
+ run: sudo apt-get install libpq-dev
52
+
53
+ - name: Generate lockfile
54
+ run: bundle lock
55
+
56
+ - name: Cache dependencies
57
+ uses: actions/cache@v1
58
+ with:
59
+ path: vendor/bundle
60
+ key: bundle-${{ hashFiles('Gemfile.lock') }}
61
+
62
+ - name: Set up Scenic
63
+ run: bin/setup
64
+
65
+ - name: Run fast tests
66
+ run: bundle exec rake spec
67
+ continue-on-error: ${{ matrix.continue-on-error }}
68
+
69
+ - name: Run acceptance tests
70
+ run: bundle exec rake spec:acceptance
71
+ continue-on-error: ${{ matrix.continue-on-error }}
data/.gitignore CHANGED
@@ -17,3 +17,4 @@ test/version_tmp
17
17
  tmp
18
18
  gemfiles/*.lock
19
19
  .DS_Store
20
+ .ruby-version
@@ -1,9 +1,55 @@
1
- # News
1
+ # Changelog
2
2
 
3
3
  The noteworthy changes for each Scenic version are included here. For a complete
4
- changelog, see the [CHANGELOG] for each version via the version links.
4
+ changelog, see the [commits] for each version via the version links.
5
5
 
6
- [CHANGELOG]: https://github.com/scenic-views/scenic/commits/master
6
+ [commits]: https://github.com/scenic-views/scenic/commits/master
7
+
8
+ ## [1.5.5] - December 15, 2021
9
+
10
+ ### Fixed
11
+
12
+ - Fixed an issue reverting migrations under Ruby 3
13
+ - Fixed an issue in index reapplication where sometimes `say` was undefined
14
+
15
+ [1.5.5]: https://github.com/scenic-views/scenic/compare/v1.5.4...v1.5.5
16
+
17
+ ## [1.5.4] - September 16, 2020
18
+
19
+ [1.5.4]: https://github.com/scenic-views/scenic/compare/v1.5.3...v1.5.4
20
+
21
+ ### Fixed
22
+
23
+ - Added missing changelog for v1.5.3.
24
+
25
+ ## [1.5.3] - September 15, 2020
26
+
27
+ [1.5.3]: https://github.com/scenic-views/scenic/compare/v1.5.2...v1.5.3
28
+
29
+ ### Fixed
30
+
31
+ - `scenic-oracle_enhanced_adapter` has been pulled from rubygems.
32
+ `scenic-oracle_adapter` is a current, maintained alternative.
33
+ - Updated code snippets - since Rails 5.0, all models inherit from
34
+ ApplicationRecord (#302)
35
+ - Update Caleb's last name
36
+
37
+ ### Added
38
+
39
+ - Add Security Policy
40
+
41
+ ## [1.5.2] - February 6, 2020
42
+
43
+ ### Fixed
44
+
45
+ - The schema statement `create_view` is now reversible when passed a `version`
46
+ argument.
47
+ - Calling `refresh_materialized_view` with both `concurrently` and `cascade` set
48
+ to `true` now correctly cascades the concurrent refresh to dependent views.
49
+ - File generation and lookup now operates correctly for schema-qualified names
50
+ like `warehouse.archived_posts`.
51
+
52
+ [1.5.2]: https://github.com/scenic-views/scenic/compare/v1.5.1...v1.5.2
7
53
 
8
54
  ## [1.5.1] - February 10, 2019
9
55
 
data/CONTRIBUTING.md CHANGED
@@ -10,10 +10,12 @@ agree to abide by our [code of conduct].
10
10
  1. Fork the repository.
11
11
  2. Run `bin/setup`, which will install dependencies and create the dummy
12
12
  application database.
13
- 3. Run `bin/appraisal rake` to verify that the tests pass against all
14
- supported versions of Rails.
13
+ 3. Run `rake` to verify that the tests pass against the version of Rails you are
14
+ running locally.
15
15
  4. Make your change with new passing tests, following existing style.
16
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.
17
19
 
18
20
  [good commit message]: http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html
19
21
 
data/Gemfile CHANGED
@@ -2,3 +2,15 @@ source "https://rubygems.org"
2
2
 
3
3
  # Specify your gem's dependencies in scenic.gemspec
4
4
  gemspec
5
+
6
+ rails_version = ENV.fetch("RAILS_VERSION", "6.1")
7
+
8
+ if rails_version == "master"
9
+ rails_constraint = { github: "rails/rails" }
10
+ else
11
+ rails_constraint = "~> #{rails_version}.0"
12
+ end
13
+
14
+ gem "rails", rails_constraint
15
+ gem "sprockets", "< 4.0.0"
16
+ gem "pg", "~> 1.1"
data/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2014-2016 Derek Prior, Caleb Thompson, and thoughtbot.
1
+ Copyright (c) 2014-2020 Derek Prior, Caleb Hearth, and thoughtbot.
2
2
 
3
3
  MIT License
4
4
 
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  ![Scenic Landscape](https://user-images.githubusercontent.com/152152/49344534-a8817480-f646-11e8-8431-3d95d349c070.png)
4
4
 
5
- [![Build Status](https://travis-ci.org/scenic-views/scenic.svg?branch=master)](https://travis-ci.org/scenic-views/scenic)
5
+ [![Build Status](https://github.com/scenic-views/scenic/actions/workflows/ci.yml/badge.svg)](https://github.com/scenic-views/scenic/actions/workflows/ci.yml)
6
6
  [![Documentation Quality](http://inch-ci.org/github/scenic-views/scenic.svg?branch=master)](http://inch-ci.org/github/scenic-views/scenic)
7
7
  [![Reviewed by Hound](https://img.shields.io/badge/Reviewed_by-Hound-8E64B0.svg)](https://houndci.com)
8
8
 
@@ -94,7 +94,7 @@ when some of those views may be materialized and take a long time to recreate.
94
94
 
95
95
  You can use `replace_view` to generate a CREATE OR REPLACE VIEW SQL statement.
96
96
 
97
- See postgresql documentation on how this works:
97
+ See Postgres documentation on how this works:
98
98
  http://www.postgresql.org/docs/current/static/sql-createview.html
99
99
 
100
100
  To start replacing a view run the generator like for a regular change:
@@ -135,7 +135,7 @@ ActiveRecord or ARel queries. As far as ActiveRecord is concerned, a view is
135
135
  no different than a table.
136
136
 
137
137
  ```ruby
138
- class SearchResult < ActiveRecord::Base
138
+ class SearchResult < ApplicationRecord
139
139
  belongs_to :searchable, polymorphic: true
140
140
 
141
141
  # this isn't strictly necessary, but it will prevent
@@ -218,7 +218,7 @@ You can get around these issues by setting the primary key column on your Rails
218
218
  model like so:
219
219
 
220
220
  ```ruby
221
- class People < ActiveRecord::Base
221
+ class People < ApplicationRecord
222
222
  self.primary_key = :my_unique_identifier_field
223
223
  end
224
224
  ```
@@ -255,12 +255,15 @@ meet your needs:
255
255
  * [scenic_sqlite_adapter](https://github.com/pdebelak/scenic_sqlite_adapter)
256
256
  * [scenic-mysql_adapter](https://github.com/EmpaticoOrg/scenic-mysql_adapter)
257
257
  * [scenic-sqlserver-adapter](https://github.com/ClickMechanic/scenic_sqlserver_adapter)
258
- * [scenic-oracle_enhanced_adapter](https://github.com/PMACS/scenic_oracle_enhanced_adapter)
258
+ * [scenic-oracle_adapter](https://github.com/cdinger/scenic-oracle_adapter)
259
+
260
+ Please note that the maintainers of Scenic make no assertions about the
261
+ quality or security of the above adapters.
259
262
 
260
263
  ## About
261
264
 
262
- Scenic is maintained by [Derek Prior], [Caleb Thompson], and you, our
265
+ Scenic is maintained by [Derek Prior], [Caleb Hearth], and you, our
263
266
  contributors.
264
267
 
265
268
  [Derek Prior]: http://prioritized.net
266
- [Caleb Thompson]: http://calebthompson.io
269
+ [Caleb Hearth]: http://calebhearth.com
data/SECURITY.md ADDED
@@ -0,0 +1,14 @@
1
+ # Security Policy
2
+
3
+ ## Supported Versions
4
+
5
+ Scenic maintainenance is a volunteer effort. We will do our best to fix
6
+ forward but do not offer backported fixes. As such, the only "supported" version of Scenic is whichever was most recently released.
7
+
8
+ ## Reporting a Vulnerability
9
+
10
+ Please report any discovered security vulnerabilities to Scenic's primary
11
+ volunteer maintainers, derekprior@gmail.com and caleb@calebhearth.com.
12
+
13
+ We will respond as soon as possible with any follow-up questions or details
14
+ on how we plan to handle the issue.
data/bin/setup CHANGED
@@ -2,12 +2,17 @@
2
2
 
3
3
  set -e
4
4
 
5
+ # CI-specific setup
6
+ if [ -n "$GITHUB_ACTIONS" ]; then
7
+ bundle config path vendor/bundle
8
+ bundle config jobs 4
9
+ bundle config retry 3
10
+ git config --global user.name 'GitHub Actions'
11
+ git config --global user.email 'github-actions@example.com'
12
+ fi
13
+
5
14
  gem install bundler --conservative
6
15
  bundle check || bundle install
7
16
 
8
- if [ -z "$CI" ]; then
9
- bundle exec appraisal install
10
- fi
11
-
12
17
  bundle exec rake dummy:db:drop
13
18
  bundle exec rake dummy:db:create
@@ -73,6 +73,12 @@ module Scenic
73
73
 
74
74
  private
75
75
 
76
+ alias singular_name file_name
77
+
78
+ def file_name
79
+ super.tr(".", "_")
80
+ end
81
+
76
82
  def views_directory_path
77
83
  @views_directory_path ||= Rails.root.join("db", "views")
78
84
  end
@@ -93,10 +99,6 @@ module Scenic
93
99
  Scenic::Definition.new(plural_file_name, previous_version)
94
100
  end
95
101
 
96
- def plural_file_name
97
- @plural_file_name ||= file_name.pluralize.tr(".", "_")
98
- end
99
-
100
102
  def destroying?
101
103
  behavior == :revoke
102
104
  end
@@ -13,7 +13,7 @@ module Scenic
13
13
  # @param connection [Connection] The connection to execute SQL against.
14
14
  # @param speaker [#say] (ActiveRecord::Migration) The object used for
15
15
  # logging the results of reapplying indexes.
16
- def initialize(connection:, speaker: ActiveRecord::Migration)
16
+ def initialize(connection:, speaker: ActiveRecord::Migration.new)
17
17
  @connection = connection
18
18
  @speaker = speaker
19
19
  end
@@ -2,25 +2,29 @@ module Scenic
2
2
  module Adapters
3
3
  class Postgres
4
4
  class RefreshDependencies
5
- def self.call(name, adapter, connection)
6
- new(name, adapter, connection).call
5
+ def self.call(name, adapter, connection, concurrently: false)
6
+ new(name, adapter, connection, concurrently: concurrently).call
7
7
  end
8
8
 
9
- def initialize(name, adapter, connection)
9
+ def initialize(name, adapter, connection, concurrently:)
10
10
  @name = name
11
11
  @adapter = adapter
12
12
  @connection = connection
13
+ @concurrently = concurrently
13
14
  end
14
15
 
15
16
  def call
16
17
  dependencies.each do |dependency|
17
- adapter.refresh_materialized_view(dependency)
18
+ adapter.refresh_materialized_view(
19
+ dependency,
20
+ concurrently: concurrently,
21
+ )
18
22
  end
19
23
  end
20
24
 
21
25
  private
22
26
 
23
- attr_reader :name, :adapter, :connection
27
+ attr_reader :name, :adapter, :connection, :concurrently
24
28
 
25
29
  class DependencyParser
26
30
  def initialize(raw_dependencies, view_to_refresh)
@@ -209,8 +209,9 @@ module Scenic
209
209
  # @return [void]
210
210
  def refresh_materialized_view(name, concurrently: false, cascade: false)
211
211
  raise_unless_materialized_views_supported
212
+
212
213
  if cascade
213
- refresh_dependencies_for(name)
214
+ refresh_dependencies_for(name, concurrently: concurrently)
214
215
  end
215
216
 
216
217
  if concurrently
@@ -242,11 +243,12 @@ module Scenic
242
243
  end
243
244
  end
244
245
 
245
- def refresh_dependencies_for(name)
246
+ def refresh_dependencies_for(name, concurrently: false)
246
247
  Scenic::Adapters::Postgres::RefreshDependencies.call(
247
248
  name,
248
249
  self,
249
250
  connection,
251
+ concurrently: concurrently,
250
252
  )
251
253
  end
252
254
  end
@@ -22,8 +22,12 @@ module Scenic
22
22
  StatementArguments.new([view, options_for_revert])
23
23
  end
24
24
 
25
+ def remove_version
26
+ StatementArguments.new([view, options_without_version])
27
+ end
28
+
25
29
  def to_a
26
- @args.to_a
30
+ @args.to_a.dup.delete_if(&:empty?)
27
31
  end
28
32
 
29
33
  private
@@ -32,11 +36,25 @@ module Scenic
32
36
  @options ||= @args[1] || {}
33
37
  end
34
38
 
39
+ def keyword_hash(hash)
40
+ if Hash.respond_to? :ruby2_keywords_hash
41
+ Hash.ruby2_keywords_hash(hash)
42
+ else
43
+ hash
44
+ end
45
+ end
46
+
35
47
  def options_for_revert
36
- options.clone.tap do |revert_options|
48
+ opts = options.clone.tap do |revert_options|
37
49
  revert_options[:version] = revert_to_version
38
50
  revert_options.delete(:revert_to_version)
39
51
  end
52
+
53
+ keyword_hash(opts)
54
+ end
55
+
56
+ def options_without_version
57
+ keyword_hash(options.except(:version))
40
58
  end
41
59
  end
42
60
  end
@@ -6,21 +6,26 @@ module Scenic
6
6
  def create_view(*args)
7
7
  record(:create_view, args)
8
8
  end
9
+ ruby2_keywords :create_view if respond_to?(:ruby2_keywords, true)
9
10
 
10
11
  def drop_view(*args)
11
12
  record(:drop_view, args)
12
13
  end
14
+ ruby2_keywords :drop_view if respond_to?(:ruby2_keywords, true)
13
15
 
14
16
  def update_view(*args)
15
17
  record(:update_view, args)
16
18
  end
19
+ ruby2_keywords :update_view if respond_to?(:ruby2_keywords, true)
17
20
 
18
21
  def replace_view(*args)
19
22
  record(:replace_view, args)
20
23
  end
24
+ ruby2_keywords :replace_view if respond_to?(:ruby2_keywords, true)
21
25
 
22
26
  def invert_create_view(args)
23
- [:drop_view, args]
27
+ drop_view_args = StatementArguments.new(args).remove_version.to_a
28
+ [:drop_view, drop_view_args]
24
29
  end
25
30
 
26
31
  def invert_drop_view(args)
@@ -2,7 +2,7 @@ module Scenic
2
2
  class Configuration
3
3
  # The Scenic database adapter instance to use when executing SQL.
4
4
  #
5
- # Defualts to an instance of {Adapters::Postgres}
5
+ # Defaults to an instance of {Adapters::Postgres}
6
6
  # @return Scenic adapter
7
7
  attr_accessor :database
8
8
 
@@ -29,7 +29,7 @@ module Scenic
29
29
  private
30
30
 
31
31
  def filename
32
- "#{@name}_v#{version}.sql"
32
+ "#{@name.to_s.tr('.', '_')}_v#{version}.sql"
33
33
  end
34
34
  end
35
35
  end
@@ -1,3 +1,3 @@
1
1
  module Scenic
2
- VERSION = "1.5.1".freeze
2
+ VERSION = "1.5.5".freeze
3
3
  end
data/scenic.gemspec CHANGED
@@ -5,8 +5,8 @@ require "scenic/version"
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "scenic"
7
7
  spec.version = Scenic::VERSION
8
- spec.authors = ["Derek Prior", "Caleb Thompson"]
9
- spec.email = ["derekprior@gmail.com", "caleb@calebthompson.io"]
8
+ spec.authors = ["Derek Prior", "Caleb Hearth"]
9
+ spec.email = ["derekprior@gmail.com", "caleb@calebhearth.com"]
10
10
  spec.summary = "Support for database views in Rails migrations"
11
11
  spec.description = <<-DESCRIPTION
12
12
  Adds methods to ActiveRecord::Migration to create and manage database views
@@ -19,7 +19,6 @@ Gem::Specification.new do |spec|
19
19
  spec.test_files = spec.files.grep(%r{^spec/})
20
20
  spec.require_paths = ["lib"]
21
21
 
22
- spec.add_development_dependency "appraisal"
23
22
  spec.add_development_dependency "bundler", ">= 1.5"
24
23
  spec.add_development_dependency "database_cleaner"
25
24
  spec.add_development_dependency "rake"
@@ -2,7 +2,12 @@ development: &default
2
2
  adapter: postgresql
3
3
  database: dummy_development
4
4
  encoding: unicode
5
+ host: localhost
5
6
  pool: 5
7
+ <% if ENV.fetch("GITHUB_ACTIONS", false) %>
8
+ username: <%= ENV.fetch("POSTGRES_USER") %>
9
+ password: <%= ENV.fetch("POSTGRES_PASSWORD") %>
10
+ <% end %>
6
11
 
7
12
  test:
8
13
  <<: *default
@@ -38,14 +38,20 @@ describe Scenic::Generators::ViewGenerator, :generator do
38
38
  end
39
39
 
40
40
  context "for views created in a schema other than 'public'" do
41
- it "creates view definition and migration files" do
42
- migration = file("db/migrate/create_non_public_searches.rb")
41
+ it "creates a view definition" do
43
42
  view_definition = file("db/views/non_public_searches_v01.sql")
44
43
 
45
44
  run_generator ["non_public.search"]
46
45
 
47
- expect(migration).to be_a_migration
48
46
  expect(view_definition).to exist
49
47
  end
48
+
49
+ it "creates a migration file" do
50
+ run_generator ["non_public.search"]
51
+
52
+ migration = migration_file("db/migrate/create_non_public_searches.rb")
53
+ expect(migration).to contain(/class CreateNonPublicSearches/)
54
+ expect(migration).to contain(/create_view "non_public.searches"/)
55
+ end
50
56
  end
51
57
  end
@@ -33,19 +33,24 @@ module Scenic
33
33
  )
34
34
 
35
35
  expect(adapter).to receive(:refresh_materialized_view)
36
- .with("public.first").ordered
36
+ .with("public.first", concurrently: true).ordered
37
37
  expect(adapter).to receive(:refresh_materialized_view)
38
- .with("public.second").ordered
38
+ .with("public.second", concurrently: true).ordered
39
39
  expect(adapter).to receive(:refresh_materialized_view)
40
- .with("public.third").ordered
40
+ .with("public.third", concurrently: true).ordered
41
41
  expect(adapter).to receive(:refresh_materialized_view)
42
- .with("public.fourth_1").ordered
42
+ .with("public.fourth_1", concurrently: true).ordered
43
43
  expect(adapter).to receive(:refresh_materialized_view)
44
- .with("public.x_fourth").ordered
44
+ .with("public.x_fourth", concurrently: true).ordered
45
45
  end
46
46
 
47
47
  it "refreshes in the right order when called without namespace" do
48
- described_class.call(:fourth, adapter, ActiveRecord::Base.connection)
48
+ described_class.call(
49
+ :fourth,
50
+ adapter,
51
+ ActiveRecord::Base.connection,
52
+ concurrently: true,
53
+ )
49
54
  end
50
55
 
51
56
  it "refreshes in the right order when called with namespace" do
@@ -53,6 +58,7 @@ module Scenic
53
58
  "public.fourth",
54
59
  adapter,
55
60
  ActiveRecord::Base.connection,
61
+ concurrently: true,
56
62
  )
57
63
  end
58
64
  end
@@ -119,8 +119,14 @@ module Scenic
119
119
  connectable = double("Connectable", connection: connection)
120
120
  adapter = Postgres.new(connectable)
121
121
  expect(Scenic::Adapters::Postgres::RefreshDependencies)
122
- .to receive(:call).with(:tests, adapter, connection)
123
- adapter.refresh_materialized_view(:tests, cascade: true)
122
+ .to receive(:call)
123
+ .with(:tests, adapter, connection, concurrently: true)
124
+
125
+ adapter.refresh_materialized_view(
126
+ :tests,
127
+ cascade: true,
128
+ concurrently: true,
129
+ )
124
130
  end
125
131
 
126
132
  context "refreshing concurrently" do
@@ -8,11 +8,25 @@ describe Scenic::CommandRecorder do
8
8
  expect(recorder.commands).to eq [[:create_view, [:greetings], nil]]
9
9
  end
10
10
 
11
- it "reverts to drop_view" do
11
+ it "reverts to drop_view when not passed a version" do
12
12
  recorder.revert { recorder.create_view :greetings }
13
13
 
14
14
  expect(recorder.commands).to eq [[:drop_view, [:greetings]]]
15
15
  end
16
+
17
+ it "reverts to drop_view when passed a version" do
18
+ recorder.revert { recorder.create_view :greetings, version: 2 }
19
+
20
+ expect(recorder.commands).to eq [[:drop_view, [:greetings]]]
21
+ end
22
+
23
+ it "reverts materialized views appropriately" do
24
+ recorder.revert { recorder.create_view :greetings, materialized: true }
25
+
26
+ expect(recorder.commands).to eq [
27
+ [:drop_view, [:greetings, materialized: true]],
28
+ ]
29
+ end
16
30
  end
17
31
 
18
32
  describe "#drop_view" do
@@ -29,6 +29,12 @@ module Scenic
29
29
 
30
30
  expect(definition.path).to eq expected
31
31
  end
32
+
33
+ it "handles schema qualified view names" do
34
+ definition = Definition.new("non_public.searches", 1)
35
+
36
+ expect(definition.path).to eq "db/views/non_public_searches_v01.sql"
37
+ end
32
38
  end
33
39
 
34
40
  describe "full_path" do
@@ -3,7 +3,7 @@ require "spec_helper"
3
3
  module Scenic
4
4
  describe Scenic::Statements do
5
5
  before do
6
- adapter = instance_double("Scenic::Adapaters::Postgres").as_null_object
6
+ adapter = instance_double("Scenic::Adapters::Postgres").as_null_object
7
7
  allow(Scenic).to receive(:database).and_return(adapter)
8
8
  end
9
9
 
data/spec/spec_helper.rb CHANGED
@@ -11,6 +11,8 @@ RSpec.configure do |config|
11
11
  DatabaseCleaner.strategy = :transaction
12
12
 
13
13
  config.around(:each, db: true) do |example|
14
+ ActiveRecord::SchemaMigration.create_table
15
+
14
16
  DatabaseCleaner.start
15
17
  example.run
16
18
  DatabaseCleaner.clean
metadata CHANGED
@@ -1,30 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scenic
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.1
4
+ version: 1.5.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Derek Prior
8
- - Caleb Thompson
9
- autorequire:
8
+ - Caleb Hearth
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2019-02-11 00:00:00.000000000 Z
12
+ date: 2021-12-15 00:00:00.000000000 Z
13
13
  dependencies:
14
- - !ruby/object:Gem::Dependency
15
- name: appraisal
16
- requirement: !ruby/object:Gem::Requirement
17
- requirements:
18
- - - ">="
19
- - !ruby/object:Gem::Version
20
- version: '0'
21
- type: :development
22
- prerelease: false
23
- version_requirements: !ruby/object:Gem::Requirement
24
- requirements:
25
- - - ">="
26
- - !ruby/object:Gem::Version
27
- version: '0'
28
14
  - !ruby/object:Gem::Dependency
29
15
  name: bundler
30
16
  requirement: !ruby/object:Gem::Requirement
@@ -184,34 +170,28 @@ description: |2
184
170
  in Rails
185
171
  email:
186
172
  - derekprior@gmail.com
187
- - caleb@calebthompson.io
173
+ - caleb@calebhearth.com
188
174
  executables: []
189
175
  extensions: []
190
176
  extra_rdoc_files: []
191
177
  files:
178
+ - ".github/workflows/ci.yml"
192
179
  - ".gitignore"
193
180
  - ".hound.yml"
194
181
  - ".rubocop.yml"
195
- - ".travis.yml"
196
182
  - ".yardopts"
197
- - Appraisals
183
+ - CHANGELOG.md
198
184
  - CODE_OF_CONDUCT.md
199
185
  - CONTRIBUTING.md
200
186
  - Gemfile
201
187
  - LICENSE.txt
202
- - NEWS.md
203
188
  - README.md
204
189
  - Rakefile
205
- - bin/appraisal
190
+ - SECURITY.md
206
191
  - bin/rake
207
192
  - bin/rspec
208
193
  - bin/setup
209
194
  - bin/yard
210
- - gemfiles/rails42.gemfile
211
- - gemfiles/rails50.gemfile
212
- - gemfiles/rails51.gemfile
213
- - gemfiles/rails52.gemfile
214
- - gemfiles/rails_edge.gemfile
215
195
  - lib/generators/scenic/generators.rb
216
196
  - lib/generators/scenic/materializable.rb
217
197
  - lib/generators/scenic/model/USAGE
@@ -275,7 +255,7 @@ homepage: https://github.com/scenic-views/scenic
275
255
  licenses:
276
256
  - MIT
277
257
  metadata: {}
278
- post_install_message:
258
+ post_install_message:
279
259
  rdoc_options: []
280
260
  require_paths:
281
261
  - lib
@@ -290,8 +270,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
290
270
  - !ruby/object:Gem::Version
291
271
  version: '0'
292
272
  requirements: []
293
- rubygems_version: 3.0.1
294
- signing_key:
273
+ rubygems_version: 3.2.32
274
+ signing_key:
295
275
  specification_version: 4
296
276
  summary: Support for database views in Rails migrations
297
277
  test_files:
data/.travis.yml DELETED
@@ -1,38 +0,0 @@
1
- addons:
2
- postgresql: "9.4"
3
- before_install:
4
- - "echo '--colour' > ~/.rspec"
5
- - "echo 'gem: --no-document' > ~/.gemrc"
6
- - git config --global user.name 'Travis CI'
7
- - git config --global user.email 'travis-ci@example.com'
8
- - gem update --system
9
- branches:
10
- only:
11
- - master
12
- install:
13
- - travis_retry bin/setup
14
- language:
15
- - ruby
16
- notifications:
17
- email:
18
- - false
19
- sudo: false
20
- rvm:
21
- - 2.6.1
22
- - 2.5.3
23
- - 2.4.5
24
- - 2.3.8
25
- gemfile:
26
- - gemfiles/rails42.gemfile
27
- - gemfiles/rails50.gemfile
28
- - gemfiles/rails51.gemfile
29
- - gemfiles/rails52.gemfile
30
- - gemfiles/rails_edge.gemfile
31
- matrix:
32
- allow_failures:
33
- - gemfile: gemfiles/rails_edge.gemfile
34
- exclude:
35
- - rvm: 2.3.8
36
- gemfile: gemfiles/rails_edge.gemfile
37
- - rvm: 2.4.5
38
- gemfile: gemfiles/rails_edge.gemfile
data/Appraisals DELETED
@@ -1,26 +0,0 @@
1
- appraise "rails42" do
2
- gem "activerecord", "~> 4.2.0"
3
- gem "railties", "~> 4.2.0"
4
- end
5
-
6
- appraise "rails50" do
7
- gem "activerecord", "~> 5.0.0"
8
- gem "railties", "~> 5.0.0"
9
- end
10
-
11
- appraise "rails51" do
12
- gem "activerecord", "~> 5.1.0"
13
- gem "railties", "~> 5.1.0"
14
- end
15
-
16
- appraise "rails52" do
17
- gem "activerecord", "~> 5.2.0"
18
- gem "railties", "~> 5.2.0"
19
- end
20
-
21
- if RUBY_VERSION >= "2.5.0"
22
- appraise "rails-edge" do
23
- gem "rails", git: "https://github.com/rails/rails"
24
- gem "arel", git: "https://github.com/rails/arel"
25
- end
26
- end
data/bin/appraisal DELETED
@@ -1,16 +0,0 @@
1
- #!/usr/bin/env ruby
2
- #
3
- # This file was generated by Bundler.
4
- #
5
- # The application 'appraisal' is installed as part of a gem, and
6
- # this file is here to facilitate running it.
7
- #
8
-
9
- require 'pathname'
10
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
- Pathname.new(__FILE__).realpath)
12
-
13
- require 'rubygems'
14
- require 'bundler/setup'
15
-
16
- load Gem.bin_path('appraisal', 'appraisal')
@@ -1,8 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "activerecord", "~> 4.2.0"
6
- gem "railties", "~> 4.2.0"
7
-
8
- gemspec path: "../"
@@ -1,8 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "activerecord", "~> 5.0.0"
6
- gem "railties", "~> 5.0.0"
7
-
8
- gemspec path: "../"
@@ -1,8 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "activerecord", "~> 5.1.0"
6
- gem "railties", "~> 5.1.0"
7
-
8
- gemspec path: "../"
@@ -1,8 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "activerecord", "~> 5.2.0"
6
- gem "railties", "~> 5.2.0"
7
-
8
- gemspec path: "../"
@@ -1,8 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "rails", git: "https://github.com/rails/rails"
6
- gem "arel", git: "https://github.com/rails/arel"
7
-
8
- gemspec path: "../"