Skip to content

Commit

Permalink
Implement role editing. Apparently this never actually worked! [#54]
Browse files Browse the repository at this point in the history
  • Loading branch information
marnen committed Aug 6, 2013
1 parent 8e6dd29 commit f5bd200
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 14 deletions.
5 changes: 5 additions & 0 deletions app/controllers/permissions_controller.rb
Expand Up @@ -41,6 +41,11 @@ def destroy
go_back
end

def update
Permission.find(params[:id]).update_attributes! params[:permission]
go_back
end

def subscribe
begin
Permission.create! do |p|
Expand Down
6 changes: 6 additions & 0 deletions features/step_definitions/user_steps.rb
Expand Up @@ -40,6 +40,12 @@
end
end

When /^I change the role to "([^"]*)"$/ do |role|
within '._role' do
select role
end
end

Then /^I should (not )?have a user account for "([^\"]*)"$/ do |negation, email|
user = User.find_by_email(email)
if negation
Expand Down
6 changes: 6 additions & 0 deletions features/step_definitions/web_steps.rb
Expand Up @@ -43,6 +43,12 @@ def with_scope(locator)
with_scope(parent) { When "#{step}:", table_or_string }
end

When /^I do the following:$/ do |table|
table.raw.flatten.each do |step|
When step
end
end

Given /^(?:|I )am on (.+)$/ do |page_name|
visit path_to(page_name)
end
Expand Down
10 changes: 9 additions & 1 deletion features/user_list_for_calendar.feature
Expand Up @@ -38,4 +38,12 @@ Feature: User list for calendar
Given "Mary Wilson" is an admin of "My calendar"
When I go to the user list for "My calendar"
Then I should see "user" within user "Smith, John"
Then I should see "admin" within user "Wilson, Mary"
Then I should see "admin" within user "Wilson, Mary"

Scenario: Allow other users' roles to be changed
When I go to the user list for "My calendar"
And I do the following within user "Smith, John":
| I change the role to "admin" |
| I save |
Then I should be on the user list for "My calendar"
Then I should see "admin" within user "Smith, John"
13 changes: 0 additions & 13 deletions spec/views/calendars/users.html.haml_spec.rb
Expand Up @@ -35,19 +35,6 @@
render :file => 'calendars/users'
end

it "should show each user's role in this calendar, and -- except for the current user -- should allow it to be changed" do
for u in @users
Capybara.string(rendered).find("tr#user_#{u.id}").tap do |row|
if u == User.current_user
row.should have_selector("td._role", :content => /admin/) # just text
row.should_not have_selector("td._role select" )
else
row.should have_selector("td._role select" )
end
end
end
end

it "should show whether each user is visible on commitment reports" do
for u in @users
rendered.should have_selector("tr#user_#{u.id} td._show input[type=checkbox]")
Expand Down

0 comments on commit f5bd200

Please sign in to comment.