foreman_datacenter 0.1.45 → 0.1.46
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/stylesheets/foreman_datacenter/device_roles.css +31 -0
- data/app/controllers/foreman_datacenter/comments_controller.rb +2 -2
- data/app/helpers/foreman_datacenter/application_helper.rb +26 -0
- data/app/models/foreman_datacenter/rack.rb +4 -0
- data/app/views/foreman_datacenter/comments/_comments.html.erb +1 -1
- data/app/views/foreman_datacenter/comments/create.html.erb +2 -0
- data/app/views/foreman_datacenter/comments/index.html.erb +9 -0
- data/app/views/foreman_datacenter/console_ports/index.html.erb +1 -1
- data/app/views/foreman_datacenter/device_interface_connections/index.html.erb +1 -1
- data/app/views/foreman_datacenter/device_roles/index.html.erb +2 -3
- data/app/views/foreman_datacenter/device_roles/show.html.erb +2 -2
- data/app/views/foreman_datacenter/device_roles/welcome.html.erb +13 -0
- data/app/views/foreman_datacenter/device_types/index.html.erb +2 -3
- data/app/views/foreman_datacenter/device_types/show.html.erb +9 -9
- data/app/views/foreman_datacenter/device_types/welcome.html.erb +13 -0
- data/app/views/foreman_datacenter/devices/index.html.erb +1 -1
- data/app/views/foreman_datacenter/devices/inventory.html.erb +2 -2
- data/app/views/foreman_datacenter/devices/show.html.erb +7 -7
- data/app/views/foreman_datacenter/devices/welcome.html.erb +13 -0
- data/app/views/foreman_datacenter/manufacturers/index.html.erb +2 -3
- data/app/views/foreman_datacenter/manufacturers/show.html.erb +2 -2
- data/app/views/foreman_datacenter/manufacturers/welcome.html.erb +13 -0
- data/app/views/foreman_datacenter/platforms/index.html.erb +2 -3
- data/app/views/foreman_datacenter/platforms/show.html.erb +2 -2
- data/app/views/foreman_datacenter/platforms/welcome.html.erb +13 -0
- data/app/views/foreman_datacenter/power_ports/index.html.erb +1 -1
- data/app/views/foreman_datacenter/rack_groups/index.html.erb +2 -3
- data/app/views/foreman_datacenter/rack_groups/show.html.erb +2 -2
- data/app/views/foreman_datacenter/rack_groups/welcome.html.erb +13 -0
- data/app/views/foreman_datacenter/racks/_device_position.html.erb +24 -27
- data/app/views/foreman_datacenter/racks/_unpositioned_devices.html.erb +20 -0
- data/app/views/foreman_datacenter/racks/index.html.erb +2 -3
- data/app/views/foreman_datacenter/racks/show.html.erb +12 -3
- data/app/views/foreman_datacenter/racks/welcome.html.erb +13 -0
- data/app/views/foreman_datacenter/sites/index.html.erb +2 -3
- data/app/views/foreman_datacenter/sites/show.html.erb +3 -3
- data/app/views/foreman_datacenter/sites/welcome.html.erb +13 -0
- data/app/views/hosts/import_to_device.html.erb +1 -1
- data/db/migrate/20160727161914_create_sites.rb +1 -1
- data/db/migrate/20160728123353_create_rack_groups.rb +1 -1
- data/db/migrate/20160728143149_create_racks.rb +1 -1
- data/db/migrate/20160728161636_create_platforms.rb +1 -1
- data/db/migrate/20160728162635_create_device_roles.rb +1 -1
- data/db/migrate/20160728163815_create_manufacturers.rb +1 -1
- data/db/migrate/20160728164858_create_device_types.rb +1 -1
- data/db/migrate/20160728171422_create_devices.rb +1 -1
- data/db/migrate/20160728194401_create_device_interfaces.rb +1 -1
- data/db/migrate/20160728195242_create_device_interface_connections.rb +1 -1
- data/db/migrate/20160804104103_create_interface_templates.rb +1 -1
- data/db/migrate/20160804142618_create_console_port_templates.rb +1 -1
- data/db/migrate/20160804164301_create_power_port_templates.rb +1 -1
- data/db/migrate/20160805080626_create_console_server_port_templates.rb +1 -1
- data/db/migrate/20160805084726_create_power_outlet_templates.rb +1 -1
- data/db/migrate/20160805100411_create_device_bay_templates.rb +1 -1
- data/db/migrate/20160809091611_create_device_bays.rb +1 -1
- data/db/migrate/20160809103211_create_power_outlets.rb +1 -1
- data/db/migrate/20160809104325_create_power_ports.rb +1 -1
- data/db/migrate/20160809112815_create_console_server_ports.rb +1 -1
- data/db/migrate/20160809113846_create_console_ports.rb +1 -1
- data/db/migrate/20160816224805_create_device_modules.rb +1 -1
- data/db/migrate/20160824212010_add_host_ref_to_devices.rb +1 -1
- data/db/migrate/20160828200938_add_ip_address_to_device_interfaces.rb +1 -1
- data/db/migrate/20160905211522_create_management_devices.rb +1 -1
- data/db/migrate/20160906205605_rename_field_in_management_devices.rb +1 -1
- data/db/migrate/20160909205537_add_name_index_to_racks.rb +1 -1
- data/db/migrate/20160920221011_remove_index_from_devices.rb +1 -1
- data/db/migrate/20170824122025_add_side_to_device.rb +1 -1
- data/db/migrate/20170918202630_add_racksize_to_device.rb +1 -1
- data/db/migrate/20170922110137_create_comments.rb +2 -2
- data/db/migrate/20170922174725_renaming_comments.rb +1 -1
- data/db/migrate/20170924194247_rename_device_comments_column.rb +1 -1
- data/db/migrate/20170929101032_add_parent_id_to_comments.rb +1 -1
- data/db/migrate/20171001130802_fix_parent_id_column_in_comments.rb +1 -1
- data/db/migrate/20171004221349_add_user_id_to_comments.rb +1 -1
- data/lib/foreman_datacenter/engine.rb +1 -1
- data/lib/foreman_datacenter/version.rb +1 -1
- data/lib/tasks/test_tasks.rake +13 -0
- data/test/controllers/foreman_datacenter/rack_groups_contoller_test.rb +91 -0
- data/test/controllers/foreman_datacenter/racks_contoller_test.rb +91 -0
- data/test/controllers/foreman_datacenter/sites_contoller_test.rb +91 -0
- data/test/fixtures/foreman_datacenter/rack_groups.yml +11 -0
- data/test/fixtures/foreman_datacenter/racks.yml +19 -0
- data/test/fixtures/foreman_datacenter/sites.yml +19 -0
- data/test/integration/foreman_datacenter/rack_group_test.rb +25 -0
- data/test/integration/foreman_datacenter/rack_test.rb +25 -0
- data/test/integration/foreman_datacenter/site_test.rb +29 -0
- metadata +34 -2
@@ -1,4 +1,4 @@
|
|
1
|
-
class CreateComments < ActiveRecord::Migration
|
1
|
+
class CreateComments < ActiveRecord::Migration[4.2]
|
2
2
|
def change
|
3
3
|
create_table :comments do |t|
|
4
4
|
t.text :content
|
@@ -6,6 +6,6 @@ class CreateComments < ActiveRecord::Migration
|
|
6
6
|
|
7
7
|
t.timestamps null: false
|
8
8
|
end
|
9
|
-
add_index :comments, [:commentable_id, :commentable_type]
|
9
|
+
add_index :comments, [:commentable_id, :commentable_type], name: 'comments_index'
|
10
10
|
end
|
11
11
|
end
|
@@ -413,7 +413,7 @@ module ForemanDatacenter
|
|
413
413
|
role "Datacenter Manager", MANAGER
|
414
414
|
add_all_permissions_to_default_roles
|
415
415
|
|
416
|
-
sub_menu :top_menu, :datacenter, :after=> :infrastructure_menu do
|
416
|
+
sub_menu :top_menu, :datacenter, :after=> :infrastructure_menu, :icon => 'pficon pficon-enterprise' do
|
417
417
|
menu :top_menu, :sites, :url_hash => { controller: :'foreman_datacenter/sites', action: :index }
|
418
418
|
divider :top_menu, :parent => :datacenter, :after => :sites, :caption => 'Racks'
|
419
419
|
menu :top_menu, :racks, :url_hash => { controller: :'foreman_datacenter/racks', action: :index }
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# Tasks
|
2
|
+
namespace :foreman_datacenter do
|
3
|
+
namespace :example do
|
4
|
+
desc 'Example Task'
|
5
|
+
task task: :environment do
|
6
|
+
Comment.create({content: "TEST ++++++++++++++++++++"})
|
7
|
+
ForemanDatacenter::Comment.create({content: "TEST ______________________"})
|
8
|
+
Comment.create(content: "TEST ################")
|
9
|
+
ForemanDatacenter::Comment.create(content: "TEST @@@@@@@@@@@@@@@@@@@@")
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
@@ -0,0 +1,91 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module ForemanDatacenter
|
4
|
+
class RackGroupsControllerTest < ActionController::TestCase
|
5
|
+
setup do
|
6
|
+
@model = RackGroup.first
|
7
|
+
end
|
8
|
+
|
9
|
+
basic_index_test
|
10
|
+
basic_new_test
|
11
|
+
basic_edit_test
|
12
|
+
basic_pagination_per_page_test
|
13
|
+
basic_pagination_rendered_test
|
14
|
+
|
15
|
+
test 'test_new_submit_button_id' do
|
16
|
+
get :new, {}, set_session_user
|
17
|
+
assert_select "[data-id='aid_create_foreman_datacenter_rack_group']"
|
18
|
+
end
|
19
|
+
|
20
|
+
test 'test_new_cancel_button_id' do
|
21
|
+
get :new, {}, set_session_user
|
22
|
+
assert_select "[data-id='aid_datacenter_rack_groups']"
|
23
|
+
end
|
24
|
+
|
25
|
+
test 'test_create_invalid' do
|
26
|
+
RackGroup.any_instance.stubs(:valid?).returns(false)
|
27
|
+
post :create, {:rack_group => {:name => nil, :site_id => nil}}, set_session_user
|
28
|
+
assert_template 'new'
|
29
|
+
end
|
30
|
+
|
31
|
+
test 'test_create_valid' do
|
32
|
+
RackGroup.any_instance.stubs(:valid?).returns(true)
|
33
|
+
post :create, {:rack_group => {:name => 'test rack_group', :site_id => Site.first.id}}, set_session_user
|
34
|
+
assert_redirected_to rack_groups_url
|
35
|
+
end
|
36
|
+
|
37
|
+
test 'test_edit_submit_button_id' do
|
38
|
+
get :edit, {:id => RackGroup.first}, set_session_user
|
39
|
+
assert_select "[data-id='aid_update_foreman_datacenter_rack_group']"
|
40
|
+
end
|
41
|
+
|
42
|
+
test 'test_update_invalid' do
|
43
|
+
RackGroup.any_instance.stubs(:valid?).returns(false)
|
44
|
+
put :update, {:id => RackGroup.first.to_param, :rack_group => {:name => "3243"}}, set_session_user
|
45
|
+
assert_template 'edit'
|
46
|
+
end
|
47
|
+
|
48
|
+
test 'test_update_valid' do
|
49
|
+
Site.any_instance.stubs(:valid?).returns(true)
|
50
|
+
put :update, {:id => RackGroup.first.to_param, :rack_group => {:name => RackGroup.first.name}}, set_session_user
|
51
|
+
assert_redirected_to rack_groups_url
|
52
|
+
end
|
53
|
+
|
54
|
+
test 'test_destroy' do
|
55
|
+
rack_group = RackGroup.first
|
56
|
+
delete :destroy, {:id => rack_group}, set_session_user
|
57
|
+
assert_redirected_to rack_groups_url
|
58
|
+
assert !RackGroup.exists?(rack_group.id)
|
59
|
+
end
|
60
|
+
|
61
|
+
test '403 response contains missing permissions' do
|
62
|
+
setup_user
|
63
|
+
get :edit, { :id => RackGroup.first.id }, {:user => users(:one).id, :expires_at => 5.minutes.from_now}
|
64
|
+
assert_response :forbidden
|
65
|
+
assert_includes @response.body, 'edit_rack_groups'
|
66
|
+
end
|
67
|
+
|
68
|
+
def setup_user
|
69
|
+
@request.session[:user] = users(:one).id
|
70
|
+
users(:one).roles = [Role.default, Role.find_by_name('Viewer')]
|
71
|
+
end
|
72
|
+
|
73
|
+
test 'user_with_viewer_rights_should_fail_to_edit_a_rack_group' do
|
74
|
+
setup_user
|
75
|
+
get :edit, {:id => RackGroup.first.id}
|
76
|
+
assert_response :forbidden
|
77
|
+
end
|
78
|
+
|
79
|
+
test 'user_with_viewer_rights_should_succeed_in_viewing_rack_groups' do
|
80
|
+
setup_user
|
81
|
+
get :index
|
82
|
+
assert_response :success
|
83
|
+
end
|
84
|
+
|
85
|
+
test 'user_with_viewer_rights_should_succeed_in_viewing_rack_group' do
|
86
|
+
setup_user
|
87
|
+
get :show
|
88
|
+
assert_response :success
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
@@ -0,0 +1,91 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module ForemanDatacenter
|
4
|
+
class RacksControllerTest < ActionController::TestCase
|
5
|
+
setup do
|
6
|
+
@model = ForemanDatacenter::Rack.first
|
7
|
+
end
|
8
|
+
|
9
|
+
basic_index_test
|
10
|
+
basic_new_test
|
11
|
+
basic_edit_test
|
12
|
+
basic_pagination_per_page_test
|
13
|
+
basic_pagination_rendered_test
|
14
|
+
|
15
|
+
test 'test_new_submit_button_id' do
|
16
|
+
get :new, {}, set_session_user
|
17
|
+
assert_select "[data-id='aid_create_foreman_datacenter_racks']"
|
18
|
+
end
|
19
|
+
|
20
|
+
test 'test_new_cancel_button_id' do
|
21
|
+
get :new, {}, set_session_user
|
22
|
+
assert_select "[data-id='aid_datacenter_racks']"
|
23
|
+
end
|
24
|
+
|
25
|
+
test 'test_create_invalid' do
|
26
|
+
ForemanDatacenter::Rack.any_instance.stubs(:valid?).returns(false)
|
27
|
+
post :create, {:rack => {:name => nil, :site => nil, :height => nil}}, set_session_user
|
28
|
+
assert_template 'new'
|
29
|
+
end
|
30
|
+
|
31
|
+
test 'test_create_valid' do
|
32
|
+
ForemanDatacenter::Rack.any_instance.stubs(:valid?).returns(true)
|
33
|
+
post :create, {:rack => {:name => 'test rack', :height => '42', :site => Site.first.id }}, set_session_user
|
34
|
+
assert_redirected_to racks_url
|
35
|
+
end
|
36
|
+
|
37
|
+
test 'test_edit_submit_button_id' do
|
38
|
+
get :edit, {:id => ForemanDatacenter::Rack.first}, set_session_user
|
39
|
+
assert_select "[data-id='aid_update_foreman_datacenter_rack']"
|
40
|
+
end
|
41
|
+
|
42
|
+
test 'test_update_invalid' do
|
43
|
+
ForemanDatacenter::Rack.any_instance.stubs(:valid?).returns(false)
|
44
|
+
put :update, {:id => ForemanDatacenter::Rack.first.to_param, :rack => {:name => "3243"}}, set_session_user
|
45
|
+
assert_template 'edit'
|
46
|
+
end
|
47
|
+
|
48
|
+
test 'test_update_valid' do
|
49
|
+
ForemanDatacenter::Rack.any_instance.stubs(:valid?).returns(true)
|
50
|
+
put :update, {:id => ForemanDatacenter::Rack.first.to_param, :rack => {:name => ForemanDatacenter::Rack.first.name}}, set_session_user
|
51
|
+
assert_redirected_to racks_url
|
52
|
+
end
|
53
|
+
|
54
|
+
test 'test_destroy' do
|
55
|
+
rack = ForemanDatacenter::Rack.first
|
56
|
+
delete :destroy, {:id => rack}, set_session_user
|
57
|
+
assert_redirected_to racks_url
|
58
|
+
assert !ForemanDatacenter::Rack.exists?(rack.id)
|
59
|
+
end
|
60
|
+
|
61
|
+
test '403 response contains missing permissions' do
|
62
|
+
setup_user
|
63
|
+
get :edit, { :id => ForemanDatacenter::Rack.first.id }, {:user => users(:one).id, :expires_at => 5.minutes.from_now}
|
64
|
+
assert_response :forbidden
|
65
|
+
assert_includes @response.body, 'edit_racks'
|
66
|
+
end
|
67
|
+
|
68
|
+
def setup_user
|
69
|
+
@request.session[:user] = users(:one).id
|
70
|
+
users(:one).roles = [Role.default, Role.find_by_name('Viewer')]
|
71
|
+
end
|
72
|
+
|
73
|
+
test 'user_with_viewer_rights_should_fail_to_edit_a_rack' do
|
74
|
+
setup_user
|
75
|
+
get :edit, {:id => ForemanDatacenter::Rack.first.id}
|
76
|
+
assert_response :forbidden
|
77
|
+
end
|
78
|
+
|
79
|
+
test 'user_with_viewer_rights_should_succeed_in_viewing_racks' do
|
80
|
+
setup_user
|
81
|
+
get :index
|
82
|
+
assert_response :success
|
83
|
+
end
|
84
|
+
|
85
|
+
test 'user_with_viewer_rights_should_succeed_in_viewing_rack' do
|
86
|
+
setup_user
|
87
|
+
get :show
|
88
|
+
assert_response :success
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
@@ -0,0 +1,91 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module ForemanDatacenter
|
4
|
+
class SitesControllerTest < ActionController::TestCase
|
5
|
+
setup do
|
6
|
+
@model = ForemanDatacenter::Site.first
|
7
|
+
end
|
8
|
+
|
9
|
+
basic_index_test
|
10
|
+
basic_new_test
|
11
|
+
basic_edit_test
|
12
|
+
basic_pagination_per_page_test
|
13
|
+
basic_pagination_rendered_test
|
14
|
+
|
15
|
+
test 'test_new_submit_button_id' do
|
16
|
+
get :new, {}, set_session_user
|
17
|
+
assert_select "[data-id='aid_create_foreman_datacenter_sites']"
|
18
|
+
end
|
19
|
+
|
20
|
+
test 'test_new_cancel_button_id' do
|
21
|
+
get :new, {}, set_session_user
|
22
|
+
assert_select "[data-id='aid_datacenter_sites']"
|
23
|
+
end
|
24
|
+
|
25
|
+
test 'test_create_invalid' do
|
26
|
+
ForemanDatacenter::Site.any_instance.stubs(:valid?).returns(false)
|
27
|
+
post :create, {:site => {:name => nil}}, set_session_user
|
28
|
+
assert_template 'new'
|
29
|
+
end
|
30
|
+
|
31
|
+
test 'test_create_valid' do
|
32
|
+
ForemanDatacenter::Site.any_instance.stubs(:valid?).returns(true)
|
33
|
+
post :create, {:site => {:name => 'test site'}}, set_session_user
|
34
|
+
assert_redirected_to sites_url
|
35
|
+
end
|
36
|
+
|
37
|
+
test 'test_edit_submit_button_id' do
|
38
|
+
get :edit, {:id => ForemanDatacenter::Site.first}, set_session_user
|
39
|
+
assert_select "[data-id='aid_update_foreman_datacenter_site']"
|
40
|
+
end
|
41
|
+
|
42
|
+
test 'test_update_invalid' do
|
43
|
+
ForemanDatacenter::Site.any_instance.stubs(:valid?).returns(false)
|
44
|
+
put :update, {:id => ForemanDatacenter::Site.first.to_param, :site => {:name => "3243", :asn => "string"}}, set_session_user
|
45
|
+
assert_template 'edit'
|
46
|
+
end
|
47
|
+
|
48
|
+
test 'test_update_valid' do
|
49
|
+
ForemanDatacenter::Site.any_instance.stubs(:valid?).returns(true)
|
50
|
+
put :update, {:id => ForemanDatacenter::Site.first.to_param, :site => {:name => ForemanDatacenter::Site.first.name}}, set_session_user
|
51
|
+
assert_redirected_to sites_url
|
52
|
+
end
|
53
|
+
|
54
|
+
test 'test_destroy' do
|
55
|
+
site = ForemanDatacenter::Site.first
|
56
|
+
delete :destroy, {:id => site}, set_session_user
|
57
|
+
assert_redirected_to sites_url
|
58
|
+
assert !ForemanDatacenter::Site.exists?(site.id)
|
59
|
+
end
|
60
|
+
|
61
|
+
test '403 response contains missing permissions' do
|
62
|
+
setup_user
|
63
|
+
get :edit, { :id => ForemanDatacenter::Site.first.id }, {:user => users(:one).id, :expires_at => 5.minutes.from_now}
|
64
|
+
assert_response :forbidden
|
65
|
+
assert_includes @response.body, 'edit_sites'
|
66
|
+
end
|
67
|
+
|
68
|
+
def setup_user
|
69
|
+
@request.session[:user] = users(:one).id
|
70
|
+
users(:one).roles = [Role.default, Role.find_by_name('Viewer')]
|
71
|
+
end
|
72
|
+
|
73
|
+
test 'user_with_viewer_rights_should_fail_to_edit_a_site' do
|
74
|
+
setup_user
|
75
|
+
get :edit, {:id => ForemanDatacenter::Site.first.id}
|
76
|
+
assert_response :forbidden
|
77
|
+
end
|
78
|
+
|
79
|
+
test 'user_with_viewer_rights_should_succeed_in_viewing_sites' do
|
80
|
+
setup_user
|
81
|
+
get :index
|
82
|
+
assert_response :success
|
83
|
+
end
|
84
|
+
|
85
|
+
test 'user_with_viewer_rights_should_succeed_in_viewing_site' do
|
86
|
+
setup_user
|
87
|
+
get :show
|
88
|
+
assert_response :success
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
|
2
|
+
|
3
|
+
one:
|
4
|
+
id: 1
|
5
|
+
site_id: 1
|
6
|
+
rack_group_id: 1
|
7
|
+
name: Rack 1
|
8
|
+
facility: test facility
|
9
|
+
height: 42
|
10
|
+
comments: test comment
|
11
|
+
|
12
|
+
two:
|
13
|
+
id: 2
|
14
|
+
site_id: 2
|
15
|
+
rack_group_id: 2
|
16
|
+
name: Rack 2
|
17
|
+
facility: test facility
|
18
|
+
height: 42
|
19
|
+
comments: test comment
|