From fcd46106a39ee0beedf59ad767cfd535fe0b5f5d Mon Sep 17 00:00:00 2001 From: d-m-u Date: Thu, 23 Aug 2018 08:01:09 -0400 Subject: [PATCH 1/2] Fix merge conflicts --- spec/models/dialog_spec.rb | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/spec/models/dialog_spec.rb b/spec/models/dialog_spec.rb index a9c74d6bb82..6b678b432cc 100644 --- a/spec/models/dialog_spec.rb +++ b/spec/models/dialog_spec.rb @@ -68,23 +68,23 @@ context "validate label uniqueness" do it "with same label" do - expect { @dialog = FactoryGirl.create(:dialog, :label => 'dialog') }.to_not raise_error - expect { @dialog = FactoryGirl.create(:dialog, :label => 'dialog') } + expect { @dialog = FactoryGirl.create(:dialog, :name => 'dialog') }.to_not raise_error + expect { @dialog = FactoryGirl.create(:dialog, :name => 'dialog') } .to raise_error(ActiveRecord::RecordInvalid, /Name is not unique within region/) end it "with different labels" do - expect { @dialog = FactoryGirl.create(:dialog, :label => 'dialog') }.to_not raise_error - expect { @dialog = FactoryGirl.create(:dialog, :label => 'dialog 1') }.to_not raise_error + expect { @dialog = FactoryGirl.create(:dialog, :name => 'dialog') }.to_not raise_error + expect { @dialog = FactoryGirl.create(:dialog, :name => 'dialog 1') }.to_not raise_error end end context "#create" do it "validates_presence_of name" do expect do - FactoryGirl.create(:dialog, :label => nil) + FactoryGirl.create(:dialog, :name => nil) end.to raise_error(ActiveRecord::RecordInvalid, /Label can't be blank/) - expect { FactoryGirl.create(:dialog, :label => 'dialog') }.not_to raise_error + expect { FactoryGirl.create(:dialog, :name => 'dialog') }.not_to raise_error expect do FactoryGirl.create(:dialog_tab, :label => nil) @@ -99,8 +99,8 @@ end context "#destroy" do - before do - @dialog = FactoryGirl.create(:dialog, :label => 'dialog') + before(:each) do + @dialog = FactoryGirl.create(:dialog, :name => 'dialog') end it "destroy without resource_action association" do From a29cb58f0b764b49b1507b24791de0ca211074a3 Mon Sep 17 00:00:00 2001 From: d-m-u Date: Thu, 23 Aug 2018 08:29:05 -0400 Subject: [PATCH 2/2] Address feedback --- spec/models/dialog_spec.rb | 39 +++++++++----------------------------- 1 file changed, 9 insertions(+), 30 deletions(-) diff --git a/spec/models/dialog_spec.rb b/spec/models/dialog_spec.rb index 6b678b432cc..e770964839b 100644 --- a/spec/models/dialog_spec.rb +++ b/spec/models/dialog_spec.rb @@ -68,50 +68,29 @@ context "validate label uniqueness" do it "with same label" do - expect { @dialog = FactoryGirl.create(:dialog, :name => 'dialog') }.to_not raise_error - expect { @dialog = FactoryGirl.create(:dialog, :name => 'dialog') } + dialog = FactoryGirl.create(:dialog) + + expect { FactoryGirl.create(:dialog, :name => dialog.name) } .to raise_error(ActiveRecord::RecordInvalid, /Name is not unique within region/) end it "with different labels" do - expect { @dialog = FactoryGirl.create(:dialog, :name => 'dialog') }.to_not raise_error - expect { @dialog = FactoryGirl.create(:dialog, :name => 'dialog 1') }.to_not raise_error - end - end - - context "#create" do - it "validates_presence_of name" do - expect do - FactoryGirl.create(:dialog, :name => nil) - end.to raise_error(ActiveRecord::RecordInvalid, /Label can't be blank/) - expect { FactoryGirl.create(:dialog, :name => 'dialog') }.not_to raise_error + FactoryGirl.create(:dialog) - expect do - FactoryGirl.create(:dialog_tab, :label => nil) - end.to raise_error(ActiveRecord::RecordInvalid, /Label can't be blank/) - expect { FactoryGirl.create(:dialog_tab, :label => 'tab') }.not_to raise_error - - expect do - FactoryGirl.create(:dialog_group, :label => nil) - end.to raise_error(ActiveRecord::RecordInvalid, /Label can't be blank/) - expect { FactoryGirl.create(:dialog_group, :label => 'group') }.not_to raise_error + expect { FactoryGirl.create(:dialog) }.to_not raise_error end end context "#destroy" do - before(:each) do - @dialog = FactoryGirl.create(:dialog, :name => 'dialog') - end - it "destroy without resource_action association" do - expect(@dialog.destroy).to be_truthy + expect(FactoryGirl.create(:dialog).destroy).to be_truthy expect(Dialog.count).to eq(0) end it "destroy with resource_action association" do - FactoryGirl.create(:resource_action, :action => "Provision", :dialog => @dialog) - @dialog.reload - expect { @dialog.destroy } + dialog = FactoryGirl.create(:dialog) + FactoryGirl.create(:resource_action, :action => "Provision", :dialog => dialog) + expect { dialog.destroy } .to raise_error(RuntimeError, /Dialog cannot be deleted.*connected to other components/) expect(Dialog.count).to eq(1) end