|
235 | 235 | let(:inventory_item) { storage_location.inventory_items.first }
|
236 | 236 |
|
237 | 237 | context "with a version found" do
|
238 |
| - it "should show the version specified" do |
239 |
| - travel 1.day do |
240 |
| - inventory_item.update!(quantity: 100) |
| 238 | + context "with events_read on" do |
| 239 | + before(:each) { allow(Event).to receive(:read_events?).and_return(true) } |
| 240 | + context "before active events" do |
| 241 | + it "should show the version specified" do |
| 242 | + travel 1.day do |
| 243 | + inventory_item.update!(quantity: 100) |
| 244 | + end |
| 245 | + travel 1.week do |
| 246 | + inventory_item.update!(quantity: 300) |
| 247 | + end |
| 248 | + travel 8.days do |
| 249 | + SnapshotEvent.delete_all |
| 250 | + SnapshotEvent.publish(organization) |
| 251 | + end |
| 252 | + travel 2.weeks do |
| 253 | + get storage_location_path(storage_location, format: response_format, |
| 254 | + version_date: 9.days.ago.to_date.to_fs(:db)) |
| 255 | + expect(response).to be_successful |
| 256 | + expect(response.body).to include("Smithsonian") |
| 257 | + expect(response.body).to include("Test Item") |
| 258 | + expect(response.body).to include("100") |
| 259 | + end |
| 260 | + end |
241 | 261 | end
|
242 |
| - travel 1.week do |
243 |
| - inventory_item.update!(quantity: 300) |
| 262 | + |
| 263 | + context "with active events" do |
| 264 | + it 'should show the right version' do |
| 265 | + travel 1.day do |
| 266 | + TestInventory.create_inventory(organization, { |
| 267 | + storage_location.id => { |
| 268 | + item.id => 100, |
| 269 | + item2.id => 0 |
| 270 | + } |
| 271 | + }) |
| 272 | + end |
| 273 | + travel 1.week do |
| 274 | + TestInventory.create_inventory(organization, { |
| 275 | + storage_location.id => { |
| 276 | + item.id => 300, |
| 277 | + item2.id => 0 |
| 278 | + } |
| 279 | + }) |
| 280 | + end |
| 281 | + travel 2.weeks do |
| 282 | + get storage_location_path(storage_location, format: response_format, |
| 283 | + version_date: 9.days.ago.to_date.to_fs(:db)) |
| 284 | + expect(response).to be_successful |
| 285 | + expect(response.body).to include("Smithsonian") |
| 286 | + expect(response.body).to include("Test Item") |
| 287 | + expect(response.body).to include("100") |
| 288 | + end |
| 289 | + end |
244 | 290 | end
|
245 |
| - travel 2.weeks do |
246 |
| - get storage_location_path(storage_location, format: response_format, |
247 |
| - version_date: 9.days.ago.to_date.to_fs(:db)) |
248 |
| - expect(response).to be_successful |
249 |
| - expect(response.body).to include("Smithsonian") |
250 |
| - expect(response.body).to include("Test Item") |
251 |
| - expect(response.body).to include("100") |
| 291 | + end |
| 292 | + context "with events_read off" do |
| 293 | + before(:each) { allow(Event).to receive(:read_events?).and_return(false) } |
| 294 | + it "should show the version specified" do |
| 295 | + travel 1.day do |
| 296 | + inventory_item.update!(quantity: 100) |
| 297 | + end |
| 298 | + travel 1.week do |
| 299 | + inventory_item.update!(quantity: 300) |
| 300 | + end |
| 301 | + travel 2.weeks do |
| 302 | + get storage_location_path(storage_location, format: response_format, |
| 303 | + version_date: 9.days.ago.to_date.to_fs(:db)) |
| 304 | + expect(response).to be_successful |
| 305 | + expect(response.body).to include("Smithsonian") |
| 306 | + expect(response.body).to include("Test Item") |
| 307 | + expect(response.body).to include("100") |
| 308 | + end |
252 | 309 | end
|
253 | 310 | end
|
254 | 311 | end
|
|
0 commit comments