refile-postgres 1.2.0 → 1.2.1

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
  SHA1:
3
- metadata.gz: dcbf870ad7c94880999b64a72c48264070344114
4
- data.tar.gz: e9015db34ee5fcc3e39963894d9b1fe2c3bc4827
3
+ metadata.gz: 3750ff6ae5e70ecd23b619f28d6a3c9a12150d09
4
+ data.tar.gz: ccaf3d9739e3b80e7c4ebbf76de3b124c33064ae
5
5
  SHA512:
6
- metadata.gz: 8164bf9a9cd8dc25d88c809490ba28ed3dd9b1b997da8a892a9a30022c39cfe0dba14ecbc574f2744392b5950a0f9b095308d10cd4e163e102f62d0c855522a7
7
- data.tar.gz: 0a84dff267e690011f4a219042b6e674409fa1249555671ca248e8dd52c8f073afc0bdd2e92afc1111d711266cf828619386316088cf4188550b35ec1fc2a7dc
6
+ metadata.gz: 2983f0299c9d796c8ba4a1b1831612b4bf2633ee410c7897aa4ad3da5b4f9b6acb1276fc576b8e7dd819504ab4b383fe00de5264b90b5df7339cf0398f0fc173
7
+ data.tar.gz: 16d74a9439671ae6ffd5a3970dad6b987619d56c8941bd8586673344d6ef44c33410cef0415aa5754b53014cf24d8d9b66f28dc59deb0be93589a2f20dae1e21
data/README.md CHANGED
@@ -4,6 +4,7 @@ A PostgreSQL backend for [Refile](https://github.com/elabs/refile).
4
4
 
5
5
  [![Build Status](https://travis-ci.org/krists/refile-postgres.svg?branch=master)](https://travis-ci.org/krists/refile-postgres)
6
6
  [![Code Climate](https://codeclimate.com/github/krists/refile-postgres/badges/gpa.svg)](https://codeclimate.com/github/krists/refile-postgres)
7
+ [![Test Coverage](https://codeclimate.com/github/krists/refile-postgres/badges/coverage.svg)](https://codeclimate.com/github/krists/refile-postgres/coverage)
7
8
 
8
9
  ## Why?
9
10
 
@@ -23,7 +23,7 @@ module Refile
23
23
  unless @registry_table_validated
24
24
  with_connection do |connection|
25
25
  connection.exec_params("SELECT * FROM pg_catalog.pg_tables WHERE tablename = $1::varchar;", [@registry_table]) do |result|
26
- if result.count != 1
26
+ if result.count == 0
27
27
  raise RegistryTableDoesNotExistError.new(%{Please create a table "#{@registry_table}" where backend could store list of attachments})
28
28
  end
29
29
  end
@@ -1,5 +1,5 @@
1
1
  module Refile
2
2
  module Postgres
3
- VERSION = "1.2.0"
3
+ VERSION = "1.2.1"
4
4
  end
5
5
  end
@@ -1,7 +1,7 @@
1
1
  require "spec_helper"
2
2
 
3
3
  describe Refile::Postgres::Backend do
4
- let(:connection) { PG.connect(dbname: 'refile_test') }
4
+ let(:connection) { test_connection }
5
5
  let(:backend) { Refile::Postgres::Backend.new(connection_or_proc, max_size: 100) }
6
6
 
7
7
  context "Connection tests" do
@@ -21,6 +21,7 @@ describe Refile::Postgres::Backend do
21
21
  }.to raise_error(ArgumentError, "When initializing new Refile::Postgres::Backend first argument should be an instance of PG::Connection or a lambda/proc that yields it.")
22
22
  end
23
23
  end
24
+
24
25
  context "when lambda does yield a PG::Connection" do
25
26
  let(:connection_or_proc) { lambda { |&blk| blk.call(connection) } }
26
27
  it "is usable in queries" do
@@ -30,6 +31,39 @@ describe Refile::Postgres::Backend do
30
31
  end
31
32
  end
32
33
 
34
+ describe "#registry_table" do
35
+ context "when no registry table is present" do
36
+ it "raises an exception" do
37
+ drop_registry_table
38
+ expect {
39
+ Refile::Postgres::Backend.new(test_connection, max_size: 100).registry_table
40
+ }.to raise_error Refile::Postgres::Backend::RegistryTableDoesNotExistError
41
+ end
42
+ end
43
+
44
+ context "when registry tables exist in multiple schemas" do
45
+ before do
46
+ test_connection.exec %{
47
+ CREATE SCHEMA other_schema;
48
+ CREATE TABLE IF NOT EXISTS other_schema.#{Refile::Postgres::Backend::DEFAULT_REGISTRY_TABLE}
49
+ ( id serial NOT NULL );
50
+ }
51
+ end
52
+
53
+ after do
54
+ test_connection.exec %{
55
+ DROP SCHEMA other_schema CASCADE;
56
+ }
57
+ end
58
+
59
+ it "does not raise an exception" do
60
+ expect {
61
+ Refile::Postgres::Backend.new(test_connection, max_size: 100).registry_table
62
+ }.not_to raise_error
63
+ end
64
+ end
65
+ end
66
+
33
67
  context "Refile Provided tests" do
34
68
  let(:connection_or_proc) { connection }
35
69
  it_behaves_like :backend
data/spec/spec_helper.rb CHANGED
@@ -11,11 +11,13 @@ require "refile/postgres"
11
11
 
12
12
  WebMock.disable!(:except => [:codeclimate_test_reporter])
13
13
 
14
- RSpec.configure do |config|
15
- config.before(:all) do
16
- connection = PG.connect(host: 'localhost', dbname: 'refile_test', user: 'refile_postgres_test_user', password: 'refilepostgres')
17
- connection.exec %{ DROP TABLE IF EXISTS #{Refile::Postgres::Backend::DEFAULT_REGISTRY_TABLE} CASCADE; }
18
- connection.exec %{
14
+ module DatabaseHelpers
15
+ def test_connection
16
+ @@connection ||= PG.connect(host: 'localhost', dbname: 'refile_test', user: 'refile_postgres_test_user', password: 'refilepostgres')
17
+ end
18
+
19
+ def create_registy_table
20
+ test_connection.exec %{
19
21
  CREATE TABLE IF NOT EXISTS #{Refile::Postgres::Backend::DEFAULT_REGISTRY_TABLE}
20
22
  (
21
23
  id serial NOT NULL,
@@ -27,4 +29,18 @@ RSpec.configure do |config|
27
29
  );
28
30
  }
29
31
  end
32
+
33
+ def drop_registry_table
34
+ test_connection.exec %{ DROP TABLE IF EXISTS #{Refile::Postgres::Backend::DEFAULT_REGISTRY_TABLE} CASCADE; }
35
+ end
36
+ end
37
+
38
+ RSpec.configure do |config|
39
+ config.include DatabaseHelpers
40
+
41
+ config.around(:each) do |example|
42
+ create_registy_table
43
+ example.run
44
+ drop_registry_table
45
+ end
30
46
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: refile-postgres
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Krists Ozols
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-01 00:00:00.000000000 Z
11
+ date: 2016-03-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: refile
@@ -209,7 +209,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
209
209
  version: '0'
210
210
  requirements: []
211
211
  rubyforge_project:
212
- rubygems_version: 2.4.5.1
212
+ rubygems_version: 2.5.1
213
213
  signing_key:
214
214
  specification_version: 4
215
215
  summary: Postgres database as a backend for Refile