Skip to content

Commit f91e6c4

Browse files
authored
Merge branch 'master' into dependabot/bundler/puma-4.3.3
2 parents 448df5d + 84eb63f commit f91e6c4

File tree

4 files changed

+56
-14
lines changed

4 files changed

+56
-14
lines changed

.github/workflows/mysql.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ jobs:
1010
DB_ADAPTER: mysql2
1111
MYSQL_PWD: root
1212
RAILS_ENV: test
13-
WICKED_PDF_PATH: vendor/bundle/bin/wkhtmltopdf
1413

1514
steps:
1615
# Checkout the repo
@@ -79,6 +78,10 @@ jobs:
7978
run: |
8079
yarn install
8180
81+
# Figure out where wkhtmltopdf is installed
82+
- name: 'Determine wkhtmltopdf location'
83+
run: echo ::set-env name=WICKED_PDF_PATH::$(echo `bundle exec which wkhtmltopdf`)
84+
8285
# Setup the database
8386
- name: 'Setup Test DB'
8487
run: bundle exec rake db:setup RAILS_ENV=test

.github/workflows/postgres.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,13 @@ jobs:
99
services:
1010
# Postgres installation
1111
db:
12-
image: postgres:11
12+
image: postgres
13+
env:
14+
# Latest version of Postgres has increased security. We can use the default
15+
# user/password in this testing scenario though so use the following env
16+
# variable to bypass this changes:
17+
# https://github.com/docker-library/postgres/issues/681
18+
POSTGRES_HOST_AUTH_METHOD: trust
1319
ports: ['5432:5432']
1420
options: >-
1521
--health-cmd pg_isready
@@ -84,6 +90,10 @@ jobs:
8490
${{ runner.os }}-yarn-
8591
${{ runner.os }}-
8692
93+
# Figure out where wkhtmltopdf is installed
94+
- name: 'Determine wkhtmltopdf location'
95+
run: echo ::set-env name=WICKED_PDF_PATH::$(echo `bundle exec which wkhtmltopdf`)
96+
8797
# Install the JS dependencies
8898
- name: 'Yarn Install'
8999
run: |

app/models/plan.rb

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -344,19 +344,17 @@ def editable_by?(user_id)
344344
#
345345
# Returns Boolean
346346
def readable_by?(user_id)
347+
return true if commentable_by?(user_id)
347348
current_user = User.find(user_id)
348-
if current_user.present?
349-
# If the user is a super admin and the config allows for supers to view plans
350-
if current_user.can_super_admin? &&
351-
Branding.fetch(:service_configuration, :plans, :super_admins_read_all)
352-
true
353-
# If the user is an org admin and the config allows for org admins to view plans
354-
elsif current_user.can_org_admin? &&
355-
Branding.fetch(:service_configuration, :plans, :org_admins_read_all)
356-
owner_and_coowners.map(&:org_id).include?(current_user.org_id)
357-
else
358-
commentable_by?(user_id)
359-
end
349+
return false unless current_user.present?
350+
# If the user is a super admin and the config allows for supers to view plans
351+
if current_user.can_super_admin? &&
352+
Branding.fetch(:service_configuration, :plans, :super_admins_read_all)
353+
true
354+
# If the user is an org admin and the config allows for org admins to view plans
355+
elsif current_user.can_org_admin? &&
356+
Branding.fetch(:service_configuration, :plans, :org_admins_read_all)
357+
owner_and_coowners.map(&:org_id).include?(current_user.org_id)
360358
else
361359
false
362360
end
@@ -388,6 +386,7 @@ def administerable_by?(user_id)
388386
def reviewable_by?(user_id)
389387
reviewer = User.find(user_id)
390388
feedback_requested? &&
389+
reviewer.present? &&
391390
reviewer.org_id == owner.org_id &&
392391
reviewer.can_review_plans?
393392
end

spec/models/plan_spec.rb

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -856,6 +856,36 @@
856856
end
857857
end
858858

859+
context "explicit sharing does not conflict with admin-viewing" do
860+
861+
it "super admins" do
862+
Branding.expects(:fetch)
863+
.with(:service_configuration, :plans, :super_admins_read_all)
864+
.at_most_once
865+
.returns(false)
866+
867+
user.perms << create(:perm, name: "add_organisations")
868+
role = subject.roles.commenter.first
869+
role.user_id = user.id
870+
role.save!
871+
872+
expect(subject.readable_by?(user.id)).to eql(true)
873+
end
874+
875+
it "org admins" do
876+
Branding.expects(:fetch)
877+
.with(:service_configuration, :plans, :org_admins_read_all)
878+
.at_most_once
879+
.returns(false)
880+
881+
user.perms << create(:perm, name: "modify_guidance")
882+
role = subject.roles.commenter.first
883+
role.user_id = user.id
884+
role.save!
885+
886+
expect(subject.readable_by?(user.id)).to eql(true)
887+
end
888+
end
859889
end
860890

861891
describe "#commentable_by?" do

0 commit comments

Comments
 (0)