acts_as_readable 2.4.0 → 2.5.0

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: 26f1b10303846fe0f6adb4dd943ca37ba592463bfaf57b6dbf8f55008bca9d9f
4
- data.tar.gz: c108f52d20a6b6e32f76b57486a87dffcea367b33e2b9d11845761cbde28bb76
3
+ metadata.gz: 8ebb4f311aa3f11a92b82cc87aa496a4501202dc5e63a22f619bb1e01195c758
4
+ data.tar.gz: 21bd9b62364d989f6103c4b112d989d6234274c7f3a0faa05d2eaeac1a3a8de2
5
5
  SHA512:
6
- metadata.gz: 2cdf040047e4f4985c51d2bd1a0b3f207f4f8d6ee7c17f3732c5c93a09f89c2a842ec670e970ff5c8cb0f00dc0bf02fdbff9fe04b3d154b3881f4d52db17f209
7
- data.tar.gz: 335b0e36faf70e2385bc806a5900a4eddaf66ab0e8fdf18b9c2850a041329408c89b0c8d6107eb29a596bcee7c3217522fc5a2907d625b202fec5ce61d19f0f7
6
+ metadata.gz: 3190c64def5ec6c0ad43f22a2963a58132db21c7a4fb57302f18069e3f4d1a3757c581f1a6f256b882ab4e3a3e84c10f5dab1e492d93756342fbbadd8517ad63
7
+ data.tar.gz: 4c5ebf476c915aedf33852450ffc05d48ebb2a3d420f2bcdd0e41d487eeabf1feb784caaf2a6a37d4abc5a420f487508064da53574af2aea8da1f5c975baf015
@@ -79,6 +79,19 @@ module ActsAsReadable
79
79
  end
80
80
  end
81
81
  end
82
+
83
+ # Mark all records as unread by the user
84
+ # If a :cache option has been set in acts_as_readable, a timestamp will be cleared on the user as well as deleting all readings for that user with this class as the readable type
85
+ def unread_by!(user)
86
+ if user.has_attribute?(acts_as_readable_options[:cache])
87
+ Reading.where(:user_id => user.id, :readable_type => HelperMethods.readable_type(self)).delete_all
88
+ user.update_column(acts_as_readable_options[:cache], nil)
89
+ else
90
+ read_by(user).find_each do |record|
91
+ record.unread_by!(user)
92
+ end
93
+ end
94
+ end
82
95
  end
83
96
 
84
97
  module InstanceMethods
@@ -9,6 +9,14 @@ describe 'acts_as_readable' do
9
9
  @user = User.create
10
10
  end
11
11
 
12
+ describe '::unread_by!' do
13
+ it "clears all readings with this readable class for the given user" do
14
+ readable_class.read_by! @user
15
+ expect { readable_class.unread_by! @user }
16
+ .to change { queryable_class.unread_by(@user) }.to include(@queryable)
17
+ end
18
+ end
19
+
12
20
  describe "the unread scope" do
13
21
  it "should not return records explicitly marked as read" do
14
22
  @readable.read_by! @user
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: acts_as_readable
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.0
4
+ version: 2.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nicholas Jakobsen
8
8
  - Ryan Wallace
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2024-03-06 00:00:00.000000000 Z
12
+ date: 2024-10-31 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -59,7 +59,7 @@ dependencies:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
61
  version: '4'
62
- description:
62
+ description:
63
63
  email: contact@culturecode.ca
64
64
  executables: []
65
65
  extensions: []
@@ -76,7 +76,7 @@ files:
76
76
  homepage: http://github.com/culturecode/acts_as_readable
77
77
  licenses: []
78
78
  metadata: {}
79
- post_install_message:
79
+ post_install_message:
80
80
  rdoc_options: []
81
81
  require_paths:
82
82
  - lib
@@ -91,8 +91,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
91
91
  - !ruby/object:Gem::Version
92
92
  version: '0'
93
93
  requirements: []
94
- rubygems_version: 3.3.23
95
- signing_key:
94
+ rubygems_version: 3.5.13
95
+ signing_key:
96
96
  specification_version: 4
97
97
  summary: Allows records to be marked as readable. Optimized for bulk, 'mark all as
98
98
  read' operations