Skip to content

Commit

Permalink
Add notifications column to grant permissions index. #792 (#962)
Browse files Browse the repository at this point in the history
* Add notifications column to grant permissions index. #792
* add specs for on_off_boolean helper. #792
* add specs on index row for grant_permissions. #792
  • Loading branch information
mattbaumann1 authored Jul 15, 2022
1 parent 68ca45c commit eefb3e5
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 3 deletions.
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

0 comments on commit eefb3e5

Please sign in to comment.