mirror of
https://github.com/astuto/astuto.git
synced 2025-12-15 03:07:52 +01:00
Apply single quote convention in Ruby code
This commit is contained in:
@@ -10,13 +10,13 @@ module Admin
|
|||||||
|
|
||||||
def authenticate_admin
|
def authenticate_admin
|
||||||
unless user_signed_in?
|
unless user_signed_in?
|
||||||
flash[:alert] = "You must be logged in to access this page."
|
flash[:alert] = 'You must be logged in to access this page.'
|
||||||
redirect_to new_user_session_path
|
redirect_to new_user_session_path
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
unless current_user.moderator? || current_user.admin?
|
unless current_user.moderator? || current_user.admin?
|
||||||
flash[:alert] = "You do not have the privilegies to access this page."
|
flash[:alert] = 'You do not have the privilegies to access this page.'
|
||||||
redirect_to root_path
|
redirect_to root_path
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -33,13 +33,13 @@ module Admin
|
|||||||
|
|
||||||
def authenticate_admin
|
def authenticate_admin
|
||||||
unless user_signed_in?
|
unless user_signed_in?
|
||||||
flash[:alert] = "You must be logged in to access this page."
|
flash[:alert] = 'You must be logged in to access this page.'
|
||||||
redirect_to new_user_session_path
|
redirect_to new_user_session_path
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
unless current_user.admin?
|
unless current_user.admin?
|
||||||
flash[:alert] = "You do not have the privilegies to access this page."
|
flash[:alert] = 'You do not have the privilegies to access this page.'
|
||||||
redirect_to root_path
|
redirect_to root_path
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@@ -51,7 +51,7 @@ module Admin
|
|||||||
user.skip_confirmation! # automatically confirm user email
|
user.skip_confirmation! # automatically confirm user email
|
||||||
|
|
||||||
if user.save
|
if user.save
|
||||||
flash[:notice] = translate_with_resource("create.success")
|
flash[:notice] = translate_with_resource('create.success')
|
||||||
redirect_to admin_user_path(user)
|
redirect_to admin_user_path(user)
|
||||||
else
|
else
|
||||||
render :new, locals: {
|
render :new, locals: {
|
||||||
@@ -73,7 +73,7 @@ module Admin
|
|||||||
user.skip_reconfirmation! # automatically reconfirm user email
|
user.skip_reconfirmation! # automatically reconfirm user email
|
||||||
|
|
||||||
if user.save
|
if user.save
|
||||||
flash[:notice] = translate_with_resource("update.success")
|
flash[:notice] = translate_with_resource('update.success')
|
||||||
redirect_to admin_user_path(user)
|
redirect_to admin_user_path(user)
|
||||||
else
|
else
|
||||||
render :new, locals: {
|
render :new, locals: {
|
||||||
|
|||||||
@@ -2,5 +2,5 @@
|
|||||||
<%= f.label field.attribute %>
|
<%= f.label field.attribute %>
|
||||||
</div>
|
</div>
|
||||||
<div class="field-unit__field">
|
<div class="field-unit__field">
|
||||||
<%= f.color_field field.attribute, style: "height: 40px" %>
|
<%= f.color_field field.attribute, style: 'height: 40px;' %>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1 +1,3 @@
|
|||||||
<div style="background-color: <%= field.to_s %>; width: 32px; height: 32px; border-radius: 32px;"></div>
|
<div
|
||||||
|
style="background-color: <%= field.to_s %>; width: 32px; height: 32px; border-radius: 32px;">
|
||||||
|
</div>
|
||||||
|
|||||||
@@ -1,2 +1,4 @@
|
|||||||
<div style="background-color: <%= field.to_s %>; width: 32px; height: 32px; border-radius: 32px;"></div>
|
<div
|
||||||
|
style="background-color: <%= field.to_s %>; width: 32px; height: 32px; border-radius: 32px;">
|
||||||
|
</div>
|
||||||
(<%= field.to_s %>)
|
(<%= field.to_s %>)
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
<% boards.each do |board| %>
|
<% boards.each do |board| %>
|
||||||
<li class="nav-item<%= board.id == @board.id ? ' active' : '' unless @board.nil? %>">
|
<li class="nav-item<%= board.id == @board.id ? ' active' : '' unless @board.nil? %>">
|
||||||
<%= link_to board.name, board_path(board), class: "nav-link" %>
|
<%= link_to board.name, board_path(board), class: 'nav-link' %>
|
||||||
</li>
|
</li>
|
||||||
<% end %>
|
<% end %>
|
||||||
@@ -1,35 +1,35 @@
|
|||||||
<nav class="navbar navbar-expand-lg navbar-light">
|
<nav class="navbar navbar-expand-lg navbar-light">
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<%= link_to "Astuto", root_path, class: "navbar-brand" %>
|
<%= link_to 'Astuto', root_path, class: 'navbar-brand' %>
|
||||||
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
|
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
|
||||||
<span class="navbar-toggler-icon"></span>
|
<span class="navbar-toggler-icon"></span>
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<div class="collapse navbar-collapse" id="navbarSupportedContent">
|
<div class="collapse navbar-collapse" id="navbarSupportedContent">
|
||||||
<ul class="navbar-nav nav-pills mr-auto">
|
<ul class="navbar-nav nav-pills mr-auto">
|
||||||
<%= render "layouts/boards_menu_section", boards: @boards unless @boards.nil? %>
|
<%= render 'layouts/boards_menu_section', boards: @boards unless @boards.nil? %>
|
||||||
</ul>
|
</ul>
|
||||||
<ul class="navbar-nav ml-auto">
|
<ul class="navbar-nav ml-auto">
|
||||||
<% if user_signed_in? %>
|
<% if user_signed_in? %>
|
||||||
<% if current_user.moderator? || current_user.admin? %>
|
<% if current_user.moderator? || current_user.admin? %>
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<%= link_to "Admin Panel", admin_root_path, class: "nav-link", 'data-turbolinks': 'false' %>
|
<%= link_to 'Admin Panel', admin_root_path, class: 'nav-link', 'data-turbolinks': 'false' %>
|
||||||
</li>
|
</li>
|
||||||
<% end %>
|
<% end %>
|
||||||
<li class="nav-item dropdown">
|
<li class="nav-item dropdown">
|
||||||
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||||
<%= image_tag(current_user.gravatar_url, class: "gravatar", alt: current_user.full_name, size: 24) %>
|
<%= image_tag(current_user.gravatar_url, class: 'gravatar', alt: current_user.full_name, size: 24) %>
|
||||||
<span class="fullname"><%= current_user.full_name %></span>
|
<span class="fullname"><%= current_user.full_name %></span>
|
||||||
</a>
|
</a>
|
||||||
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
|
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
|
||||||
<%= link_to "Profile settings", edit_user_registration_path, class: "dropdown-item" %>
|
<%= link_to 'Profile settings', edit_user_registration_path, class: 'dropdown-item' %>
|
||||||
<div class="dropdown-divider"></div>
|
<div class="dropdown-divider"></div>
|
||||||
<%= link_to "Sign out", destroy_user_session_path, method: :delete, class: "dropdown-item" %>
|
<%= link_to 'Sign out', destroy_user_session_path, method: :delete, class: 'dropdown-item' %>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
<% else %>
|
<% else %>
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<%= link_to "Sign in / Sign up", new_user_session_path, class: "nav-link" %>
|
<%= link_to 'Sign in / Sign up', new_user_session_path, class: 'nav-link' %>
|
||||||
</li>
|
</li>
|
||||||
<% end %>
|
<% end %>
|
||||||
</ul>
|
</ul>
|
||||||
|
|||||||
@@ -10,8 +10,8 @@
|
|||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<%= render "layouts/header" %>
|
<%= render 'layouts/header' %>
|
||||||
<%= render "layouts/alerts" %>
|
<%= render 'layouts/alerts' %>
|
||||||
|
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<%= yield %>
|
<%= yield %>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ Rails.application.routes.draw do
|
|||||||
root to: 'static_pages#home'
|
root to: 'static_pages#home'
|
||||||
|
|
||||||
namespace :admin do
|
namespace :admin do
|
||||||
root to: "boards#index"
|
root to: 'boards#index'
|
||||||
|
|
||||||
resources :boards
|
resources :boards
|
||||||
resources :post_statuses
|
resources :post_statuses
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
FactoryBot.define do
|
FactoryBot.define do
|
||||||
factory :board do
|
factory :board do
|
||||||
sequence(:name) { |n| "Board#{n}" }
|
sequence(:name) { |n| "Board#{n}" }
|
||||||
description { "My fantastic board" }
|
description { 'My fantastic board' }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
FactoryBot.define do
|
FactoryBot.define do
|
||||||
factory :post_status do
|
factory :post_status do
|
||||||
sequence(:name) { |n| "Post Status #{n}" }
|
sequence(:name) { |n| "Post Status #{n}" }
|
||||||
color { "#ffffff" }
|
color { '#ffffff' }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
FactoryBot.define do
|
FactoryBot.define do
|
||||||
factory :post do
|
factory :post do
|
||||||
title { "Post Title" }
|
title { 'Post Title' }
|
||||||
description { "Post Description" }
|
description { 'Post Description' }
|
||||||
board
|
board
|
||||||
user
|
user
|
||||||
post_status
|
post_status
|
||||||
|
|||||||
@@ -2,23 +2,23 @@ FactoryBot.define do
|
|||||||
factory :user do
|
factory :user do
|
||||||
sequence(:email) { |n| "user#{n}@example.com" }
|
sequence(:email) { |n| "user#{n}@example.com" }
|
||||||
|
|
||||||
full_name { "First Last" }
|
full_name { 'First Last' }
|
||||||
password { "password" }
|
password { 'password' }
|
||||||
end
|
end
|
||||||
|
|
||||||
factory :moderator, class: User do
|
factory :moderator, class: User do
|
||||||
sequence(:email) { |n| "mod#{n}@example.com" }
|
sequence(:email) { |n| "mod#{n}@example.com" }
|
||||||
|
|
||||||
full_name { "First Last" }
|
full_name { 'First Last' }
|
||||||
password { "password" }
|
password { 'password' }
|
||||||
role { "moderator" }
|
role { 'moderator' }
|
||||||
end
|
end
|
||||||
|
|
||||||
factory :admin, class: User do
|
factory :admin, class: User do
|
||||||
sequence(:email) { |n| "admin#{n}@example.com" }
|
sequence(:email) { |n| "admin#{n}@example.com" }
|
||||||
|
|
||||||
full_name { "First Last" }
|
full_name { 'First Last' }
|
||||||
password { "password" }
|
password { 'password' }
|
||||||
role { "admin" }
|
role { 'admin' }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ RSpec.describe Board, type: :model do
|
|||||||
|
|
||||||
it 'has a non-nil and non-empty name' do
|
it 'has a non-nil and non-empty name' do
|
||||||
nil_name_board = FactoryBot.build(:board, name: nil)
|
nil_name_board = FactoryBot.build(:board, name: nil)
|
||||||
empty_name_board = FactoryBot.build(:board, name: "")
|
empty_name_board = FactoryBot.build(:board, name: '')
|
||||||
|
|
||||||
expect(nil_name_board).to be_invalid
|
expect(nil_name_board).to be_invalid
|
||||||
expect(empty_name_board).to be_invalid
|
expect(empty_name_board).to be_invalid
|
||||||
@@ -24,7 +24,7 @@ RSpec.describe Board, type: :model do
|
|||||||
|
|
||||||
it 'has a description that can be nil or empty' do
|
it 'has a description that can be nil or empty' do
|
||||||
nil_description_board = FactoryBot.build(:board, description: nil)
|
nil_description_board = FactoryBot.build(:board, description: nil)
|
||||||
empty_description_board = FactoryBot.build(:board, description: "")
|
empty_description_board = FactoryBot.build(:board, description: '')
|
||||||
|
|
||||||
expect(nil_description_board).to be_valid
|
expect(nil_description_board).to be_valid
|
||||||
expect(empty_description_board).to be_valid
|
expect(empty_description_board).to be_valid
|
||||||
|
|||||||
@@ -9,17 +9,17 @@ RSpec.describe Post, type: :model do
|
|||||||
|
|
||||||
it 'has a non-nil and non-empty title' do
|
it 'has a non-nil and non-empty title' do
|
||||||
nil_post = FactoryBot.build(:post, title: nil)
|
nil_post = FactoryBot.build(:post, title: nil)
|
||||||
empty_post = FactoryBot.build(:post, title: "")
|
empty_post = FactoryBot.build(:post, title: '')
|
||||||
|
|
||||||
expect(nil_post).to be_invalid
|
expect(nil_post).to be_invalid
|
||||||
expect(empty_post).to be_invalid
|
expect(empty_post).to be_invalid
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'has a title between 4 and 64 characters' do
|
it 'has a title between 4 and 64 characters' do
|
||||||
too_short_post = FactoryBot.build(:post, title: "a" * 3)
|
too_short_post = FactoryBot.build(:post, title: 'a' * 3)
|
||||||
short_post = FactoryBot.build(:post, title: "a" * 4)
|
short_post = FactoryBot.build(:post, title: 'a' * 4)
|
||||||
long_post = FactoryBot.build(:post, title: "a" * 64)
|
long_post = FactoryBot.build(:post, title: 'a' * 64)
|
||||||
too_long_post = FactoryBot.build(:post, title: "a" * 65)
|
too_long_post = FactoryBot.build(:post, title: 'a' * 65)
|
||||||
|
|
||||||
expect(too_short_post).to be_invalid
|
expect(too_short_post).to be_invalid
|
||||||
expect(short_post).to be_valid
|
expect(short_post).to be_valid
|
||||||
@@ -29,7 +29,7 @@ RSpec.describe Post, type: :model do
|
|||||||
|
|
||||||
it 'has a description that can be nil or empty' do
|
it 'has a description that can be nil or empty' do
|
||||||
nil_description_post = FactoryBot.build(:post, description: nil)
|
nil_description_post = FactoryBot.build(:post, description: nil)
|
||||||
empty_description_post = FactoryBot.build(:post, description: "")
|
empty_description_post = FactoryBot.build(:post, description: '')
|
||||||
|
|
||||||
expect(nil_description_post).to be_valid
|
expect(nil_description_post).to be_valid
|
||||||
expect(empty_description_post).to be_valid
|
expect(empty_description_post).to be_valid
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ RSpec.describe PostStatus, type: :model do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it 'must have a name' do
|
it 'must have a name' do
|
||||||
empty_name = FactoryBot.build(:post_status, name: "")
|
empty_name = FactoryBot.build(:post_status, name: '')
|
||||||
nil_name = FactoryBot.build(:post_status, name: nil)
|
nil_name = FactoryBot.build(:post_status, name: nil)
|
||||||
|
|
||||||
expect(empty_name).to be_invalid
|
expect(empty_name).to be_invalid
|
||||||
@@ -23,11 +23,11 @@ RSpec.describe PostStatus, type: :model do
|
|||||||
|
|
||||||
it 'has a valid hex color' do
|
it 'has a valid hex color' do
|
||||||
nil_color = FactoryBot.build(:post_status, color: nil)
|
nil_color = FactoryBot.build(:post_status, color: nil)
|
||||||
empty_color = FactoryBot.build(:post_status, color: "")
|
empty_color = FactoryBot.build(:post_status, color: '')
|
||||||
invalid_color = FactoryBot.build(:post_status, color: "ffffff")
|
invalid_color = FactoryBot.build(:post_status, color: 'ffffff')
|
||||||
invalid_color2 = FactoryBot.build(:post_status, color: "#ffff")
|
invalid_color2 = FactoryBot.build(:post_status, color: '#ffff')
|
||||||
valid_color = FactoryBot.build(:post_status, color: "#fff")
|
valid_color = FactoryBot.build(:post_status, color: '#fff')
|
||||||
valid_color2 = FactoryBot.build(:post_status, color: "#ffffff")
|
valid_color2 = FactoryBot.build(:post_status, color: '#ffffff')
|
||||||
|
|
||||||
expect(nil_color).to be_invalid
|
expect(nil_color).to be_invalid
|
||||||
expect(empty_color).to be_invalid
|
expect(empty_color).to be_invalid
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ RSpec.describe User, type: :model do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it 'creates a user with role "user" by default' do
|
it 'creates a user with role "user" by default' do
|
||||||
expect(User.new.role).to eq("user")
|
expect(User.new.role).to eq('user')
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'can have the following roles: "user", "moderator" and "admin"' do
|
it 'can have the following roles: "user", "moderator" and "admin"' do
|
||||||
@@ -16,9 +16,9 @@ RSpec.describe User, type: :model do
|
|||||||
moderator = FactoryBot.build(:moderator)
|
moderator = FactoryBot.build(:moderator)
|
||||||
admin = FactoryBot.build(:admin)
|
admin = FactoryBot.build(:admin)
|
||||||
|
|
||||||
expect(user.role).to eq("user")
|
expect(user.role).to eq('user')
|
||||||
expect(moderator.role).to eq("moderator")
|
expect(moderator.role).to eq('moderator')
|
||||||
expect(admin.role).to eq("admin")
|
expect(admin.role).to eq('admin')
|
||||||
|
|
||||||
expect(user).to be_valid
|
expect(user).to be_valid
|
||||||
expect(moderator).to be_valid
|
expect(moderator).to be_valid
|
||||||
@@ -27,17 +27,17 @@ RSpec.describe User, type: :model do
|
|||||||
|
|
||||||
it 'has a non-nil and non-empty full name' do
|
it 'has a non-nil and non-empty full name' do
|
||||||
nil_name_user = FactoryBot.build(:user, full_name: nil)
|
nil_name_user = FactoryBot.build(:user, full_name: nil)
|
||||||
empty_name_user = FactoryBot.build(:user, full_name: "")
|
empty_name_user = FactoryBot.build(:user, full_name: '')
|
||||||
|
|
||||||
expect(nil_name_user).to be_invalid
|
expect(nil_name_user).to be_invalid
|
||||||
expect(empty_name_user).to be_invalid
|
expect(empty_name_user).to be_invalid
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'has a full name between 2 and 32 characters' do
|
it 'has a full name between 2 and 32 characters' do
|
||||||
too_short_user = FactoryBot.build(:user, full_name: "a" * 1)
|
too_short_user = FactoryBot.build(:user, full_name: 'a' * 1)
|
||||||
short_user = FactoryBot.build(:user, full_name: "a" * 2)
|
short_user = FactoryBot.build(:user, full_name: 'a' * 2)
|
||||||
long_user = FactoryBot.build(:user, full_name: "a" * 32)
|
long_user = FactoryBot.build(:user, full_name: 'a' * 32)
|
||||||
too_long_user = FactoryBot.build(:user, full_name: "a" * 33)
|
too_long_user = FactoryBot.build(:user, full_name: 'a' * 33)
|
||||||
|
|
||||||
expect(too_short_user).to be_invalid
|
expect(too_short_user).to be_invalid
|
||||||
expect(short_user).to be_valid
|
expect(short_user).to be_valid
|
||||||
@@ -46,7 +46,7 @@ RSpec.describe User, type: :model do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it 'has an email that must contain a @' do
|
it 'has an email that must contain a @' do
|
||||||
invalid_email_user = FactoryBot.build(:user, email: "invalid.email")
|
invalid_email_user = FactoryBot.build(:user, email: 'invalid.email')
|
||||||
|
|
||||||
expect(invalid_email_user).to be_invalid
|
expect(invalid_email_user).to be_invalid
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user