Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add notifications column to grant permissions index. #792 #962

Merged
merged 4 commits into from
Jul 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ def title_tag_content(page_title: '')
page_title.empty? ? base_title : "#{page_title} | #{base_title}"
end

# Boolean value changes
def on_off_boolean(boolean)
boolean ? 'On' : 'Off'
end

# Dates
def date_mmddyyyy(date)
date.blank? ? '' : date.strftime('%m/%d/%Y')
Expand Down
6 changes: 5 additions & 1 deletion app/views/grant_permissions/index.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,18 @@
%th
Role
%th
Notifications
%th

%tbody
- @grant_permissions.each do |grant_permission|
- grant_permission_user_name = full_name(grant_permission.user)
%tr
%tr{ id: "#{dom_id(grant_permission)}" }
%td
= grant_permission_user_name
%td
= grant_permission.role.capitalize
%td
= on_off_boolean(grant_permission.submission_notification)
%td
= render partial: "#{current_user.get_role_by_grant(grant: @grant)}_links", locals: { grant_permission: grant_permission, grant: @grant, grant_permission_user_name: grant_permission_user_name }
14 changes: 14 additions & 0 deletions spec/helpers/application_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,18 @@ def excel_worksheet_reserved_characters
expect(title_tag_content(page_title: 'Page Name')).to eql 'Page Name | TEST'
end
end

context 'booleans' do
describe '#on_off_boolean(boolean)' do
it 'returns On when given a true boolean' do
boolean = true
helper.on_off_boolean(boolean).should eql("On")
end

it 'returns Off when given a false boolean' do
boolean = false
helper.on_off_boolean(boolean).should eql("Off")
end
end
end
end
12 changes: 10 additions & 2 deletions spec/system/grant_permissions/grant_permissions_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# frozen_string_literal: true

require 'rails_helper'
include ApplicationHelper
include UsersHelper

RSpec.describe 'GrantPermissions', type: :system, js: true do
Expand All @@ -23,23 +24,30 @@
describe 'grant editor user' do
before(:each) do
login_as(@grant_editor, scope: :saml_user)
visit grant_grant_permissions_path(@grant)
end

context '#index' do
scenario 'includes link to add permission' do
visit grant_grant_permissions_path(@grant)
expect(page).to have_link 'Grant access to another user', href: new_grant_grant_permission_path(@grant)
end

scenario 'includes edit link, excludes delete link' do
visit grant_grant_permissions_path(@grant)
expect(page).to have_link 'Edit', href: edit_grant_grant_permission_path(@grant, @grant_admin_role)
expect(page).not_to have_link 'Delete', href: grant_grant_permission_path(@grant, @grant_admin_role)
expect(page).to have_link 'Edit', href: edit_grant_grant_permission_path(@grant, @grant_editor_role)
expect(page).not_to have_link 'Delete', href: grant_grant_permission_path(@grant, @grant_editor_role)
expect(page).to have_link 'Edit', href: edit_grant_grant_permission_path(@grant, @grant_viewer_role)
expect(page).not_to have_link 'Delete', href: grant_grant_permission_path(@grant, @grant_viewer_role)
end

scenario 'includes information in grant admin table row' do
within("tr#grant_permission_#{@grant_admin_role.id}") do
expect(page).to have_content(full_name(@grant_admin))
expect(page).to have_content(@grant_admin_role.role.capitalize)
expect(page).to have_content(on_off_boolean(@grant.grant_permissions.role_admin.first.submission_notification))
end
end
end

context '#edit' do
Expand Down