spec/acceptance/rest/push_admin_spec.rb in ably-1.1.1 vs spec/acceptance/rest/push_admin_spec.rb in ably-1.1.2
- old
+ new
@@ -179,10 +179,16 @@
describe '#list (#RSH1b2)' do
let(:client_id) { random_str }
let(:fixture_count) { 6 }
+ before(:all) do
+ # As push tests often use the global scope (devices),
+ # we need to ensure tests cannot conflict
+ reload_test_app
+ end
+
before do
fixture_count.times.map do |index|
Thread.new do
subject.save({
id: "device-#{client_id}-#{index}",
@@ -242,10 +248,16 @@
describe '#get (#RSH1b1)' do
let(:fixture_count) { 2 }
let(:client_id) { random_str }
+ before(:all) do
+ # As push tests often use the global scope (devices),
+ # we need to ensure tests cannot conflict
+ reload_test_app
+ end
+
before do
fixture_count.times.map do |index|
Thread.new do
subject.save({
id: "device-#{client_id}-#{index}",
@@ -316,10 +328,16 @@
},
}
}
end
+ before(:all) do
+ # As push tests often use the global scope (devices),
+ # we need to ensure tests cannot conflict
+ reload_test_app
+ end
+
after do
subject.remove_where client_id: client_id, full_wait: true
end
it 'saves the new DeviceDetails Hash object' do
@@ -442,10 +460,16 @@
describe '#remove_where (#RSH1b5)' do
let(:device_id) { random_str }
let(:client_id) { random_str }
+ before(:all) do
+ # As push tests often use the global scope (devices),
+ # we need to ensure tests cannot conflict
+ reload_test_app
+ end
+
before do
[
Thread.new do
subject.save({
id: "device-#{client_id}-0",
@@ -499,10 +523,16 @@
describe '#remove (#RSH1b4)' do
let(:device_id) { random_str }
let(:client_id) { random_str }
+ before(:all) do
+ # As push tests often use the global scope (devices),
+ # we need to ensure tests cannot conflict
+ reload_test_app
+ end
+
before do
[
Thread.new do
subject.save({
id: "device-#{client_id}-0",
@@ -583,12 +613,12 @@
# Set up 2 devices with the same client_id
# and two device with the unique device_id and no client_id
before do
[
- lambda { device_registrations.save(default_device_attr.merge(id: device_id)) },
- lambda { device_registrations.save(default_device_attr.merge(id: device_id_2)) },
+ lambda { device_registrations.save(default_device_attr.merge(id: device_id, client_id: nil)) },
+ lambda { device_registrations.save(default_device_attr.merge(id: device_id_2, client_id: nil)) },
lambda { device_registrations.save(default_device_attr.merge(client_id: client_id, id: random_str)) },
lambda { device_registrations.save(default_device_attr.merge(client_id: client_id, id: random_str)) }
].map do |proc|
Thread.new { proc.call }
end.each(&:join) # Wait for all threads to complete
@@ -600,10 +630,16 @@
end
describe '#list (#RSH1c1)' do
let(:fixture_count) { 6 }
+ before(:all) do
+ # As push tests often use the global scope (devices),
+ # we need to ensure tests cannot conflict
+ reload_test_app
+ end
+
before do
fixture_count.times.map do |index|
Thread.new { subject.save(channel: "pushenabled:#{random_str}", client_id: client_id) }
end + fixture_count.times.map do |index|
Thread.new { subject.save(channel: "pushenabled:#{random_str}", device_id: device_id) }
@@ -668,15 +704,18 @@
end
describe '#list_channels (#RSH1c2)' do
let(:fixture_count) { 6 }
- before(:context) do
- reload_test_app # TODO: Review if necessary late, currently other tests may affect list_channels
+ before(:all) do
+ # As push tests often use the global scope (devices),
+ # we need to ensure tests cannot conflict
+ reload_test_app
end
before do
+ # Create 6 channel subscriptions to the client ID for this test
fixture_count.times.map do |index|
Thread.new do
subject.save(channel: "pushenabled:#{index}:#{random_str}", client_id: client_id)
end
end.each(&:join) # Wait for all threads to complete
@@ -692,13 +731,10 @@
expect(page.items.first).to be_a(String)
expect(page.items.length).to eql(fixture_count)
end
it 'supports paging' do
- skip 'Channel lists with limits is not reliable immediately after fixture creation'
- # TODO: Remove this once list channels with limits is reliable immediately after fixtures created
- # See https://github.com/ably/realtime/issues/1882
subject.list_channels
page = subject.list_channels(limit: 3)
expect(page).to be_a(Ably::Models::PaginatedResult)
expect(page.items.count).to eql(3)
@@ -728,10 +764,16 @@
describe '#save (#RSH1c3)' do
let(:channel) { "pushenabled:#{random_str}" }
let(:client_id) { random_str }
let(:device_id) { random_str }
+ before(:all) do
+ # As push tests often use the global scope (devices),
+ # we need to ensure tests cannot conflict
+ reload_test_app
+ end
+
it 'saves the new client_id PushChannelSubscription Hash object' do
subject.save(channel: channel, client_id: client_id)
channel_sub = subject.list(client_id: client_id).items.first
expect(channel_sub).to be_a(Ably::Models::PushChannelSubscription)
@@ -800,10 +842,16 @@
let(:device_id) { random_str }
let(:fixed_channel) { "pushenabled:#{random_str}" }
let(:fixture_count) { 6 }
+ before(:all) do
+ # As push tests often use the global scope (devices),
+ # we need to ensure tests cannot conflict
+ reload_test_app
+ end
+
before do
fixture_count.times.map do |index|
[
lambda { subject.save(channel: "pushenabled:#{random_str}", client_id: client_id) },
lambda { subject.save(channel: "pushenabled:#{random_str}", device_id: device_id) },
@@ -812,12 +860,14 @@
end.flatten.map do |proc|
Thread.new { proc.call }
end.each(&:join) # Wait for all threads to complete
end
+ # TODO: Reinstate once delete subscriptions by channel is possible
+ # See https://github.com/ably/realtime/issues/1359
it 'removes matching channels' do
- skip 'Delete by channel is not yet supported'
+ skip 'deleting subscriptions is not yet supported realtime#1359'
subject.remove_where channel: fixed_channel, full_wait: true
expect(subject.list(channel: fixed_channel).items.count).to eql(0)
expect(subject.list(client_id: client_id).items.count).to eql(0)
expect(subject.list(device_id: device_id).items.count).to eql(0)
end
@@ -849,9 +899,15 @@
describe '#remove (#RSH1c4)' do
let(:channel) { "pushenabled:#{random_str}" }
let(:channel2) { "pushenabled:#{random_str}" }
let(:client_id) { random_str }
let(:device_id) { random_str }
+
+ before(:all) do
+ # As push tests often use the global scope (devices),
+ # we need to ensure tests cannot conflict
+ reload_test_app
+ end
before do
[
lambda { subject.save(channel: channel, client_id: client_id) },
lambda { subject.save(channel: channel, device_id: device_id) },