end
if lang.nil? && !Setting.force_default_language_for_anonymous? && request.env['HTTP_ACCEPT_LANGUAGE']
accept_lang = parse_qvalues(request.env['HTTP_ACCEPT_LANGUAGE']).first
- if !accept_lang.blank?
+ if accept_lang.present?
accept_lang = accept_lang.downcase
lang = find_language(accept_lang) || find_language(accept_lang.split('-').first)
end
@role.safe_attributes = params[:role]
if request.post? && @role.save
# workflow copy
- if !params[:copy_workflow_from].blank? && (copy_from = Role.find_by_id(params[:copy_workflow_from]))
+ if params[:copy_workflow_from].present? && (copy_from = Role.find_by_id(params[:copy_workflow_from]))
@role.copy_workflow_rules(copy_from)
end
flash[:notice] = l(:notice_successful_create)
@tracker.safe_attributes = params[:tracker]
if @tracker.save
# workflow copy
- if !params[:copy_workflow_from].blank? && (copy_from = Tracker.find_by_id(params[:copy_workflow_from]))
+ if params[:copy_workflow_from].present? && (copy_from = Tracker.find_by_id(params[:copy_workflow_from]))
@tracker.copy_workflow_rules(copy_from)
end
flash[:notice] = l(:notice_successful_create)
def custom_field_value_tag(value)
attr_value = show_value(value)
- if !attr_value.blank? && value.custom_field.full_text_formatting?
+ if attr_value.present? && value.custom_field.full_text_formatting?
content_tag('div', attr_value, :class => 'wiki')
else
attr_value
# Singleton class method is public
class << self
def get_attr(entry, attr_name)
- if !attr_name.blank?
+ if attr_name.present?
value = entry[attr_name].is_a?(Array) ? entry[attr_name].first : entry[attr_name]
(+value.to_s).force_encoding('UTF-8')
end
'notifications' => '0'
)
- if options.key?(:project_id) && !options[:project_id].blank?
+ if options.key?(:project_id) && options[:project_id].present?
# Do not fail if project doesn't exist
begin
project = Project.find(options[:project_id])
end
if override && (v = extract_keyword!(cleaned_up_text_body, attr, options[:format]))
v
- elsif !handler_options[:issue][attr].blank?
+ elsif handler_options[:issue][attr].present?
handler_options[:issue][attr]
end
end
add_filter_error(field, :blank) unless
# filter requires one or more values
- (values_for(field) and !values_for(field).first.blank?) or
+ (values_for(field) and values_for(field).first.present?) or
# filter doesn't require any value
["o", "c", "!*", "*", "nd", "t", "ld", "nw", "w", "lw", "l2w", "nm", "m", "lm", "y", "*o", "!o"].include? operator_for(field)
end if filters
def column_names=(names)
if names
- names = names.select {|n| n.is_a?(Symbol) || !n.blank?}
+ names = names.select {|n| n.is_a?(Symbol) || n.present?}
names = names.collect {|n| n.is_a?(Symbol) ? n : n.to_sym}
if names.delete(:all_inline)
names = available_inline_columns.map(&:name) | names
v = YAML.safe_load(v, permitted_classes: Rails.configuration.active_record.yaml_column_permitted_classes)
v = force_utf8_strings(v)
end
- v = v.to_sym if available_settings[name]['format'] == 'symbol' && !v.blank?
+ v = v.to_sym if available_settings[name]['format'] == 'symbol' && v.present?
v
end
protected
def validate_parent_title
- errors.add(:parent_title, :invalid) if !@parent_title.blank? && parent.nil?
+ errors.add(:parent_title, :invalid) if @parent_title.present? && parent.nil?
errors.add(:parent_title, :circular_dependency) if parent && (parent == self || parent.ancestors.include?(self))
if parent_id_changed? && parent && (parent.wiki_id != wiki_id)
errors.add(:parent_title, :not_same_project)
author = item.event_author if item.respond_to?(:event_author)
xml.author do
xml.name(author)
- xml.email(author.mail) if author.is_a?(User) && !author.mail.blank? && !author.pref.hide_mail
+ xml.email(author.mail) if author.is_a?(User) && author.mail.present? && !author.pref.hide_mail
end if author
xml.content "type" => "html" do
xml.text! textilizable(item, :event_description, :only_path => false)
xml.updated change.created_on.xmlschema
xml.author do
xml.name change.user.name
- xml.email(change.user.mail) if change.user.is_a?(User) && !change.user.mail.blank? && !change.user.pref.hide_mail
+ xml.email(change.user.mail) if change.user.is_a?(User) && change.user.mail.present? && !change.user.pref.hide_mail
end
xml.content "type" => "html" do
xml.text! '<ul>'
# Returns +true+ if the plugin can be configured.
def configurable?
- settings && settings.is_a?(Hash) && !settings[:partial].blank?
+ settings && settings.is_a?(Hash) && settings[:partial].present?
end
# The directory containing this plugin's migrations (<tt>plugin/db/migrate</tt>)
assert_equal @source_project.issues.size, @project.issues.size
@project.issues.each do |issue|
assert issue.valid?
- assert ! issue.assigned_to.blank?
+ assert issue.assigned_to.present?
assert_equal @project, issue.project
end
end
with_settings :sequential_project_identifiers => '1' do
- assert !Project.new.identifier.blank?
+ assert Project.new.identifier.present?
assert Project.new(:identifier => '').identifier.blank?
end
with_settings :sequential_project_identifiers => '0' do
assert Project.new.identifier.blank?
- assert !Project.new(:identifier => 'test').blank?
+ assert Project.new(:identifier => 'test').present?
end
with_settings :default_projects_modules => ['issue_tracking', 'repository'] do
def test_random_password
u = User.new
u.random_password
- assert !u.password.blank?
- assert !u.password_confirmation.blank?
+ assert u.password.present?
+ assert u.password_confirmation.present?
end
def test_random_password_include_required_characters
user.reload
# Salt added
- assert !user.salt.blank?
+ assert user.salt.present?
# Password still valid
assert user.check_password?("unsalted")
assert_equal user, User.try_to_login(user.login, "unsalted")