Revision 890e765e
Added by Daniel Lobato Garcia almost 9 years ago
app/controllers/api/v2/permissions_controller.rb | ||
---|---|---|
type = params[:resource_type].blank? ? nil : params[:resource_type]
|
||
name = params[:name].blank? ? nil : params[:name]
|
||
if type
|
||
@permissions = Permission.find_all_by_resource_type(type)
|
||
@permissions = Permission.where(:resource_type => type)
|
||
elsif name
|
||
@permissions = Permission.find_all_by_name(name)
|
||
@permissions = Permission.where(:name => name)
|
||
else
|
||
@permissions = Permission.all
|
||
end
|
app/controllers/fact_values_controller.rb | ||
---|---|---|
conds = (original_search_parameter || '').split(/AND|OR/i)
|
||
conds = conds.flatten.reject { |c| c.include?('host') }
|
||
|
||
if (parent = params[:parent_fact]).present? && (@parent = ::FactName.find_all_by_name(parent)).present?
|
||
if (parent = params[:parent_fact]).present? && (@parent = ::FactName.where(:name => parent)).present?
|
||
values = values.with_fact_parent_id(@parent.map(&:id))
|
||
@parent = @parent.first
|
||
elsif conds.present?
|
app/controllers/permissions_controller.rb | ||
---|---|---|
|
||
def index
|
||
type = params[:resource_type].blank? ? nil : params[:resource_type]
|
||
@permissions = Permission.find_all_by_resource_type(type)
|
||
@permissions = Permission.where(:resource_type => type)
|
||
@search_path = search_path(type)
|
||
@granular = granular?(type)
|
||
|
app/helpers/ancestry_helper.rb | ||
---|---|---|
link_to_if_authorized(
|
||
content_tag(:span,
|
||
content_tag(:span, nesting, :class => 'gray nbsp') + name, options),
|
||
send("hash_for_edit_#{obj.class.name.tableize.singularize}_path", obj).merge(:auth_object => obj, :authorizer => authorizer))
|
||
send("hash_for_edit_#{obj.class.name.to_s.tableize.singularize}_path", obj).merge(:auth_object => obj, :authorizer => authorizer))
|
||
end
|
||
end
|
db/seeds.d/07-provisioning_templates.rb | ||
---|---|---|
# Find known operating systems for associations
|
||
os_junos = Operatingsystem.find_all_by_type "Junos" || Operatingsystem.where("name LIKE ?", "junos")
|
||
os_solaris = Operatingsystem.find_all_by_type "Solaris"
|
||
os_suse = Operatingsystem.find_all_by_type "Suse" || Operatingsystem.where("name LIKE ?", "suse")
|
||
os_windows = Operatingsystem.find_all_by_type "Windows"
|
||
os_junos = Operatingsystem.where(:type => "Junos") || Operatingsystem.where("name LIKE ?", "junos")
|
||
os_solaris = Operatingsystem.where(:type => "Solaris")
|
||
os_suse = Operatingsystem.where(:type => "Suse") || Operatingsystem.where("name LIKE ?", "suse")
|
||
os_windows = Operatingsystem.where(:type => "Windows")
|
||
|
||
# Template kinds
|
||
kinds = {}
|
||
[:PXELinux, :PXEGrub, :iPXE, :provision, :finish, :script, :user_data, :ZTP, :POAP].each do |type|
|
||
kinds[type] = TemplateKind.find_by_name(type)
|
||
kinds[type] ||= TemplateKind.create :name => type
|
||
kinds[type] ||= TemplateKind.create(:name => type)
|
||
raise "Unable to create template kind: #{format_errors kinds[type]}" if kinds[type].nil? || kinds[type].errors.any?
|
||
end
|
||
|
||
... | ... | |
{ :name => 'redhat_register', :source => 'snippets/_redhat_register.erb', :snippet => true },
|
||
{ :name => 'saltstack_minion', :source => 'snippets/_saltstack_minion.erb', :snippet => true }
|
||
].each do |input|
|
||
next if ProvisioningTemplate.find_by_name(input[:name])
|
||
next if ProvisioningTemplate.find_by_name(input[:name]).present?
|
||
next if audit_modified? ProvisioningTemplate, input[:name]
|
||
|
||
input.merge!(:default => true)
|
db/seeds.d/10-installation_media.rb | ||
---|---|---|
os_suse = Operatingsystem.find_all_by_type "Suse" || Operatingsystem.where("name LIKE ?", "suse")
|
||
os_suse = Operatingsystem.where(:type => "Suse") || Operatingsystem.where("name LIKE ?", "suse")
|
||
|
||
# Installation media: default mirrors
|
||
Medium.without_auditing do
|
db/seeds.d/16-mail_notifications.rb | ||
---|---|---|
]
|
||
|
||
notifications.each do |notification|
|
||
MailNotification.find_or_create_by_name(notification)
|
||
MailNotification.create(notification) if MailNotification.where(:name => notification[:name]).blank?
|
||
end
|
||
|
db/seeds.rb | ||
---|---|---|
role = Role.new(:name => role_name)
|
||
role.builtin = builtin
|
||
role.save!
|
||
permissions = Permission.find_all_by_name permission_names
|
||
permissions = Permission.where(:name => permission_names)
|
||
create_filters(role, permissions)
|
||
end
|
||
|
test/functional/api/v2/fact_values_controller_test.rb | ||
---|---|---|
get :index, {:host_id => @host.name }
|
||
assert_response :success
|
||
fact_values = ActiveSupport::JSON.decode(@response.body)['results']
|
||
expected_hash = FactValue.build_facts_hash(FactValue.find_all_by_host_id(@host.id))
|
||
expected_hash = FactValue.build_facts_hash(FactValue.where(:host_id => @host.id))
|
||
assert_equal expected_hash, fact_values
|
||
end
|
||
|
||
... | ... | |
get :index, {:host_id => @host.id }
|
||
assert_response :success
|
||
fact_values = ActiveSupport::JSON.decode(@response.body)['results']
|
||
expected_hash = FactValue.build_facts_hash(FactValue.find_all_by_host_id(@host.id))
|
||
expected_hash = FactValue.build_facts_hash(FactValue.where(:host_id => @host.id))
|
||
assert_equal expected_hash, fact_values
|
||
end
|
||
end
|
test/unit/puppetclass_test.rb | ||
---|---|---|
# add permission for user :one
|
||
as_admin do
|
||
filter1 = FactoryGirl.build(:filter)
|
||
filter1.permissions = Permission.find_all_by_name(['create_external_variables'])
|
||
filter1.permissions = Permission.where(:name => ['create_external_variables'])
|
||
filter2 = FactoryGirl.build(:filter)
|
||
filter2.permissions = Permission.find_all_by_name(['edit_puppetclasses'])
|
||
filter2.permissions = Permission.where(:name => ['edit_puppetclasses'])
|
||
role = Role.find_or_create_by_name :name => "testing_role"
|
||
role.filters = [ filter1, filter2 ]
|
||
role.save!
|
Also available in: Unified diff
Fixes #11078 - Substitute find_all_by by where to comply with Rails 4
This commit takes away all instances up to this point of find_all_by to
improve Rails 4 compatibility. They are substituted by .where calls.