Skip to content

Commit

Permalink
FIX: removing a default category wasn't working
Browse files Browse the repository at this point in the history
  • Loading branch information
ZogStriP committed Aug 26, 2015
1 parent 5457684 commit 4ba89ee
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/site_setting_extension.rb
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ def is_valid_data?(name, value)
valid = false unless value.to_i.is_a?(Fixnum)
end

return valid
valid
end

def filter_value(name, value)
Expand Down
33 changes: 28 additions & 5 deletions lib/site_setting_validations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,35 @@ def validate_max_username_length(new_val)
validate_error :max_username_length_exists if User.where('length(username) > ?', new_val).exists?
end

def validate_default_categories(new_val)
validate_error :default_categories_already_selected if (new_val.split("|").to_set & SiteSetting.default_categories_selected).size > 0
def validate_default_categories(new_val, default_categories_selected)
validate_error :default_categories_already_selected if (new_val.split("|").to_set & default_categories_selected).size > 0
end

alias_method :validate_default_categories_watching, :validate_default_categories
alias_method :validate_default_categories_tracking, :validate_default_categories
alias_method :validate_default_categories_muted, :validate_default_categories
def validate_default_categories_watching(new_val)
default_categories_selected = [
SiteSetting.default_categories_tracking.split("|"),
SiteSetting.default_categories_muted.split("|"),
].flatten.to_set

validate_default_categories(new_val, default_categories_selected)
end

def validate_default_categories_tracking(new_val)
default_categories_selected = [
SiteSetting.default_categories_watching.split("|"),
SiteSetting.default_categories_muted.split("|"),
].flatten.to_set

validate_default_categories(new_val, default_categories_selected)
end

def validate_default_categories_muted(new_val)
default_categories_selected = [
SiteSetting.default_categories_watching.split("|"),
SiteSetting.default_categories_tracking.split("|"),
].flatten.to_set

validate_default_categories(new_val, default_categories_selected)
end

end

0 comments on commit 4ba89ee

Please sign in to comment.