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

Fix PostgreSQL GitHub Action and Tests For Rails 7 Upgrade #3435

Merged
merged 10 commits into from
Aug 19, 2024
6 changes: 3 additions & 3 deletions .github/workflows/mysql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:

# Stub out the Rails credentials file so that we can start the Rails app
- name: 'Setup Credentials'
run: EDITOR='echo "$(cat config/credentials.yml.mysql2)" >' bundle exec rails credentials:edit
run: EDITOR="sh -c 'echo \"$(cat config/credentials.yml.mysql2)\" > \$1' --" bundle exec rails credentials:edit

# Set the path to the wkhtmltopdf executable
- name: 'Determine wkhtmltopdf location'
Expand All @@ -54,8 +54,8 @@ jobs:

- name: 'Build out the test database'
run: |
bundle exec rails db:create RAILS_ENV=test
bundle exec rails db:schema:load RAILS_ENV=test
DISABLE_SPRING=1 bundle exec rails db:create RAILS_ENV=test
DISABLE_SPRING=1 bundle exec rails db:schema:load RAILS_ENV=test

- name: 'Run any pending database migrations'
run: bin/rails db:migrate RAILS_ENV=test
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/postgres.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ jobs:
- name: 'Setup Credentials'
run: |
# generate a default credential file and key
EDITOR='echo "$(cat config/credentials.yml.postgresql)" >' bundle exec rails credentials:edit
EDITOR="sh -c 'echo \"$(cat config/credentials.yml.postgresql)\" > \$1' --" bundle exec rails credentials:edit

# Set the path to the wkhtmltopdf executable
- name: 'Determine wkhtmltopdf location'
Expand All @@ -79,7 +79,7 @@ jobs:
# Initialize the DB
- name: 'Setup Test DB'
run: |
bundle exec rails db:setup RAILS_ENV=test
DISABLE_SPRING=1 bundle exec rails db:setup RAILS_ENV=test
bundle exec rails db:migrate RAILS_ENV=test

# Prebuild the CSS, JS and image assets
Expand Down
2 changes: 1 addition & 1 deletion app/models/org.rb
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ class Org < ApplicationRecord
before_validation :check_for_missing_logo_file

# This gives all managed orgs api access whenever saved or updated.
before_save :ensure_api_access, if: lambda(&:managed?)
before_save :ensure_api_access, if: -> { managed? }

# If the physical logo file is no longer on disk we do not want it to prevent the
# model from saving. This typically happens when you copy the database to another
Expand Down
2 changes: 1 addition & 1 deletion app/models/template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class Template < ApplicationRecord
# overwriting the accessors. We want to ensure this template is published
# before we remove the published_version
# That being said, there's a potential race_condition where we have multiple-published-versions
after_update :reconcile_published, if: lambda(&:published?)
after_update :reconcile_published, if: -> { published? }

# ==========
# = Scopes =
Expand Down
5 changes: 4 additions & 1 deletion app/views/org_admin/templates/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@
placement: 'right' }%>
<div class="form-check">
<%= f.label(:visibility) do %>
<%= f.check_box(:visibility, checked: f.object.visibility == 'organisationally_visible') %>
<%= f.check_box(:visibility,
{ checked: f.object.organisationally_visible? },
f.object.class.visibilities[:organisationally_visible],
f.object.class.visibilities[:publicly_visible]) %>

<%= _('for internal %{org_name} use only') % { org_name: f.object.org.name } %>
<% end %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/org_admin/templates/_show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<!-- If the Org is a funder and another org type then allow then to set the visibility -->
<dt><%= _('Visibility') %></dt>
<dd>
<% if template.visibility == 'organisationally_visible' %>
<% if template.organisationally_visible? %>
<%= _('for internal %{org_name} use only') % {org_name: template.org.name} %>
<% else %>
<%= _('available to the public') + (template.published? ? '' : ' (once published)') %>
Expand Down
2 changes: 1 addition & 1 deletion bin/setup
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ if valid_db
cp ".env.#{db_adapter}", '.env'

puts "\n== Preparing credentials file =="
system! "EDITOR='echo \"$(cat config/credentials.yml.#{db_adapter})\" >' bin/rails credentials:edit"
system!("EDITOR=\"sh -c 'echo \\\"$(cat config/credentials.yml.#{db_adapter})\\\" > \\\"\\\$1\\\"' --\" bin/rails credentials:edit")

# Set the editor based on the platform
ENV['EDITOR'] = Gem.win_platform? ? 'code --wait' : 'vim'
Expand Down
4 changes: 2 additions & 2 deletions spec/models/template_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1083,7 +1083,7 @@
end

it 'sets visibility to Organisationally visible' do
expect(subject.visibility).to eql(Template.visibilities['organisationally_visible'])
expect(subject.organisationally_visible?).to eql(true)
end

it 'sets is_default to false' do
Expand Down Expand Up @@ -1152,7 +1152,7 @@
end

it 'sets the visibility to Organisationally visible' do
expect(subject.visibility).to eql(Template.visibilities['organisationally_visible'])
expect(subject.organisationally_visible?).to eql(true)
end

it 'sets is_default to false' do
Expand Down
Loading