forked from MiraWaNeko/zammad
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into private-te-refactoring-constantize
- Loading branch information
Showing
16 changed files
with
434 additions
and
334 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
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,22 @@ | ||
# Copyright (C) 2012-2016 Zammad Foundation, http://zammad-foundation.org/ | ||
class Channel::Driver::Null | ||
def fetchable?(_channel) | ||
false | ||
end | ||
|
||
def fetch(*) | ||
{ | ||
result: 'ok', | ||
fetched: 0, | ||
notice: '', | ||
} | ||
end | ||
|
||
def disconnect | ||
true | ||
end | ||
|
||
def self.streamable? | ||
false | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,4 +31,8 @@ def self.with_parents(key) | |
names | ||
end | ||
|
||
def to_s | ||
name | ||
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,5 @@ | ||
FactoryBot.define do | ||
factory :permission do | ||
name { Faker::Job.unique.position.downcase } | ||
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 |
---|---|---|
@@ -0,0 +1,100 @@ | ||
require 'rails_helper' | ||
|
||
RSpec.describe Cache do | ||
describe '.get' do | ||
before { allow(Rails.cache).to receive(:read) } | ||
|
||
it 'wraps Rails.cache.read' do | ||
Cache.get('foo') | ||
|
||
expect(Rails.cache).to have_received(:read).with('foo') | ||
end | ||
|
||
context 'with a non-string argument' do | ||
it 'passes a string' do | ||
Cache.get(:foo) | ||
|
||
expect(Rails.cache).to have_received(:read).with('foo') | ||
end | ||
end | ||
end | ||
|
||
describe '.write' do | ||
it 'stores string values' do | ||
expect { Cache.write('123', 'some value') } | ||
.to change { Cache.get('123') }.to('some value') | ||
end | ||
|
||
it 'stores hash values' do | ||
expect { Cache.write('123', { key: 'some value' }) } | ||
.to change { Cache.get('123') }.to({ key: 'some value' }) | ||
end | ||
|
||
it 'overwrites previous values' do | ||
Cache.write('123', 'some value') | ||
|
||
expect { Cache.write('123', { key: 'some value' }) } | ||
.to change { Cache.get('123') }.to({ key: 'some value' }) | ||
end | ||
|
||
it 'stores hash values with non-ASCII content' do | ||
expect { Cache.write('123', { key: 'some valueöäüß' }) } | ||
.to change { Cache.get('123') }.to({ key: 'some valueöäüß' }) | ||
end | ||
|
||
it 'defaults to expires_in: 7.days' do | ||
Cache.write('123', 'some value') | ||
|
||
expect { travel 7.days }.not_to change { Cache.get('123') } | ||
expect { travel 1.second }.to change { Cache.get('123') }.to(nil) | ||
end | ||
|
||
it 'accepts a custom :expires_in option' do | ||
Cache.write('123', 'some value', expires_in: 3.seconds) | ||
|
||
expect { travel 4.seconds }.to change { Cache.get('123') }.to(nil) | ||
end | ||
end | ||
|
||
describe '.delete' do | ||
it 'deletes stored values' do | ||
Cache.write('123', 'some value') | ||
|
||
expect { Cache.delete('123') } | ||
.to change { Cache.get('123') }.to(nil) | ||
end | ||
|
||
it 'is idempotent' do | ||
Cache.write('123', 'some value') | ||
Cache.delete('123') | ||
|
||
expect { Cache.delete('123') }.not_to raise_error | ||
end | ||
end | ||
|
||
describe '.clear' do | ||
it 'deletes all stored values' do | ||
Cache.write('123', 'some value') | ||
Cache.write('456', 'some value') | ||
|
||
expect { Cache.clear } | ||
.to change { Cache.get('123') }.to(nil) | ||
.and change { Cache.get('456') }.to(nil) | ||
end | ||
|
||
it 'is idempotent' do | ||
Cache.write('123', 'some value') | ||
Cache.clear | ||
|
||
expect { Cache.clear }.not_to raise_error | ||
end | ||
|
||
context 'when cache directory is not present on disk' do | ||
before { FileUtils.rm_rf(Rails.cache.cache_path) } | ||
|
||
it 'does not raise an error' do | ||
expect { Cache.clear }.not_to raise_error | ||
end | ||
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
Oops, something went wrong.