1
0
Fork 0

Remove resident registration feature

This commit is contained in:
Alex Kotov 2019-07-19 07:46:09 +05:00
parent 6f58f71ab2
commit a1846ca2ed
Signed by: kotovalexarian
GPG Key ID: 553C0EBBEB5D5F08
16 changed files with 0 additions and 145 deletions

View File

@ -1,20 +0,0 @@
# frozen_string_literal: true
class Staffs::People::ResidentRegistrationsController < ApplicationController
before_action :set_person
# GET /staff/people/:person_id/resident_registrations
def index
authorize [:staff, @person, :resident_registration]
@resident_registrations = policy_scope(
@person.resident_registrations,
policy_scope_class: Staff::Person::ResidentRegistrationPolicy::Scope,
)
end
private
def set_person
@person = Person.find params[:person_id]
end
end

View File

@ -27,8 +27,6 @@ class Person < ApplicationRecord
has_many :passports, dependent: :restrict_with_exception
has_many :resident_registrations, dependent: :restrict_with_exception
###############
# Validations #
###############

View File

@ -1,9 +0,0 @@
# frozen_string_literal: true
class ResidentRegistration < ApplicationRecord
################
# Associations #
################
belongs_to :person, optional: true
end

View File

@ -1,15 +0,0 @@
# frozen_string_literal: true
class Staff::Person::ResidentRegistrationPolicy < ApplicationPolicy
def index?
account&.is_superuser?
end
class Scope < Scope
def resolve
return scope.all if account&.is_superuser?
scope.none
end
end
end

View File

@ -5,6 +5,5 @@
overview: [:staff, person],
person_comments: staff_person_person_comments_path(person),
passports: staff_person_passports_path(person),
resident_registrations: staff_person_resident_registrations_path(person),
) %>
</div>

View File

@ -1,24 +0,0 @@
<div class="container">
<%= render partial: 'staffs/people/nav_tabs',
locals: { person: @person, tab: :resident_registrations } %>
<table class="table">
<thead>
<tr>
<th scope="col">
<%= ResidentRegistration.human_attribute_name :id %>
</th>
<th scope="col"></th>
</tr>
</thead>
<tbody>
<% @resident_registrations.each do |resident_registration| %>
<tr>
<td scope="row"><%= resident_registration.id %></td>
<td></td>
</tr>
<% end %>
</tbody>
</table>
</div>

View File

@ -16,9 +16,6 @@ en:
person_comment:
one: Comment
many: Comments
resident_registration:
one: Resident registration
many: Resident registrations
roles:
one: Role
many: Roles
@ -69,8 +66,6 @@ en:
person/sex:
male: Male
female: Female
resident_registration:
id: ID
role:
id: ID
name: Name

View File

@ -16,9 +16,6 @@ ru:
person_comment:
one: Комментарий
many: Комментарии
resident_registration:
one: Прописка
many: Прописки
roles:
one: Роль
many: Роли
@ -69,8 +66,6 @@ ru:
person/sex:
male: Мужской
female: Женский
resident_registration:
id: ID
role:
id: ID
name: Название

View File

@ -4,7 +4,6 @@ en:
overview: Overview
person_comments: Comments
passports: Passports
resident_registrations: Resident registrations
settings:
credentials: Credentials
profile: Public profile

View File

@ -4,7 +4,6 @@ ru:
overview: Обзор
person_comments: Комментарии
passports: Паспорта
resident_registrations: Прописки
settings:
credentials: Данные для входа
profile: Публичный профиль

View File

@ -58,10 +58,6 @@ Rails.application.routes.draw do
resources :passports,
controller: 'people/passports',
only: :index
resources :resident_registrations,
controller: 'people/resident_registrations',
only: :index
end
end
end

View File

@ -1,7 +0,0 @@
# frozen_string_literal: true
FactoryBot.define do
factory :empty_resident_registration, class: ResidentRegistration do
association :person, factory: :initial_person
end
end

View File

@ -41,12 +41,6 @@ RSpec.describe Person do
.dependent(:restrict_with_exception)
end
it do
is_expected.to \
have_many(:resident_registrations)
.dependent(:restrict_with_exception)
end
it { is_expected.not_to validate_presence_of :regional_office }
describe '#relationships' do

View File

@ -1,9 +0,0 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe ResidentRegistration do
subject { create :empty_resident_registration }
it { is_expected.to belong_to(:person).optional }
end

View File

@ -1,7 +0,0 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe Staff::Person::ResidentRegistrationPolicy do
pending "add some examples to (or delete) #{__FILE__}"
end

View File

@ -1,29 +0,0 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe 'GET /staff/people/:person_id/resident_registrations' do
let(:person) { create :initial_person }
before do
sign_in current_account.user if current_account&.user
create :empty_resident_registration, person: person
create :empty_resident_registration, person: person
create :empty_resident_registration, person: person
get "/staff/people/#{person.to_param}/resident_registrations"
end
for_account_types nil, :guest, :usual do
specify do
expect(response).to have_http_status :forbidden
end
end
for_account_types :superuser do
specify do
expect(response).to have_http_status :ok
end
end
end