Skip to content

Commit

Permalink
fixes #2485 - Clicking close on the sitehome wiki throws error
Browse files Browse the repository at this point in the history
fixes #2422 - group wiki editable only by coordinators
  • Loading branch information
K. Clair committed Aug 31, 2010
1 parent 2d55b51 commit bfc5b5e
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 10 deletions.
2 changes: 1 addition & 1 deletion app/helpers/wiki_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ def wiki_action(action, hash={})
end

def wiki_edit_link(wiki_id=nil)
return unless may_edit_wiki?
return unless may_edit_wiki?(@group, wiki_id)
# note: firefox uses layerY, ie uses offsetY
link_to_remote_with_icon(I18n.t(:edit), :icon => 'pencil',
:url => wiki_action('edit', :wiki_id => wiki_id),
Expand Down
4 changes: 0 additions & 4 deletions app/permissions/groups/base_permission.rb
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,6 @@ def may_edit_appearance?(group=@group)
current_user.may?(:admin,group)
end

def may_edit_group_wiki?(group=@group)
current_user.may?(:admin,group) or group.profiles.public.members_may_edit_wiki?
end

##
## SEARCHING
##
Expand Down
12 changes: 10 additions & 2 deletions app/permissions/wiki_permission.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,16 @@
# end
module WikiPermission
def may_edit_wiki?(group=@group, wiki_id=nil)
logged_in? and current_user.member_of?(group)
may_edit_group_wiki?(group=@group) if (!wiki_id.nil? and group.profiles.public.wiki_id == wiki_id)
wiki = Wiki.find_by_id(wiki_id)
if !wiki.nil? and wiki.profile
may_edit_group_wiki?(wiki.profile.group)
else
logged_in? and current_user.member_of?(group)
end
end

def may_edit_group_wiki?(group=@group)
logged_in? and (current_user.may?(:admin,group) or (current_user.member_of?(group) and group.profiles.public.members_may_edit_wiki?))
end

alias_method :may_old_version_wiki?, :may_edit_wiki?
Expand Down
18 changes: 18 additions & 0 deletions features/groups/settings_and_profile/may_edit_wiki_ajax.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
@js

Feature: When the edit wiki icon is visible, the wiki can actually be edited

Background:
Given a group exists
And I exist
And I am logged in
And I am a member of that group

Scenario: I can edit the group wiki
And I go to that group's landing page
When I follow "Edit"
And I wait for the AJAX call to finish
Then I should see "Close Editor"
And I follow "Close Editor"
And I wait for the AJAX call to finish
Then I should not see "Close Editor"
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,18 @@ Background:
Given a group exists
And I exist
And I am logged in
And I am a member of that group

Scenario: Logged in users who are not members of the group cannot see the edit wiki link
When I go to that group's landing page
Then I should not see "Edit" within '#wiki-area'

Scenario: When there is no council, the edit group wiki checkbox is not shown
When I go to that group's administration page
When I am a member of that group
And I go to that group's administration page
And I follow "Permissions"
Then I should not see "Group Wiki"

Scenario: I can edit the group wiki
When I go to that group's landing page
When I am a member of that group
And I go to that group's landing page
Then I should see "Edit" within '#wiki-area'

0 comments on commit bfc5b5e

Please sign in to comment.