Skip to content

Commit

Permalink
Adds owner user to project show and permissions pages
Browse files Browse the repository at this point in the history
Partially addresses #322  (_Project show: List owners_)
  • Loading branch information
atruskie committed Mar 16, 2017
1 parent 3032fcf commit e26a8e4
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 12 deletions.
3 changes: 2 additions & 1 deletion app/views/permissions/index.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
- menu_edit_link(:project, project_permissions_path(@project), 'permissions')

- content_for :right_sidebar do
= render partial: 'shared/sidebar_metadata', locals: {title: 'Creator', text: link_to(@project.creator.user_name, user_account_path(@project.creator))}
= render partial: 'shared/sidebar_metadata_user_created', locals: { item: @project }
= render partial: 'shared/sidebar_metadata_users', locals: { title: 'Owned by', users: @project.owners }

- anon_level = Access::Core.highest(Access::Core.anon_levels(@project))
- anon_is_none = anon_level.blank?
Expand Down
4 changes: 3 additions & 1 deletion app/views/projects/show.html.haml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
- content_for :meta_title, "Project #{@project.name}"
- content_for :page_title, @project.name
- content_for :page_title do
= @project.name
- @info_bar = {model: @project, icon: 'globe'}

- content_for :page_actions do
Expand All @@ -22,6 +23,7 @@
= destroy_button(@project, 'project')

- content_for :right_sidebar do
= render partial: 'shared/sidebar_metadata_users', locals: { title: 'Owned by', users: @project.owners }
- levels = Access::Core.user_levels(current_user, @project)
- level = Access::Core.highest(levels)
- unless level.blank?
Expand Down
25 changes: 15 additions & 10 deletions app/views/shared/_sidebar_metadata_users.html.haml
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
-# locals: title, user, subtext
- if !title.blank? && !user.blank? && !subtext.blank?
-# locals: title, user, users, subtext
- user ||= nil
- users ||= []
- users << user if user
- subtext ||= nil
- if !title.blank? && users.length > 0
%h4= title
.media
.media-left.media-middle
%a{href: user_account_path(user)}
= image_tag user.image.url(:spanhalf), alt: user.user_name, class: 'media-object'
.media-body
= link_to user.user_name, user_account_path(user)
%br/
= subtext
- users.each do |user|
.media
.media-left.media-middle
%a{href: user_account_path(user)}
= image_tag user.image.url(:spanhalf), alt: user.user_name, class: 'media-object'
.media-body
= link_to user.user_name, user_account_path(user)
%br/
= subtext
8 changes: 8 additions & 0 deletions spec/features/permissions_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@
expect(page).to have_content('Permissions')
end

it 'lists the creator and owner' do
visit project_permissions_path(project)
expect(page).to have_content('Created by')
expect(page).to have_link(project.creator.user_name, user_account_path(project.creator))
expect(page).to have_content('Owned by')
expect(page).to have_link(owner_user.user_name, user_account_path(owner_user))
end

def check_row(user, level)
overall_selector = "tr[data-user-id='#{user.id}'] .overall-permission"
overall = find(overall_selector)
Expand Down
56 changes: 56 additions & 0 deletions spec/features/projects_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ def select_by_value(id, value)
expect(page).not_to have_link('Delete')
end

it 'lists the creator and owner' do
visit project_path(project)
expect(page).to have_content('Created by')
expect(page).to have_link(project.creator.user_name, user_account_path(project.creator))
expect(page).to have_content('Owned by')
expect(page).to have_link(owner_user.user_name, user_account_path(owner_user))
end

it 'creates new project when filling out form correctly' do
visit new_project_path
fill_in 'project[name]', with: 'test name'
Expand Down Expand Up @@ -77,6 +85,14 @@ def select_by_value(id, value)
expect(page).to have_button('Delete this project')
end

it 'lists the creator and owner' do
visit project_path(project)
expect(page).to have_content('Created by')
expect(page).to have_link(project.creator.user_name, user_account_path(project.creator))
expect(page).to have_content('Owned by')
expect(page).to have_link(owner_user.user_name, user_account_path(owner_user))
end

it 'creates new project when filling out form correctly' do
visit new_project_path
#save_and_open_page
Expand Down Expand Up @@ -124,6 +140,14 @@ def select_by_value(id, value)
expect(page).not_to have_link('Delete')
end

it 'lists the creator and owner' do
visit project_path(project)
expect(page).to have_content('Created by')
expect(page).to have_link(project.creator.user_name, user_account_path(project.creator))
expect(page).to have_content('Owned by')
expect(page).to have_link(owner_user.user_name, user_account_path(owner_user))
end

it 'creates new project when filling out form correctly' do
visit new_project_path
fill_in 'project[name]', with: 'test name'
Expand Down Expand Up @@ -324,6 +348,14 @@ def select_by_value(id, value)
expect(page).to have_button('Delete this project')
end

it 'lists the creator and owner' do
visit project_path(project)
expect(page).to have_content('Created by')
expect(page).to have_link(project.creator.user_name, user_account_path(project.creator))
expect(page).to have_content('Owned by')
expect(page).to have_link(owner_user.user_name, user_account_path(owner_user))
end

it 'creates new project when filling out form correctly' do
visit new_project_path
fill_in 'project_name', with: 'test name'
Expand Down Expand Up @@ -372,6 +404,14 @@ def select_by_value(id, value)
expect(page).to have_button('Delete this project')
end

it 'lists the creator and owner' do
visit project_path(project)
expect(page).to have_content('Created by')
expect(page).to have_link(project.creator.user_name, user_account_path(project.creator))
expect(page).to have_content('Owned by')
expect(page).to have_link(owner_user.user_name, user_account_path(owner_user))
end

it 'creates new project when filling out form correctly' do
visit new_project_path
fill_in 'project_name', with: 'test name'
Expand Down Expand Up @@ -420,6 +460,14 @@ def select_by_value(id, value)
expect(page).not_to have_link('Delete Project')
end

it 'lists the creator and owner' do
visit project_path(project)
expect(page).to have_content('Created by')
expect(page).to have_link(project.creator.user_name, user_account_path(project.creator))
expect(page).to have_content('Owned by')
expect(page).to have_link(owner_user.user_name, user_account_path(owner_user))
end

it 'creates new project when filling out form correctly' do
visit new_project_path
fill_in 'project[name]', with: 'test name'
Expand Down Expand Up @@ -465,6 +513,14 @@ def select_by_value(id, value)
expect(page).not_to have_link('Delete Project')
end

it 'lists the creator and owner' do
visit project_path(project)
expect(page).to have_content('Created by')
expect(page).to have_link(project.creator.user_name, user_account_path(project.creator))
expect(page).to have_content('Owned by')
expect(page).to have_link(owner_user.user_name, user_account_path(owner_user))
end

it 'creates new project when filling out form correctly' do
visit new_project_path
fill_in 'project[name]', with: 'test name'
Expand Down

0 comments on commit e26a8e4

Please sign in to comment.