Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New #stub_user controller macro #10243

Merged
merged 4 commits into from
Aug 4, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ GlobalVars:
# Special Exclusions
#
AllCops:
TargetRubyVersion: 2.2
Exclude:
- gems/pending/VMwareWebService/wsdl41/vimws25MappingRegistry.rb
- db/schema.rb
Expand Down
4 changes: 2 additions & 2 deletions spec/controllers/application_controller/automate_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
describe MiqAeCustomizationController, "ApplicationController::Automate" do
context "#resolve" do
before(:each) do
set_user_privileges
stub_user(:features => :all)
@custom_button = FactoryGirl.create(:custom_button, :applies_to_class => "Host")
target_classes = {}
CustomButton.button_classes.each { |db| target_classes[db] = ui_lookup(:model => db) }
Expand Down Expand Up @@ -32,7 +32,7 @@
let(:custom_button) { FactoryGirl.create(:custom_button, :applies_to_class => "Host") }
let(:workspace) { double("MiqAeEngine::MiqAeWorkspaceRuntime", :root => options) }
before(:each) do
set_user_privileges
stub_user(:features => :all)
end

def resolve_hash(button)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@
describe HostController do
context "#show_association" do
before(:each) do
set_user_privileges
stub_user(:features => :all)
EvmSpecHelper.create_guid_miq_server_zone
@host = FactoryGirl.create(:host)
@guest_application = FactoryGirl.create(:guest_application, :name => "foo", :host_id => @host.id)
Expand Down
6 changes: 3 additions & 3 deletions spec/controllers/application_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
it "sets Processors details successfully" do
host_hardware = FactoryGirl.create(:hardware, :cpu_sockets => 2, :cpu_cores_per_socket => 4, :cpu_total_cores => 8)
host = FactoryGirl.create(:host, :hardware => host_hardware)
set_user_privileges
stub_user(:features => :all)

controller.send(:set_config, host)
expect(response.status).to eq(200)
Expand All @@ -119,7 +119,7 @@
disk = FactoryGirl.create(:disk, :filename => nil, :controller_type => nil, :device_type => 'disk', :mode => "foo")
host_hardware = FactoryGirl.create(:hardware, :cpu_sockets => 2, :cpu_cores_per_socket => 4, :cpu_total_cores => 8, :disks => [disk])
host = FactoryGirl.create(:host, :hardware => host_hardware)
set_user_privileges
stub_user(:features => :all)

controller.send(:set_config, host)
expect(response.status).to eq(200)
Expand All @@ -130,7 +130,7 @@
disk = FactoryGirl.create(:disk, :controller_type => nil)
host_hardware = FactoryGirl.create(:hardware, :cpu_sockets => 2, :cpu_cores_per_socket => 4, :cpu_total_cores => 8, :disks => [disk])
host = FactoryGirl.create(:host, :hardware => host_hardware)
set_user_privileges
stub_user(:features => :all)

controller.send(:set_config, host)
expect(response.status).to eq(200)
Expand Down
5 changes: 2 additions & 3 deletions spec/controllers/auth_key_pair_cloud_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
describe AuthKeyPairCloudController do
context "#button" do
before(:each) do
set_user_privileges
stub_user(:features => :all)
EvmSpecHelper.create_guid_miq_server_zone
end
end

context "#tags_edit" do
let!(:user) { stub_user(:features => :all) }
before(:each) do
EvmSpecHelper.create_guid_miq_server_zone
@kp = FactoryGirl.create(:auth_key_pair_cloud, :name => "auth-key-pair-cloud-01")
user = FactoryGirl.create(:user, :userid => 'testuser')
set_user_privileges user
allow(@kp).to receive(:tagged_with).with(:cat => user.userid).and_return("my tags")
classification = FactoryGirl.create(:classification, :name => "department", :description => "Department")
@tag1 = FactoryGirl.create(:classification_tag,
Expand Down
2 changes: 1 addition & 1 deletion spec/controllers/catalog_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
end

before(:each) do
set_user_privileges user
stub_user(:features => :all)
controller.instance_variable_set(:@settings, {})
allow_any_instance_of(ApplicationController).to receive(:fetch_path)
end
Expand Down
2 changes: 1 addition & 1 deletion spec/controllers/chargeback_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
describe ChargebackController do
before { set_user_privileges }
before { stub_user(:features => :all) }

context "returns current rate assignments or set them to blank if category/tag is deleted" do
let(:category) { FactoryGirl.create(:classification) }
Expand Down
2 changes: 1 addition & 1 deletion spec/controllers/cloud_network_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
describe CloudNetworkController do
render_views
before :each do
set_user_privileges
stub_user(:features => :all)
setup_zone
end

Expand Down
3 changes: 1 addition & 2 deletions spec/controllers/cloud_object_store_container_spec.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
describe CloudObjectStoreContainerController do
context "#tags_edit" do
let!(:user) { stub_user(:features => :all) }
before(:each) do
EvmSpecHelper.create_guid_miq_server_zone
@container = FactoryGirl.create(:cloud_object_store_container, :name => "cloud-object-store-container-01")
user = FactoryGirl.create(:user, :userid => 'testuser')
set_user_privileges user
allow(@container).to receive(:tagged_with).with(:cat => user.userid).and_return("my tags")
classification = FactoryGirl.create(:classification, :name => "department", :description => "D epartment")
@tag1 = FactoryGirl.create(:classification_tag,
Expand Down
3 changes: 1 addition & 2 deletions spec/controllers/cloud_object_store_object_spec.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
describe CloudObjectStoreObjectController do
context "#tags_edit" do
let!(:user) { stub_user(:features => :all) }
before(:each) do
EvmSpecHelper.create_guid_miq_server_zone
@object = FactoryGirl.create(:cloud_object_store_object, :name => "cloud-object-store-container-01")
user = FactoryGirl.create(:user, :userid => 'testuser')
set_user_privileges user
allow(@object).to receive(:tagged_with).with(:cat => user.userid).and_return("my tags")
classification = FactoryGirl.create(:classification, :name => "department", :description => "D epartment")
@tag1 = FactoryGirl.create(:classification_tag,
Expand Down
2 changes: 1 addition & 1 deletion spec/controllers/cloud_subnet_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
describe CloudSubnetController do
render_views
before :each do
set_user_privileges
stub_user(:features => :all)
setup_zone
end

Expand Down
5 changes: 2 additions & 3 deletions spec/controllers/cloud_tenant_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
describe CloudTenantController do
context "#button" do
before(:each) do
set_user_privileges
stub_user(:features => :all)
EvmSpecHelper.create_guid_miq_server_zone

ApplicationController.handle_exceptions = true
Expand All @@ -21,11 +21,10 @@
end

context "#tags_edit" do
let!(:user) { stub_user(:features => :all) }
before(:each) do
EvmSpecHelper.create_guid_miq_server_zone
@ct = FactoryGirl.create(:cloud_tenant, :name => "cloud-tenant-01")
user = FactoryGirl.create(:user, :userid => 'testuser')
set_user_privileges user
allow(@ct).to receive(:tagged_with).with(:cat => user.userid).and_return("my tags")
classification = FactoryGirl.create(:classification, :name => "department", :description => "Department")
@tag1 = FactoryGirl.create(:classification_tag,
Expand Down
3 changes: 1 addition & 2 deletions spec/controllers/cloud_volume_snapshot_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
describe CloudVolumeSnapshotController do
context "#tags_edit" do
let!(:user) { stub_user(:features => :all) }
before(:each) do
EvmSpecHelper.create_guid_miq_server_zone
@snapshot = FactoryGirl.create(:cloud_volume_snapshot, :name => "cloud-volume-snapshot-01")
user = FactoryGirl.create(:user, :userid => 'testuser')
set_user_privileges user
allow(@snapshot).to receive(:tagged_with).with(:cat => user.userid).and_return("my tags")
classification = FactoryGirl.create(:classification, :name => "department", :description => "D epartment")
@tag1 = FactoryGirl.create(:classification_tag,
Expand Down
6 changes: 2 additions & 4 deletions spec/controllers/configuration_job_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
include CompressedIds

describe ConfigurationJobController do
let(:user) { FactoryGirl.create(:user_with_group) }
let!(:user) { stub_user(:features => :all) }

before(:each) do
set_user_privileges user
EvmSpecHelper.create_guid_miq_server_zone
end

Expand All @@ -28,11 +27,10 @@
end

context "#tags_edit" do
let!(:user) { stub_user(:features => :all) }
before(:each) do
EvmSpecHelper.create_guid_miq_server_zone
@cj = FactoryGirl.create(:ansible_tower_job, :name => "testJob")
user = FactoryGirl.create(:user, :userid => 'testuser')
set_user_privileges user
allow(@cj).to receive(:tagged_with).with(:cat => user.userid).and_return("my tags")
classification = FactoryGirl.create(:classification, :name => "department", :description => "Department")
@tag1 = FactoryGirl.create(:classification_tag,
Expand Down
2 changes: 1 addition & 1 deletion spec/controllers/container_build_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
describe ContainerBuildController do
render_views
before(:each) do
set_user_privileges
stub_user(:features => :all)
end

it "renders index" do
Expand Down
5 changes: 2 additions & 3 deletions spec/controllers/container_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,16 @@
server = EvmSpecHelper.local_miq_server
allow(MiqServer).to receive(:my_server).and_return(server)
allow(MiqServer).to receive(:my_zone).and_return("default")
set_user_privileges
stub_user(:features => :all)
end

render_views

context "#tags_edit" do
let!(:user) { stub_user(:features => :all) }
before(:each) do
EvmSpecHelper.create_guid_miq_server_zone
@ct = FactoryGirl.create(:container, :name => "container-01")
user = FactoryGirl.create(:user, :userid => 'testuser')
set_user_privileges user
allow(@ct).to receive(:tagged_with).with(:cat => user.userid).and_return("my tags")
classification = FactoryGirl.create(:classification, :name => "department", :description => "Department")

Expand Down
2 changes: 1 addition & 1 deletion spec/controllers/container_dashboard_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
describe ContainerDashboardController do
render_views
before(:each) do
set_user_privileges
stub_user(:features => :all)
end

it "renders index" do
Expand Down
2 changes: 1 addition & 1 deletion spec/controllers/container_group_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
describe ContainerGroupController do
render_views
before(:each) do
set_user_privileges
stub_user(:features => :all)
end

it "renders index" do
Expand Down
2 changes: 1 addition & 1 deletion spec/controllers/container_image_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
describe ContainerImageController do
render_views
before(:each) do
set_user_privileges
stub_user(:features => :all)
end

it "when Smart Analysis is pressed" do
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
describe ContainerImageRegistryController do
render_views
before(:each) do
set_user_privileges
stub_user(:features => :all)
end

it "renders index" do
Expand Down
2 changes: 1 addition & 1 deletion spec/controllers/container_node_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
describe ContainerNodeController do
render_views
before(:each) do
set_user_privileges
stub_user(:features => :all)
end

it "renders index" do
Expand Down
2 changes: 1 addition & 1 deletion spec/controllers/container_project_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
describe ContainerProjectController do
render_views
before(:each) do
set_user_privileges
stub_user(:features => :all)
end

it "renders index" do
Expand Down
2 changes: 1 addition & 1 deletion spec/controllers/container_replicator_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
describe ContainerReplicatorController do
render_views
before(:each) do
set_user_privileges
stub_user(:features => :all)
end

it "renders index" do
Expand Down
2 changes: 1 addition & 1 deletion spec/controllers/container_route_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
describe ContainerRouteController do
render_views
before(:each) do
set_user_privileges
stub_user(:features => :all)
end

it "renders index" do
Expand Down
2 changes: 1 addition & 1 deletion spec/controllers/container_service_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
describe ContainerServiceController do
render_views
before(:each) do
set_user_privileges
stub_user(:features => :all)
end

it "renders index" do
Expand Down
2 changes: 1 addition & 1 deletion spec/controllers/container_topology_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
describe ContainerTopologyController do
render_views
before(:each) do
set_user_privileges
stub_user(:features => :all)
end

it "renders index" do
Expand Down
18 changes: 9 additions & 9 deletions spec/controllers/ems_common_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

context "#new" do
before do
set_user_privileges
stub_user(:features => :all)
allow(controller).to receive(:drop_breadcrumb)
end

Expand All @@ -53,7 +53,7 @@

context "#form_field_changed" do
before :each do
set_user_privileges
stub_user(:features => :all)
end

it "form_div should be updated when server type is sent up" do
Expand All @@ -74,7 +74,7 @@
context "#set_record_vars" do
context "strip leading/trailing whitespace from hostname/ipaddress" do
after :each do
set_user_privileges
stub_user(:features => :all)
controller.instance_variable_set(:@edit, :new => {:name => 'EMS 1',
:emstype => @type,
:hostname => ' 10.10.10.10 ',
Expand Down Expand Up @@ -127,7 +127,7 @@

context "#button" do
before(:each) do
set_user_privileges
stub_user(:features => :all)
EvmSpecHelper.create_guid_miq_server_zone
end

Expand All @@ -152,7 +152,7 @@

context "download pdf file" do
before :each do
set_user_privileges
stub_user(:features => :all)
allow(PdfGenerator).to receive(:pdf_from_string).with('', 'pdf_summary').and_return("")
get :show, :id => ems_openstack.id, :display => "download_pdf"
end
Expand Down Expand Up @@ -180,7 +180,7 @@
context "#update" do
context "updates provider with new token" do
after :each do
set_user_privileges
stub_user(:features => :all)
controller.instance_variable_set(:@_params, :name => 'EMS 2',
:default_hostname => '10.10.10.11',
:default_api_port => '5000',
Expand Down Expand Up @@ -212,7 +212,7 @@

context "#button" do
before(:each) do
set_user_privileges
stub_user(:features => :all)
EvmSpecHelper.create_guid_miq_server_zone
end

Expand Down Expand Up @@ -248,7 +248,7 @@

context "download pdf file" do
before :each do
set_user_privileges
stub_user(:features => :all)
allow(PdfGenerator).to receive(:pdf_from_string).with('', 'pdf_summary').and_return("")
get :show, :id => ems_kubernetes_container.id, :display => "download_pdf"
end
Expand Down Expand Up @@ -297,7 +297,7 @@

context "download pdf file" do
before :each do
set_user_privileges
stub_user(:features => :all)
allow(PdfGenerator).to receive(:pdf_from_string).with('', 'pdf_summary').and_return("")
get :show, :id => ems_openstack_infra.id, :display => "download_pdf"
end
Expand Down