# a helpful error message and return them to the user page.
def deny_access(exception)
if current_user && exception.action.in?([:hide, :hidecomment])
- flash[:error] = t("user.filter.not_an_administrator")
- redirect_to :action => "view"
+ flash[:error] = t("users.filter.not_an_administrator")
+ redirect_to :action => "show"
else
super
end
can :index, :site
can [:permalink, :edit, :help, :fixthemap, :offline, :export, :about, :preview, :copyright, :key, :id, :welcome], :site
- can [:list, :rss, :view, :comments], DiaryEntry
+ can [:index, :rss, :show, :comments], DiaryEntry
can [:search, :search_latlon, :search_ca_postcode, :search_osm_nominatim,
:search_geonames, :search_osm_nominatim_reverse, :search_geonames_reverse], :geocoder
test "diary permissions for a guest" do
ability = Ability.new nil
- [:list, :rss, :view, :comments].each do |action|
+ [:index, :rss, :show, :comments].each do |action|
assert ability.can?(action, DiaryEntry), "should be able to #{action} DiaryEntries"
end
test "Diary permissions" do
ability = Ability.new create(:user)
- [:list, :rss, :view, :comments, :create, :edit, :comment, :subscribe, :unsubscribe].each do |action|
+ [:index, :rss, :show, :comments, :create, :edit, :comment, :subscribe, :unsubscribe].each do |action|
assert ability.can?(action, DiaryEntry), "should be able to #{action} DiaryEntries"
end
class AdministratorAbilityTest < AbilityTest
test "Diary for an administrator" do
ability = Ability.new create(:administrator_user)
- [:list, :rss, :view, :comments, :create, :edit, :comment, :subscribe, :unsubscribe, :hide, :hidecomment].each do |action|
+ [:index, :rss, :show, :comments, :create, :edit, :comment, :subscribe, :unsubscribe, :hide, :hidecomment].each do |action|
assert ability.can?(action, DiaryEntry), "should be able to #{action} DiaryEntries"
end