Project

General

Profile

« Previous | Next » 

Revision b1b151d8

Added by Joseph Magen over 11 years ago

  • ID b1b151d83f2fb6c37e039d2662a7fc7587f13555

fixes #2166 - error when clearing location

View differences:

config/routes.rb
end
collection do
get 'auto_complete_search'
get 'clear', :action => 'select'
get 'clear'
get 'mismatches'
post 'import_mismatches'
end
......
end
collection do
get 'auto_complete_search'
get 'clear', :action => 'select'
get 'clear'
get 'mismatches'
post 'import_mismatches'
end
lib/foreman/controller/taxonomies_controller.rb
before_filter :find_taxonomy, :only => %w{edit update destroy clone_taxonomy assign_hosts
assign_selected_hosts assign_all_hosts step2 select}
before_filter :count_nil_hosts, :only => %w{index create step2}
skip_before_filter :authorize, :set_taxonomy, :only => %w{select}
skip_before_filter :authorize, :set_taxonomy, :only => %w{select clear}
end
module InstanceMethods
......
redirect_back_or_to root_url
end
def clear
taxonomy_class.current = nil
session[taxonomy_id] = nil
expire_fragment("tabs_and_title_records-#{User.current.id}")
redirect_back_or_to root_url
end
def mismatches
@mismatches = Taxonomy.all_mismatcheds
render 'taxonomies/mismatches'
test/functional/locations_controller_test.rb
assert_equal new_location.organization_ids, location.organization_ids
end
test "should clear out Location.current" do
@request.env['HTTP_REFERER'] = root_url
get :clear, {}, set_session_user
assert_equal Location.current, nil
assert_equal session[:location_id], nil
assert_redirected_to root_url
end
end
test/functional/organizations_controller_test.rb
assert_equal new_organization.location_ids, organization.location_ids
end
test "should clear out Organization.current" do
@request.env['HTTP_REFERER'] = root_url
get :clear, {}, set_session_user
assert_equal Organization.current, nil
assert_equal session[:organization_id], nil
assert_redirected_to root_url
end
end

Also available in: Unified diff