1
0
Fork 0
This commit is contained in:
Alex Kotov 2019-06-23 20:54:41 +05:00
parent a9f7558509
commit 77331530cb
Signed by: kotovalexarian
GPG key ID: 553C0EBBEB5D5F08
9 changed files with 15 additions and 15 deletions

View file

@ -1,12 +1,12 @@
# frozen_string_literal: true
class CountryStatesController < ApplicationController
class FederalSubjectsController < ApplicationController
before_action :set_country_state, except: :index
# GET /country_states
def index
authorize :country_state
@country_states = policy_scope(CountryState)
@country_states = policy_scope(FederalSubject)
end
# GET /country_states/:id
@ -17,6 +17,6 @@ class CountryStatesController < ApplicationController
private
def set_country_state
@country_state = CountryState.find params[:id]
@country_state = FederalSubject.find params[:id]
end
end

View file

@ -1,6 +1,6 @@
# frozen_string_literal: true
class CountryState < ApplicationRecord
class FederalSubject < ApplicationRecord
################
# Associations #
################

View file

@ -1,6 +1,6 @@
# frozen_string_literal: true
class CountryStatePolicy < ApplicationPolicy
class FederalSubjectPolicy < ApplicationPolicy
def index?
true
end

View file

@ -18,7 +18,7 @@
<% if policy(:country_state).index? %>
<li class="nav-item <%= :active if country_states_controller? %>">
<%= link_to country_states_path, class: 'nav-link' do %>
<%= CountryState.model_name.human count: 0 %>
<%= FederalSubject.model_name.human count: 0 %>
<% end %>
</li>
<% end %>

View file

@ -3,10 +3,10 @@
<thead>
<tr>
<th scope="col">
<%= CountryState.human_attribute_name :english_name %>
<%= FederalSubject.human_attribute_name :english_name %>
</th>
<th scope="col">
<%= CountryState.human_attribute_name :native_name %>
<%= FederalSubject.human_attribute_name :native_name %>
</th>
<th scope="col"></th>
</tr>

View file

@ -9,7 +9,7 @@ CSV.foreach country_states_filename,
native_name.strip!
english_name.strip!
CountryState.where(english_name: english_name)
FederalSubject.where(english_name: english_name)
.first_or_create! do |new_country_state|
new_country_state.native_name = native_name
end

View file

@ -3,7 +3,7 @@
FactoryBot.define do
factory :country_state do
initialize_with do
CountryState.find_or_initialize_by english_name: english_name
FederalSubject.find_or_initialize_by english_name: english_name
end
english_name do

View file

@ -2,7 +2,7 @@
require 'rails_helper'
RSpec.describe CountryState do
RSpec.describe FederalSubject do
subject { create :country_state }
it do

View file

@ -2,11 +2,11 @@
require 'rails_helper'
RSpec.describe CountryStatePolicy do
RSpec.describe FederalSubjectPolicy do
subject { described_class.new current_account, record }
let :resolved_scope do
described_class::Scope.new(current_account, CountryState.all).resolve
described_class::Scope.new(current_account, FederalSubject.all).resolve
end
let!(:record) { create :country_state }
@ -20,7 +20,7 @@ RSpec.describe CountryStatePolicy do
it { is_expected.to forbid_edit_and_update_actions }
it { is_expected.to forbid_action :destroy }
specify { expect(resolved_scope).to eq CountryState.all }
specify { expect(resolved_scope).to eq FederalSubject.all }
specify { expect(resolved_scope).to include record }
specify { expect(resolved_scope).to include other_record }