From b9b86caf4cbd0d3751e7f16fb6d6592ae4d03a74 Mon Sep 17 00:00:00 2001 From: Alex Kotov Date: Fri, 26 Jul 2019 09:46:01 +0500 Subject: [PATCH] Add breadcrumbs --- app/models/person.rb | 12 +++++++++++ app/views/federal_subjects/index.html.erb | 8 ++++++++ app/views/federal_subjects/show.html.erb | 13 ++++++++++++ app/views/staffs/home/show.html.erb | 8 ++++++++ app/views/staffs/people/index.html.erb | 12 +++++++++++ .../staffs/people/passports/index.html.erb | 16 +++++++++++++++ .../people/person_comments/index.html.erb | 16 +++++++++++++++ app/views/staffs/people/show.html.erb | 16 +++++++++++++++ spec/models/person_spec.rb | 20 +++++++++++++++++++ 9 files changed, 121 insertions(+) diff --git a/app/models/person.rb b/app/models/person.rb index 7f91e7f..b3896d6 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -35,4 +35,16 @@ class Person < ApplicationRecord ############### validates :contacts_list, uniqueness: true + + ########### + # Methods # + ########### + + def full_name + [ + last_name, + first_name, + middle_name, + ].map(&:presence).compact.join(' ').freeze + end end diff --git a/app/views/federal_subjects/index.html.erb b/app/views/federal_subjects/index.html.erb index ddfd970..7a787bc 100644 --- a/app/views/federal_subjects/index.html.erb +++ b/app/views/federal_subjects/index.html.erb @@ -1,4 +1,12 @@
+ + diff --git a/app/views/federal_subjects/show.html.erb b/app/views/federal_subjects/show.html.erb index d43e9ce..89a609c 100644 --- a/app/views/federal_subjects/show.html.erb +++ b/app/views/federal_subjects/show.html.erb @@ -1,4 +1,17 @@
+ +

<%= @federal_subject.native_name %>

diff --git a/app/views/staffs/home/show.html.erb b/app/views/staffs/home/show.html.erb index b747ee0..439c783 100644 --- a/app/views/staffs/home/show.html.erb +++ b/app/views/staffs/home/show.html.erb @@ -1,4 +1,12 @@

+ +
    <% if policy(%i[staff person]).index? %>
  • diff --git a/app/views/staffs/people/index.html.erb b/app/views/staffs/people/index.html.erb index 633e6d7..57183b9 100644 --- a/app/views/staffs/people/index.html.erb +++ b/app/views/staffs/people/index.html.erb @@ -1,4 +1,16 @@
    + +
diff --git a/app/views/staffs/people/passports/index.html.erb b/app/views/staffs/people/passports/index.html.erb index 0410873..1d930e6 100644 --- a/app/views/staffs/people/passports/index.html.erb +++ b/app/views/staffs/people/passports/index.html.erb @@ -1,4 +1,20 @@
+ + <%= render partial: 'staffs/people/nav_tabs', locals: { person: @person, tab: :passports } %> diff --git a/app/views/staffs/people/person_comments/index.html.erb b/app/views/staffs/people/person_comments/index.html.erb index a2f1a03..9516434 100644 --- a/app/views/staffs/people/person_comments/index.html.erb +++ b/app/views/staffs/people/person_comments/index.html.erb @@ -1,4 +1,20 @@
+ + <%= render partial: 'staffs/people/nav_tabs', locals: { person: @person, tab: :person_comments } %> diff --git a/app/views/staffs/people/show.html.erb b/app/views/staffs/people/show.html.erb index 13da2d9..775fb1b 100644 --- a/app/views/staffs/people/show.html.erb +++ b/app/views/staffs/people/show.html.erb @@ -1,4 +1,20 @@
+ + <%= render partial: 'nav_tabs', locals: { person: @person, tab: :overview } %>
diff --git a/spec/models/person_spec.rb b/spec/models/person_spec.rb index 08d731f..3ad214a 100644 --- a/spec/models/person_spec.rb +++ b/spec/models/person_spec.rb @@ -113,4 +113,24 @@ RSpec.describe Person do .dependent(:restrict_with_exception) end end + + describe '#full_name' do + specify do + expect(subject.full_name).to be_instance_of String + end + + specify do + expect(subject.full_name).to be_frozen + end + + specify do + expect(subject.full_name).to eq( + [ + subject.last_name, + subject.first_name, + subject.middle_name, + ].compact.join(' '), + ) + end + end end