Add action Settings::AppearancesController#edit
This commit is contained in:
parent
a36dcb7d26
commit
fcff554992
9 changed files with 69 additions and 0 deletions
16
app/controllers/settings/appearances_controller.rb
Normal file
16
app/controllers/settings/appearances_controller.rb
Normal file
|
@ -0,0 +1,16 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class Settings::AppearancesController < ApplicationController
|
||||
before_action :set_account
|
||||
|
||||
# GET /settings/appearance/edit
|
||||
def edit
|
||||
authorize %i[settings appearance]
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def set_account
|
||||
@account = current_account.clone&.reload
|
||||
end
|
||||
end
|
7
app/policies/settings/appearance_policy.rb
Normal file
7
app/policies/settings/appearance_policy.rb
Normal file
|
@ -0,0 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class Settings::AppearancePolicy < ApplicationPolicy
|
||||
def update?
|
||||
!!account
|
||||
end
|
||||
end
|
|
@ -9,6 +9,10 @@
|
|||
policy(%i[users registration]).edit?,
|
||||
edit_user_registration_path,
|
||||
],
|
||||
appearance: [
|
||||
policy(%i[settings appearance]).edit?,
|
||||
edit_settings_appearance_path,
|
||||
],
|
||||
person: [
|
||||
policy(%i[settings person]).show?,
|
||||
settings_person_path,
|
||||
|
|
10
app/views/settings/appearances/edit.html.erb
Normal file
10
app/views/settings/appearances/edit.html.erb
Normal file
|
@ -0,0 +1,10 @@
|
|||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-md-3 mb-4">
|
||||
<%= render partial: 'settings/nav_sidebar', locals: { tab: :appearance } %>
|
||||
</div>
|
||||
|
||||
<div class="col-md-9">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
|
@ -8,6 +8,7 @@ en:
|
|||
settings:
|
||||
credentials: Credentials
|
||||
profile: Public profile
|
||||
appearance: Appearance
|
||||
person: Person
|
||||
contacts: Contacts
|
||||
sessions: Sessions
|
||||
|
|
|
@ -8,6 +8,7 @@ ru:
|
|||
settings:
|
||||
credentials: Данные для входа
|
||||
profile: Публичный профиль
|
||||
appearance: Внешний вид
|
||||
person: Личность
|
||||
contacts: Контакты
|
||||
sessions: Сессии
|
||||
|
|
|
@ -32,6 +32,7 @@ Rails.application.routes.draw do
|
|||
|
||||
namespace :settings do
|
||||
resource :profile, only: %i[edit update]
|
||||
resource :appearance, only: :edit
|
||||
resource :person, only: %i[show new]
|
||||
resources :contacts, only: %i[index create destroy]
|
||||
resources :sessions, only: :index
|
||||
|
|
7
spec/policies/settings/appearance_policy_spec.rb
Normal file
7
spec/policies/settings/appearance_policy_spec.rb
Normal file
|
@ -0,0 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Settings::AppearancePolicy do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
22
spec/requests/settings/appearances/edit_spec.rb
Normal file
22
spec/requests/settings/appearances/edit_spec.rb
Normal file
|
@ -0,0 +1,22 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'GET /settings/appearance/edit' do
|
||||
before do
|
||||
sign_in current_account.user if current_account&.user
|
||||
get '/settings/appearance/edit'
|
||||
end
|
||||
|
||||
for_account_types nil do
|
||||
specify do
|
||||
expect(response).to have_http_status :forbidden
|
||||
end
|
||||
end
|
||||
|
||||
for_account_types :usual, :superuser do
|
||||
specify do
|
||||
expect(response).to have_http_status :ok
|
||||
end
|
||||
end
|
||||
end
|
Reference in a new issue