-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
81 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
app/jobs/solid_cable/prune_job.rb → app/jobs/solid_cable/trim_job.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
# frozen_string_literal: true | ||
|
||
module SolidCable | ||
class PruneJob < ActiveJob::Base | ||
class TrimJob < ActiveJob::Base | ||
def perform | ||
::SolidCable::Message.prunable.delete_all | ||
::SolidCable::Message.trimmable.delete_all | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# frozen_string_literal: true | ||
|
||
module ConfigHelpers | ||
extend ActiveSupport::Concern | ||
|
||
class ConfigStub | ||
def initialize(**) | ||
@config = ActiveSupport::OrderedOptions.new. | ||
update({ adapter: :test }.merge(**)) | ||
end | ||
|
||
def config_for(_file) | ||
@config | ||
end | ||
end | ||
|
||
def with_cable_config(**) | ||
Rails.stub(:application, ConfigStub.new(**)) { yield } | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,29 @@ | ||
# frozen_string_literal: true | ||
|
||
require "test_helper" | ||
require "config_helpers" | ||
|
||
class SolidCableTest < ActiveSupport::TestCase | ||
include ConfigHelpers | ||
|
||
test "it has a version number" do | ||
assert SolidCable::VERSION | ||
end | ||
|
||
test "autotrimming when nothing is set" do | ||
assert_not Rails.application.config_for("cable").key?(:autotrim) | ||
assert SolidCable.autotrim? | ||
end | ||
|
||
test "autotrimming when set to false" do | ||
with_cable_config autotrim: false do | ||
assert_not SolidCable.autotrim? | ||
end | ||
end | ||
|
||
test "autotrimming when set to true" do | ||
with_cable_config autotrim: true do | ||
assert SolidCable.autotrim? | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters