Skip to content

Commit

Permalink
Merge branch 'release/2.5.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasbischof committed Apr 5, 2022
2 parents 64f66b8 + eaa3ab7 commit 0c078fa
Show file tree
Hide file tree
Showing 61 changed files with 549 additions and 161 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ jobs:
strategy:
fail-fast: false
matrix:
language: [ 'javascript' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
language: [ 'javascript', 'ruby' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
# Learn more:
# https://docs.github.com/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed

Expand Down
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ gem 'puma', '~> 5.6'
gem 'rack-cors', require: 'rack/cors'
gem 'rails', '~> 6.1.4'
gem 'rails-i18n'
gem 'redis', '~> 4.0'
gem 'sepa_king'
gem 'sidekiq'
gem 'sidekiq-scheduler'
Expand Down
3 changes: 2 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ GEM
pry (>= 0.10.4)
psych (3.2.0)
public_suffix (4.0.6)
puma (5.6.2)
puma (5.6.4)
nio4r (~> 2.0)
raabro (1.4.0)
racc (1.6.0)
Expand Down Expand Up @@ -630,6 +630,7 @@ DEPENDENCIES
rails-controller-testing
rails-i18n
rails_admin (~> 2.1)
redis (~> 4.0)
reek (~> 6.0.1)
rspec-rails
rubocop
Expand Down
4 changes: 4 additions & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# frozen_string_literal: true

require 'turbo/redirection'

class ApplicationController < ActionController::Base
include Turbo::Redirection

helper_method :current_organization_admin, :current_civil_servant, :current_organization, :current_referencee

def current_organization_admin
Expand Down
4 changes: 3 additions & 1 deletion app/controllers/civil_servants/civil_servants_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,13 @@ class CivilServantsController < BaseController
before_action :set_civil_servant, only: %i[edit update]
before_action -> { authorize! params[:action].to_sym, @civil_servant }

breadcrumb 'civil_servants.civil_servants.edit', :edit_civil_servants_civil_servant_path

def edit; end

def update
if @civil_servant.update(civil_servant_params)
flash.now[:success] = t('.successfully_updated')
flash[:success] = t('.successfully_updated')
redirect_to edit_civil_servants_civil_servant_path
else
respond_to do |format|
Expand Down
1 change: 1 addition & 0 deletions app/controllers/civil_servants/overview_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ module CivilServants
class OverviewController < BaseController
before_action -> { authorize! :read, :civil_servant_overview }
before_action :set_civil_servant, only: :index
breadcrumb 'civil_servants.overview.index', :civil_servants_path

def index; end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ module CivilServants
class ServiceAgreementsController < BaseController
authorize_resource :service, only: :index

breadcrumb 'civil_servants.service_agreements.index', :civil_servants_service_agreements_path

def index
@service_agreements = Service.includes(:organization, :service_specification)
.accessible_by(current_ability).agreement
Expand Down
10 changes: 10 additions & 0 deletions app/controllers/civil_servants/services_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ class ServicesController < BaseController
include RespondWithPdfConcern

load_and_authorize_resource
breadcrumb 'civil_servants.services.index', :civil_servants_services_path
before_action :show_breadcrumb, only: :show

def index
load_filters
Expand Down Expand Up @@ -50,5 +52,13 @@ def render_pdf
Rails.root.join('lib/assets/pdfs/german_service_agreement_form.pdf').to_s
)
end

def show_breadcrumb
title = I18n.t('loaf.breadcrumbs.civil_servants.services.show',
beginning: I18n.l(@service.beginning, format: :short),
ending: I18n.l(@service.ending, format: :short))

breadcrumb title, :civil_servants_service_path
end
end
end
2 changes: 1 addition & 1 deletion app/controllers/organizations/expense_sheets_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def update
else
load_suggestions
flash.now[:error] = t('.erroneous_update')
render :edit
render :edit, status: :unprocessable_entity
end
end

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/organizations/job_postings_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def update
redirect_to edit_organizations_job_posting_path(@job_posting), notice: t('.successful_update')
else
flash.now[:error] = t('.erroneous_update')
render :edit
render :edit, status: :unprocessable_entity
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,31 +21,31 @@ def create
build_organization_holiday

if @organization_holiday.save
flash.now[:success] = t('organizations.organization_holidays.update.successful_create')
flash[:success] = t('organizations.organization_holidays.update.successful_create')
redirect_to organizations_organization_holidays_path
else
flash.now[:error] = t('organizations.organization_holidays.update.erroneous_create')
render :new
render :new, status: :unprocessable_entity
end
end

def update
if @organization_holiday.update(organization_holiday_params)
flash.now[:success] = t('organizations.organization_holidays.update.successful_update')
flash[:success] = t('organizations.organization_holidays.update.successful_update')
redirect_to organizations_organization_holidays_path
else
flash.now[:error] = t('organizations.organization_holidays.update.erroneous_update')
render :edit
render :edit, status: :unprocessable_entity
end
end

def destroy
if @organization_holiday.destroy
flash.now[:success] = t('organizations.organization_holidays.update.successful_destroy')
flash[:success] = t('organizations.organization_holidays.update.successful_destroy')
redirect_to organizations_organization_holidays_path
else
flash.now[:error] = t('organizations.organization_holidays.update.erroneous_destroy')
render :edit
render :edit, status: :unprocessable_entity
end
end

Expand Down
12 changes: 6 additions & 6 deletions app/controllers/organizations/organization_members_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,33 +17,33 @@ def new; end

def create
if @organization_member.save
flash.now[:success] = t('.successfully_created')
flash[:success] = t('.successfully_created')
redirect_to organizations_members_path
else
flash.now[:error] = t('.erroneous_create')
render :new
render :new, status: :unprocessable_entity
end
end

def edit; end

def update
if @organization_member.update(update_params)
flash.now[:success] = t('.successfully_updated')
flash[:success] = t('.successfully_updated')
redirect_to edit_organizations_member_path(@organization_member)
else
flash.now[:error] = t('.erroneous_update')
render :edit
render :edit, status: :unprocessable_entity
end
end

def destroy
if @organization_member != current_organization_admin && @organization_member.destroy
flash.now[:success] = t('.successfully_deleted')
flash[:success] = t('.successfully_deleted')
redirect_to organizations_members_path
else
flash.now[:error] = t('.erroneous_delete')
render :edit
render :edit, status: :unprocessable_entity
end
end

Expand Down
5 changes: 2 additions & 3 deletions app/controllers/organizations/organizations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
module Organizations
class OrganizationsController < BaseController
before_action :load_organization

before_action :edit_breadcrumb, only: %i[edit update]

def edit
Expand All @@ -12,11 +11,11 @@ def edit

def update
if @organization.update(organization_params)
flash.now[:success] = t('organizations.organizations.update.successful_update')
flash[:success] = t('organizations.organizations.update.successful_update')
redirect_to edit_organizations_organization_path
else
flash.now[:error] = t('organizations.organizations.update.erroneous_update')
render :edit
render :edit, status: :unprocessable_entity
end
end

Expand Down
12 changes: 6 additions & 6 deletions app/controllers/organizations/payments_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ def create
@payment.amount = @payment.expense_sheets.sum(&:amount)

if @payment.save
flash.now[:success] = t('.successful_create')
flash[:success] = t('.successful_create')
redirect_to organizations_payment_path(@payment)
else
load_accessible_expense_sheets
flash.now[:error] = t('.erroneous_create')
render :new
render :new, status: :unprocessable_entity
end
end

Expand All @@ -46,9 +46,9 @@ def update

def destroy
if @payment.destroy
flash.now[:success] = t('.successful_destroy')
flash[:success] = t('.successful_destroy')
else
flash.now[:error] = t('.erroneous_destroy')
flash[:error] = t('.erroneous_destroy')
end

redirect_back fallback_location: organizations_payments_path
Expand All @@ -58,9 +58,9 @@ def destroy

def process_paid_state_update
if payment_params[:state] == 'paid' && !@payment.readonly? && @payment.paid_out!
flash.now[:success] = I18n.t('organizations.payments.update.successful_update')
flash[:success] = I18n.t('organizations.payments.update.successful_update')
else
flash.now[:error] = I18n.t('organizations.payments.update.erroneous_update')
flash[:error] = I18n.t('organizations.payments.update.erroneous_update')
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def create
else
@service_agreement = agreement_creator.service_agreement
flash.now[:error] = t('.erroneous_create')
render :new
render :new, status: :unprocessable_entity
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def create
redirect_to organizations_service_specifications_path, notice: t('.successful_create')
else
flash.now[:error] = t('.erroneous_create')
render :new
render :new, status: :unprocessable_entity
end
end

Expand All @@ -45,15 +45,15 @@ def update
redirect_to edit_organizations_service_specification_path, notice: t('.successful_update')
else
flash.now[:error] = t('.erroneous_update')
render :edit
render :edit, status: :unprocessable_entity
end
end

def destroy
if @service_specification.destroy
flash.now[:notice] = t('.successful_destroy')
flash[:notice] = t('.successful_destroy')
else
flash.now[:error] = t('.erroneous_destroy')
flash[:error] = t('.erroneous_destroy')
end

redirect_to organizations_service_specifications_path
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/organizations/services_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ def show; end

def confirm
if @service.confirm!
flash.now[:success] = I18n.t('organizations.services.confirm.successful_confirm')
flash[:success] = I18n.t('organizations.services.confirm.successful_confirm')
redirect_to organizations_civil_servant_service_path(@civil_servant, @service)
else
flash.now[:error] = I18n.t('organizations.services.confirm.erroneous_confirm')
flash[:error] = I18n.t('organizations.services.confirm.erroneous_confirm')
redirect_back(fallback_location: organizations_path)
end
end
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/service_inquiries_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def create
end

def service_inquiry_params
params.require(:service_inquiry).permit(:name, :email, :phone, :service_beginning,
params.require(:service_inquiry).permit(:name, :email, :phone, :service_beginning, :agreement,
:service_duration, :message, :job_posting_id)
end

Expand Down
File renamed without changes.
14 changes: 14 additions & 0 deletions app/javascript/js/home/search/embedded_app/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,20 @@ import { createBrowserLocalStorageCache } from '@algolia/cache-browser-local-sto
import { createFallbackableCache } from '@algolia/cache-common';
import { createInMemoryCache } from '@algolia/cache-in-memory';
import SearchPage from 'js/home/search/embedded_app/components/SearchPage';
import aa from 'search-insights';
import Turbo from '@hotwired/turbo-rails';

declare global {
interface Window {
Turbo: typeof Turbo;
}
}

aa('init', {
appId: MyZivi.algolia.applicationId,
apiKey: MyZivi.algolia.apiKey,
useCookie: true,
});

const searchClient = algoliasearch(
MyZivi.algolia.applicationId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const NoResults: React.FunctionComponent = () => (
const renderHits = (hits: JobPostingSearchHit[]) => (
hits.map((hit) => (
<div className="col-12 col-xl-6 mb-4">
<JobPosting hit={hit} key={hit.objectID} />
<JobPosting hit={hit as never} key={hit.objectID} />
</div>
))
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
import { shallow } from 'enzyme';
import React from 'preact/compat';
import JobPosting from './JobPosting';
import JobPostingFactory from '../../../../tests/factories/JobPostingFactory';
import { mountInstantSearchClient } from '../../../../../../../jest/utils';

describe('JobPosting', () => {
let rendered;

beforeEach(() => {
rendered = mountInstantSearchClient(
<JobPosting hit={JobPostingFactory.build() as never} />,
);
});

it('renders correctly', () => {
expect(
shallow(<JobPosting hit={JobPostingFactory.build()} />),
).toMatchSnapshot();
const jobPostingComponent = rendered.find('JobPosting').children();
expect(jobPostingComponent).toMatchSnapshot();
});
});

0 comments on commit 0c078fa

Please sign in to comment.