23 |
Puppet Dashboard encountered an error.
24 |
Something went wrong, and Puppet Dashboard was unable to render the requested page. Please contact your site’s help desk or systems administrator; if that happens to be you, please check Dashboard’s logs for more information.
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/lib/has_parameters.rb:
--------------------------------------------------------------------------------
1 | module HasParameters
2 | def self.included(klass)
3 | klass.extend(ClassMethods)
4 | end
5 |
6 | module ClassMethods
7 | def has_parameters(options={})
8 |
9 | include HasParameters::InstanceMethods
10 |
11 | has_many :parameters, {:as => :parameterable, :dependent => :destroy}.merge(options) do
12 | def to_hash
13 | Hash[*to_a.map{|p| [p.key, p.value]}.flatten]
14 | end
15 | end
16 | end
17 | end
18 |
19 | module InstanceMethods
20 | def parameter_attributes=(values)
21 | raise NodeClassificationDisabledError.new unless SETTINGS.use_external_node_classification
22 | new_parameters = values.reject{|v| v[:key].blank? && v[:value].blank?}.map do |hash|
23 | parameter = parameters.find_or_initialize_by(key: hash[:key])
24 | parameter.value = hash[:value]
25 | parameter.save
26 | parameter
27 | end
28 | self.parameters = new_parameters
29 | end
30 | end
31 | end
32 |
33 | ActiveRecord::Base.send(:include, HasParameters)
34 |
--------------------------------------------------------------------------------
/app/views/shared/_class_parameter_conflicts_table.html.haml:
--------------------------------------------------------------------------------
1 | %table.inspector{:style => 'margin-top: 1.5em;'}
2 | %thead
3 | %tr
4 | %th{:scope => :col} Class
5 | %th{:scope => :col} Parameter
6 | %th{:scope => :col} Value
7 | %th{:scope => :col} Source
8 | %tbody
9 | - conflicts.keys.sort_by { |node_class| node_class.name }.each do |node_class|
10 | %tr
11 | - class_srcs_cnt = 0
12 | - conflicts[node_class].each { |param| param[:sources].each { |item| class_srcs_cnt += 1 }}
13 | %td{:rowspan => class_srcs_cnt}
14 | %strong= h(node_class.name)
15 | - first_param = true
16 | - conflicts[node_class].sort_by{ |param| param[:name] }.each do |param|
17 | - if first_param
18 | - first_param = false
19 | = render 'shared/parameters_part1', :param => param, :node_class_id => node_class.id, :links => false
20 | - else
21 | %tr
22 | = render 'shared/parameters_part1', :param => param, :node_class_id => node_class.id, :links => false
23 |
--------------------------------------------------------------------------------
/spec/controllers/application_controller_spec.rb:
--------------------------------------------------------------------------------
1 | require 'spec_helper'
2 |
3 | describe ApplicationController, :type => :controller do
4 | before do
5 | class ApplicationController
6 | def generic_action
7 | @time_zone = Time.zone
8 | end
9 | end
10 |
11 | Rails.application.routes.draw do |map|
12 | get 'application/generic_action'
13 | end
14 | end
15 |
16 | after do
17 | Rails.application.reload_routes!
18 | end
19 |
20 | before :each do
21 | Time.zone = 'UTC'
22 | end
23 |
24 | it "should set the timezone to whatever is in SETTINGS.time_zone" do
25 | SETTINGS.stubs(:time_zone).returns('Pacific Time (US & Canada)')
26 | head :generic_action
27 | Time.zone.name.should == "Pacific Time (US & Canada)"
28 | end
29 |
30 | it "should raise if SETTINGS.time_zone is set to something invalid" do
31 | SETTINGS.stubs(:time_zone).returns('invalid')
32 | lambda { head :generic_action }.should raise_error StandardError, 'Invalid timezone "invalid"'
33 | Time.zone.name.should == "UTC"
34 | end
35 | end
36 |
--------------------------------------------------------------------------------
/app/views/statuses/_run_failure.html.haml:
--------------------------------------------------------------------------------
1 | - nodes = local_assigns[:nodes]
2 | - node = local_assigns[:node]
3 | - args = {}
4 | - args[:node] = node if node
5 | - args[:nodes] = nodes if nodes
6 | - statuses = Status.within_daily_run_history(args)
7 |
8 | %h3 Daily run status
9 | %p.legend Number and status of runs during the