|
4 | 4 | let(:miq_server) { EvmSpecHelper.local_miq_server } |
5 | 5 | let(:zone) { miq_server.zone } |
6 | 6 |
|
| 7 | + context "#validate" do |
| 8 | + it "allows nil zones" do |
| 9 | + msg = FactoryBot.build(:miq_queue) |
| 10 | + expect(msg.zone).to be_nil |
| 11 | + expect(msg).to be_valid |
| 12 | + end |
| 13 | + |
| 14 | + it "allows valid zone names" do |
| 15 | + msg = FactoryBot.build(:miq_queue, :zone => zone.name) |
| 16 | + expect(msg).to be_valid |
| 17 | + end |
| 18 | + |
| 19 | + it "complains about unknown zone names" do |
| 20 | + msg = FactoryBot.build(:miq_queue, :zone => "#{zone.name}x") |
| 21 | + expect(msg).not_to be_valid |
| 22 | + end |
| 23 | + |
| 24 | + it "only queries a single zone one time" do |
| 25 | + # cache the value |
| 26 | + msg = FactoryBot.build(:miq_queue, :zone => zone.name) |
| 27 | + expect(msg).to be_valid |
| 28 | + expect { expect(FactoryBot.build(:miq_queue, :zone => zone.name)).to be_valid }.not_to make_database_queries |
| 29 | + end |
| 30 | + |
| 31 | + it "can find new zones" do |
| 32 | + # potentially load the cached |
| 33 | + msg = FactoryBot.build(:miq_queue, :zone => zone.name) |
| 34 | + expect(msg).to be_valid |
| 35 | + zone2 = FactoryBot.create(:zone) |
| 36 | + msg = FactoryBot.build(:miq_queue, :zone => zone2.name) |
| 37 | + expect(msg).to be_valid |
| 38 | + end |
| 39 | + end |
| 40 | + |
7 | 41 | context "#deliver" do |
8 | 42 | before { miq_server } |
9 | 43 | it "requires class_name" do |
|
0 commit comments