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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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