File tree Expand file tree Collapse file tree 4 files changed +43
-1
lines changed
Expand file tree Collapse file tree 4 files changed +43
-1
lines changed Original file line number Diff line number Diff line change 11Gem ::Specification . new do |spec |
22 spec . name = 'code_teams'
3- spec . version = '1.0.1 '
3+ spec . version = '1.0.2 '
44 spec . authors = [ 'Gusto Engineers' ]
55 spec . email = [ '[email protected] ' ] 66 spec . summary = 'A low-dependency gem for declaring and querying engineering teams'
Original file line number Diff line number Diff line change @@ -60,6 +60,7 @@ def self.tag_value_for(string)
6060 # The primary reason this is helpful is for clients of CodeTeams who want to test their code, and each test context has different set of teams
6161 sig { void }
6262 def self . bust_caches!
63+ Plugin . bust_caches!
6364 @all = nil
6465 @index_by_name = nil
6566 end
Original file line number Diff line number Diff line change @@ -61,6 +61,16 @@ def self.register_team(team)
6161 T . unsafe ( registry_for_team [ self ] )
6262 end
6363
64+ sig { void }
65+ def self . bust_caches!
66+ all_plugins . each ( &:clear_team_registry! )
67+ end
68+
69+ sig { void }
70+ def self . clear_team_registry!
71+ @registry = nil
72+ end
73+
6474 private_class_method :registry
6575 private_class_method :register_team
6676 end
Original file line number Diff line number Diff line change 1+ RSpec . describe CodeTeams ::Plugin do
2+ def write_team_yml ( extra_data : false )
3+ write_file ( 'config/teams/my_team.yml' , <<~YML . strip )
4+ name: My Team
5+ extra_data: #{ extra_data }
6+ YML
7+ end
8+
9+ before do
10+ CodeTeams . bust_caches!
11+
12+ test_plugin_class = Class . new ( described_class ) do
13+ def extra_data
14+ @team . raw_hash [ 'extra_data' ]
15+ end
16+ end
17+ stub_const ( 'TestPlugin' , test_plugin_class )
18+ end
19+
20+ describe '.bust_caches!' do
21+ it 'clears all plugins team registries ensuring cached configs are purged' do
22+ write_team_yml ( extra_data : true )
23+ team = CodeTeams . find ( 'My Team' )
24+ expect ( TestPlugin . for ( team ) . extra_data ) . to be ( true )
25+ write_team_yml ( extra_data : false )
26+ CodeTeams . bust_caches!
27+ team = CodeTeams . find ( 'My Team' )
28+ expect ( TestPlugin . for ( team ) . extra_data ) . to be ( false )
29+ end
30+ end
31+ end
You can’t perform that action at this time.
0 commit comments