|
127 | 127 | end |
128 | 128 |
|
129 | 129 | context 'with ActorLimit adapter wrapping local' do |
130 | | - let(:limit) { 5 } |
| 130 | + let(:limit) { 10 } |
131 | 131 | let(:limited_local) { Flipper::Adapters::ActorLimit.new(local, limit) } |
132 | 132 | let(:limited_local_flipper) { Flipper.new(limited_local) } |
133 | 133 |
|
134 | 134 | subject { described_class.new(limited_local, remote, instrumenter: instrumenter) } |
135 | 135 |
|
136 | 136 | it 'syncs actors even when remote has more actors than local limit' do |
137 | 137 | # Remote has more actors than local limit allows |
138 | | - 10.times { |i| remote_flipper[:search].enable_actor Flipper::Actor.new("User;#{i}") } |
| 138 | + 20.times { |i| remote_flipper[:search].enable_actor Flipper::Actor.new("User;#{i}") } |
139 | 139 |
|
140 | 140 | # This should NOT raise - sync should bypass actor limits |
141 | 141 | expect { subject.call }.not_to raise_error |
142 | 142 |
|
143 | 143 | # All actors should be synced |
144 | | - expect(limited_local_flipper[:search].actors_value.size).to eq(10) |
| 144 | + expect(limited_local_flipper[:search].actors_value.size).to eq(20) |
| 145 | + end |
| 146 | + |
| 147 | + it 'syncs new actors added to remote after initial sync' do |
| 148 | + # Initial state: remote has 20 actors, local limit is 10 |
| 149 | + 20.times { |i| remote_flipper[:search].enable_actor Flipper::Actor.new("User;#{i}") } |
| 150 | + |
| 151 | + # First sync - should work despite exceeding limit |
| 152 | + subject.call |
| 153 | + expect(limited_local_flipper[:search].actors_value.size).to eq(20) |
| 154 | + |
| 155 | + # Add a 21st actor to remote (simulating Cloud adding a new actor) |
| 156 | + remote_flipper[:search].enable_actor Flipper::Actor.new("User;20") |
| 157 | + |
| 158 | + # Sync again - should pick up the new actor |
| 159 | + expect { subject.call }.not_to raise_error |
| 160 | + expect(limited_local_flipper[:search].actors_value.size).to eq(21) |
| 161 | + expect(limited_local_flipper[:search].actors_value).to include("User;20") |
| 162 | + end |
| 163 | + |
| 164 | + it 'still enforces limit for direct enable operations' do |
| 165 | + # First sync 20 actors from remote |
| 166 | + 20.times { |i| remote_flipper[:search].enable_actor Flipper::Actor.new("User;#{i}") } |
| 167 | + subject.call |
| 168 | + |
| 169 | + # Direct enable should still fail because we're over limit |
| 170 | + expect { |
| 171 | + limited_local_flipper[:search].enable_actor Flipper::Actor.new("User;new") |
| 172 | + }.to raise_error(Flipper::Adapters::ActorLimit::LimitExceeded) |
145 | 173 | end |
146 | 174 | end |
147 | 175 | end |
0 commit comments