unread 0.7.0 → 0.7.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: 9a7a52ce94c2d2bf78f926c90869494d43c7c0d5
4
- data.tar.gz: 3f75e1d043b89b5ec6cee60f5b1197106399df23
3
+ metadata.gz: b42af3056d22efa6bd8f01efb9015ce13f4e2655
4
+ data.tar.gz: 99e1e8ba04db00f7d29e40dfb5ac4370511d3fe5
5
5
  SHA512:
6
- metadata.gz: 576527e97d9c23f90a6d96061598e890a86c3fcb06a36030472e4e12f04a5abfe231eea980c6a122335319f9630c9c71bb4604e77f01018a7b378046dda736ae
7
- data.tar.gz: 34fd6607a8935bf86ca508def361545f0d1a56d6b9c5057102db317dca29769d27a47d98b8059750d6063bb74a6adfee348db47c18453848ed859f4c1e3f2a83
6
+ metadata.gz: d4cd7ed7703aa74f878b8c3a93b2c5b083775b04735590db2431d745e2f68e271c7f3546cb8494de38c1969ad552894cc5a0e776a9303a63d6ed0d1bb1b796de
7
+ data.tar.gz: 98263bf4a54954ce81777b2c6aefde0baee14938da8ecea81462bfa693c263a7862bc2ff5fbb9c14bb948916ff5febee9f303df1b3fa24c5cb660111c6b2e486
@@ -16,5 +16,7 @@ sudo: false
16
16
  env:
17
17
  - DB=sqlite
18
18
  - DB=mysql
19
+ - DB=postgres
19
20
  before_script:
20
21
  - sh -c "if [ '$DB' = 'mysql' ]; then mysql -e 'create database IF NOT EXISTS unread_test;'; fi"
22
+ - sh -c "if [ '$DB' = 'postgres' ]; then psql -c 'create database unread_test;' -U postgres; fi"
data/README.md CHANGED
@@ -21,6 +21,7 @@ Ruby gem to manage read/unread status of ActiveRecord objects - and it's fast.
21
21
 
22
22
  * Ruby 1.9.3 or newer
23
23
  * Rails 3 (including 3.0, 3.1, 3.2) and Rails 4. For use with Rails 2.3 there is a branch named "rails2"
24
+ * MySQL, PostgreSQL or SQLite
24
25
  * Needs a timestamp field in your models (like created_at or updated_at) with a database index on it
25
26
 
26
27
 
@@ -20,7 +20,7 @@ require 'spec/app/models/email'
20
20
  # Pry.start
21
21
 
22
22
  ActiveRecord::Base.configurations = YAML.load_file('spec/database.yml')
23
- ActiveRecord::Base.establish_connection(:sqlite)
23
+ ActiveRecord::Base.establish_connection((ENV['DB'] || 'sqlite').to_sym)
24
24
  ActiveRecord::Migration.verbose = false
25
25
 
26
26
  UnreadMigration.up
@@ -3,6 +3,7 @@ source 'https://rubygems.org'
3
3
  gem 'activerecord', '~> 3.0.20'
4
4
  gem 'sqlite3'
5
5
  gem 'activerecord-mysql2-adapter'
6
+ gem 'pg'
6
7
  gem 'timecop'
7
8
  gem 'rake'
8
9
  gem 'rspec'
@@ -3,6 +3,7 @@ source 'https://rubygems.org'
3
3
  gem 'activerecord', '~> 3.1.12'
4
4
  gem 'sqlite3'
5
5
  gem 'mysql2', '~> 0.3.10'
6
+ gem 'pg'
6
7
  gem 'timecop'
7
8
  gem 'rake'
8
9
  gem 'rspec'
@@ -3,6 +3,7 @@ source 'https://rubygems.org'
3
3
  gem 'activerecord', '~> 3.2.17'
4
4
  gem 'sqlite3'
5
5
  gem 'mysql2', '~> 0.3.10'
6
+ gem 'pg'
6
7
  gem 'timecop'
7
8
  gem 'rake'
8
9
  gem 'rspec'
@@ -3,6 +3,7 @@ source 'https://rubygems.org'
3
3
  gem 'activerecord', '~> 4.0.4'
4
4
  gem 'sqlite3'
5
5
  gem 'mysql2', '~> 0.3.10'
6
+ gem 'pg'
6
7
  gem 'timecop'
7
8
  gem 'rake'
8
9
  gem 'rspec'
@@ -3,6 +3,7 @@ source 'https://rubygems.org'
3
3
  gem 'activerecord', '~> 4.1.0'
4
4
  gem 'sqlite3'
5
5
  gem 'mysql2', '~> 0.3.13'
6
+ gem 'pg'
6
7
  gem 'timecop'
7
8
  gem 'rake'
8
9
  gem 'rspec'
@@ -3,6 +3,7 @@ source 'https://rubygems.org'
3
3
  gem 'activerecord', '~> 4.2.0'
4
4
  gem 'sqlite3'
5
5
  gem 'mysql2', '~> 0.3.13'
6
+ gem 'pg'
6
7
  gem 'timecop'
7
8
  gem 'rake'
8
9
  gem 'rspec'
@@ -30,7 +30,7 @@ module Unread
30
30
  reader_scope.
31
31
  joins(:read_marks).
32
32
  where(:read_marks => { :readable_type => readable_class.base_class.name }).
33
- group('read_marks.reader_type, read_marks.reader_id').
33
+ group("read_marks.reader_type, read_marks.reader_id, #{reader_class.quoted_table_name}.#{reader_class.quoted_primary_key}").
34
34
  having('COUNT(read_marks.id) > 1')
35
35
  end
36
36
 
@@ -122,7 +122,7 @@ module Unread
122
122
  private
123
123
 
124
124
  def read_mark_id_belongs_to?(reader)
125
- self.read_mark_reader_id == reader.id &&
125
+ self.read_mark_reader_id.to_i == reader.id &&
126
126
  self.read_mark_reader_type == reader.class.base_class.name
127
127
  end
128
128
  end
@@ -35,7 +35,7 @@ module Unread
35
35
 
36
36
  def read_mark_id_belongs_to?(readable)
37
37
  self.read_mark_readable_type == readable.class.base_class.name &&
38
- (self.read_mark_readable_id.nil? || self.read_mark_readable_id == readable.id)
38
+ (self.read_mark_readable_id.nil? || self.read_mark_readable_id.to_i == readable.id)
39
39
  end
40
40
 
41
41
  # We assume that a new reader should not be tackled by tons of old messages created BEFORE he signed up.
@@ -1,3 +1,3 @@
1
1
  module Unread
2
- VERSION = '0.7.0'
2
+ VERSION = '0.7.1'
3
3
  end
@@ -1,8 +1,8 @@
1
1
  class Reader < ActiveRecord::Base
2
2
  self.primary_key = 'number'
3
3
 
4
- scope :not_foo, -> { where('name <> "foo"') }
5
- scope :not_bar, -> { where('name <> "bar"') }
4
+ scope :not_foo, -> { where("name <> 'foo'") }
5
+ scope :not_bar, -> { where("name <> 'bar'") }
6
6
 
7
7
  acts_as_reader
8
8
 
@@ -6,3 +6,7 @@ mysql:
6
6
  database: unread_test
7
7
  username: root
8
8
  encoding: utf8
9
+ postgres:
10
+ adapter: postgresql
11
+ database: unread_test
12
+ username: postgres
@@ -1,4 +1,6 @@
1
1
  RSpec::Matchers.define :perform_queries do |expected|
2
+ supports_block_expectations
3
+
2
4
  match do |block|
3
5
  query_count(&block) == expected
4
6
  end
@@ -12,11 +14,6 @@ RSpec::Matchers.define :perform_queries do |expected|
12
14
  ActiveSupport::Notifications.subscribe('sql.active_record', @counter.to_proc)
13
15
  yield
14
16
  ActiveSupport::Notifications.unsubscribe(@counter.to_proc)
15
-
16
17
  @counter.query_count
17
18
  end
18
-
19
- def supports_block_expectations?
20
- true
21
- end
22
19
  end
@@ -25,7 +25,8 @@ Gem::Specification.new do |s|
25
25
  s.add_development_dependency 'rake'
26
26
  s.add_development_dependency 'timecop'
27
27
  s.add_development_dependency 'sqlite3'
28
- s.add_development_dependency 'mysql2'
28
+ s.add_development_dependency 'mysql2', '~> 0.3.13'
29
+ s.add_development_dependency 'pg'
29
30
  s.add_development_dependency 'rspec'
30
31
  s.add_development_dependency 'simplecov'
31
32
  s.add_development_dependency 'coveralls', '>= 0.8.0'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: unread
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Georg Ledermann
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-04 00:00:00.000000000 Z
11
+ date: 2015-11-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -68,6 +68,20 @@ dependencies:
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: mysql2
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 0.3.13
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 0.3.13
83
+ - !ruby/object:Gem::Dependency
84
+ name: pg
71
85
  requirement: !ruby/object:Gem::Requirement
72
86
  requirements:
73
87
  - - ">="