electric_slide 0.4.2 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 738ba12a4f2d6f7e957a126897abe3cf360f00f4
4
- data.tar.gz: 8fc8b4d809fd3ec91b06e98b253d379528bf496f
3
+ metadata.gz: 49101ac1f213829f41caab6990cf3183d533f3e1
4
+ data.tar.gz: 796e9cd5bbee24fcda95e58022cf1f83f8c4f2f0
5
5
  SHA512:
6
- metadata.gz: 1b0649085afa609d2c7f42b0029ac2967e61c2959e0d2e4d64df13e97748b20d192b729cff419c924fd8891820a93229e87c2a279d76e793338e1cca96bb57f3
7
- data.tar.gz: 82eb164c033578acc2367ae0f9ae9a2c6f8e7ba0db7483f9cf4f70a732d1f40acbc2301e0b33328c4c049c28b512ae98fe1ebaddde2736775afeeb5010d1b8fe
6
+ metadata.gz: 65de89ec11a21d769a14c50c0a359407b2805b096bf87ca35637502030cbc9bbdc0e3199345ecb52cdea49168d652d0ba19559f02e1edcb379789d9e8f032c3f
7
+ data.tar.gz: 9ba4811599997c2831762642cd0e9b49dc98f9606054ef1de8f00448e9c4fe7dc680b0e173aa2ec3cf284bc245ba16c2b67c7d78474e52055c00cbd08503da3d
data/CHANGELOG.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # [develop](https://github.com/adhearsion/electric_slide)
2
2
 
3
+ # [0.5.0](https://github.com/adhearsion/electric_slide/compare/v0.4.2...v0.5.0) - [2016-02-12](https://rubygems.org/gems/adhearsion/versions/0.5.0)
4
+ * API Breakage: Fixed priority strategy now ensures that the same agent cannot be in multiple priorities
5
+
3
6
  # [0.4.2](https://github.com/adhearsion/electric_slide/compare/v0.4.1...v0.4.2) - [2016-02-04](https://rubygems.org/gems/adhearsion/versions/0.4.2)
4
7
  * Bugfix: FixedPriority now correctly checks out agents in priority order.
5
8
 
@@ -37,11 +37,15 @@ class ElectricSlide
37
37
  end
38
38
 
39
39
  def <<(agent)
40
- # TODO: How aggressively do we check for agents duplicated in multiple priorities?
41
40
  raise ArgumentError, "Agents must have a specified priority" unless agent.respond_to?(:priority)
41
+
42
42
  priority = agent.priority || 999999
43
43
  @priorities[priority] ||= []
44
- @priorities[priority] << agent unless @priorities[priority].include? agent
44
+
45
+ unless @priorities[priority].include?(agent)
46
+ delete(agent)
47
+ @priorities[priority] << agent
48
+ end
45
49
  end
46
50
 
47
51
  def delete(agent)
@@ -1,4 +1,4 @@
1
1
  # encoding: utf-8
2
2
  class ElectricSlide
3
- VERSION = '0.4.2'
3
+ VERSION = '0.5.0'
4
4
  end
@@ -39,4 +39,25 @@ describe ElectricSlide::AgentStrategy::FixedPriority do
39
39
  subject.checkout_agent
40
40
  expect(subject.agent_available?).to be true
41
41
  end
42
+
43
+ context 'when agents at different priorities are available' do
44
+ let(:agent1) { agent1 = OpenStruct.new(id: 101, priority: 1) }
45
+ let(:agent2) { agent1 = OpenStruct.new(id: 102, priority: 2) }
46
+
47
+ before do
48
+ subject << agent1
49
+ subject << agent2
50
+ end
51
+
52
+ describe 'and the higher priority agent is added again, but at the lowest priority' do
53
+ before do
54
+ agent1.priority = 3
55
+ subject << agent1
56
+ end
57
+
58
+ it 'moves the agent to the new, lower priority' do
59
+ expect(subject.checkout_agent).to eq(agent2)
60
+ end
61
+ end
62
+ end
42
63
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: electric_slide
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Klang
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-04 00:00:00.000000000 Z
11
+ date: 2016-02-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: adhearsion