Rename
This commit is contained in:
parent
a9f7558509
commit
77331530cb
9 changed files with 15 additions and 15 deletions
|
@ -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
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class CountryState < ApplicationRecord
|
class FederalSubject < ApplicationRecord
|
||||||
################
|
################
|
||||||
# Associations #
|
# Associations #
|
||||||
################
|
################
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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 %>
|
||||||
|
|
|
@ -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>
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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 }
|
||||||
|
|
Reference in a new issue