Skip to content

Commit

Permalink
add clear_cache! to reset the stored campaigns between specs
Browse files Browse the repository at this point in the history
  • Loading branch information
joshmn committed Aug 24, 2023
1 parent 0356067 commit 2e9848c
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 2 deletions.
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,18 @@

Important additions/changes/removals will appear here.

## Master
## Unreleased

Nothing.

## 2.5 (August 24, 2023)

### Fixed
* If you `touch` a mailing it'll check if it needs to `#end_if_no_mailings` properly [#36](https://github.com/joshmn/caffeinate/pull/36)

### Added
* `Caffeinate.dripper_collection.clear_cache!` to resolve https://github.com/joshmn/caffeinate/issues/39

## 2.4 (April 24, 2023)

### Added
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ Caffeinate also...
* ✅ Tested against large databases at AngelList and is performant as hell
* ✅ Effortlessly handles complex workflows
- Need to skip a certain mailing? You can!

## Documentation

* [Getting started, tips and tricks](https://github.com/joshmn/caffeinate/blob/master/docs/README.md)
Expand Down
4 changes: 4 additions & 0 deletions lib/caffeinate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,8 @@ def self.config
def self.setup
yield config
end

def self.test_mode!

end
end
9 changes: 9 additions & 0 deletions lib/caffeinate/dripper_collection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@ def drippers
@registry.values
end

# Caffeinate maintains a couple of class-variables under the hood
# that don't get reset between specs (while the db records they cache do
# get truncated). This resets the appropriate class-variables between specs
def clear_cache!
drippers.each do |dripper|
dripper.safe_constantize.class_eval { @caffeinate_campaign = nil }
end
end

def clear!
@registry = {}
end
Expand Down
5 changes: 5 additions & 0 deletions lib/caffeinate/rspec/helpers.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
RSpec.configure do |config|
config.before(:each) do
Caffeinate.dripper_collection.clear_cache!
end
end

0 comments on commit 2e9848c

Please sign in to comment.