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
|
||||
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
|
||||
return
|
||||
end
|
||||
|
||||
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
|
||||
return
|
||||
end
|
||||
|
||||
@@ -33,13 +33,13 @@ module Admin
|
||||
|
||||
def authenticate_admin
|
||||
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
|
||||
return
|
||||
end
|
||||
|
||||
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
|
||||
return
|
||||
end
|
||||
@@ -51,7 +51,7 @@ module Admin
|
||||
user.skip_confirmation! # automatically confirm user email
|
||||
|
||||
if user.save
|
||||
flash[:notice] = translate_with_resource("create.success")
|
||||
flash[:notice] = translate_with_resource('create.success')
|
||||
redirect_to admin_user_path(user)
|
||||
else
|
||||
render :new, locals: {
|
||||
@@ -73,7 +73,7 @@ module Admin
|
||||
user.skip_reconfirmation! # automatically reconfirm user email
|
||||
|
||||
if user.save
|
||||
flash[:notice] = translate_with_resource("update.success")
|
||||
flash[:notice] = translate_with_resource('update.success')
|
||||
redirect_to admin_user_path(user)
|
||||
else
|
||||
render :new, locals: {
|
||||
|
||||
@@ -2,5 +2,5 @@
|
||||
<%= f.label field.attribute %>
|
||||
</div>
|
||||
<div class="field-unit__field">
|
||||
<%= f.color_field field.attribute, style: "height: 40px" %>
|
||||
<%= f.color_field field.attribute, style: 'height: 40px;' %>
|
||||
</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 %>)
|
||||
@@ -1,5 +1,5 @@
|
||||
<% boards.each do |board| %>
|
||||
<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>
|
||||
<% end %>
|
||||
@@ -1,35 +1,35 @@
|
||||
<nav class="navbar navbar-expand-lg navbar-light">
|
||||
<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">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
|
||||
<div class="collapse navbar-collapse" id="navbarSupportedContent">
|
||||
<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 class="navbar-nav ml-auto">
|
||||
<% if user_signed_in? %>
|
||||
<% if current_user.moderator? || current_user.admin? %>
|
||||
<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>
|
||||
<% end %>
|
||||
<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">
|
||||
<%= 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>
|
||||
</a>
|
||||
<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>
|
||||
<%= 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>
|
||||
</li>
|
||||
<% else %>
|
||||
<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>
|
||||
<% end %>
|
||||
</ul>
|
||||
|
||||
@@ -10,8 +10,8 @@
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<%= render "layouts/header" %>
|
||||
<%= render "layouts/alerts" %>
|
||||
<%= render 'layouts/header' %>
|
||||
<%= render 'layouts/alerts' %>
|
||||
|
||||
<div class="container">
|
||||
<%= yield %>
|
||||
|
||||
@@ -2,7 +2,7 @@ Rails.application.routes.draw do
|
||||
root to: 'static_pages#home'
|
||||
|
||||
namespace :admin do
|
||||
root to: "boards#index"
|
||||
root to: 'boards#index'
|
||||
|
||||
resources :boards
|
||||
resources :post_statuses
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
FactoryBot.define do
|
||||
factory :board do
|
||||
sequence(:name) { |n| "Board#{n}" }
|
||||
description { "My fantastic board" }
|
||||
description { 'My fantastic board' }
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
FactoryBot.define do
|
||||
factory :post_status do
|
||||
sequence(:name) { |n| "Post Status #{n}" }
|
||||
color { "#ffffff" }
|
||||
color { '#ffffff' }
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
FactoryBot.define do
|
||||
factory :post do
|
||||
title { "Post Title" }
|
||||
description { "Post Description" }
|
||||
title { 'Post Title' }
|
||||
description { 'Post Description' }
|
||||
board
|
||||
user
|
||||
post_status
|
||||
|
||||
@@ -2,23 +2,23 @@ FactoryBot.define do
|
||||
factory :user do
|
||||
sequence(:email) { |n| "user#{n}@example.com" }
|
||||
|
||||
full_name { "First Last" }
|
||||
password { "password" }
|
||||
full_name { 'First Last' }
|
||||
password { 'password' }
|
||||
end
|
||||
|
||||
factory :moderator, class: User do
|
||||
sequence(:email) { |n| "mod#{n}@example.com" }
|
||||
|
||||
full_name { "First Last" }
|
||||
password { "password" }
|
||||
role { "moderator" }
|
||||
full_name { 'First Last' }
|
||||
password { 'password' }
|
||||
role { 'moderator' }
|
||||
end
|
||||
|
||||
factory :admin, class: User do
|
||||
sequence(:email) { |n| "admin#{n}@example.com" }
|
||||
|
||||
full_name { "First Last" }
|
||||
password { "password" }
|
||||
role { "admin" }
|
||||
full_name { 'First Last' }
|
||||
password { 'password' }
|
||||
role { 'admin' }
|
||||
end
|
||||
end
|
||||
|
||||
@@ -9,7 +9,7 @@ RSpec.describe Board, type: :model do
|
||||
|
||||
it 'has a non-nil and non-empty name' do
|
||||
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(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
|
||||
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(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
|
||||
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(empty_post).to be_invalid
|
||||
end
|
||||
|
||||
it 'has a title between 4 and 64 characters' do
|
||||
too_short_post = FactoryBot.build(:post, title: "a" * 3)
|
||||
short_post = FactoryBot.build(:post, title: "a" * 4)
|
||||
long_post = FactoryBot.build(:post, title: "a" * 64)
|
||||
too_long_post = FactoryBot.build(:post, title: "a" * 65)
|
||||
too_short_post = FactoryBot.build(:post, title: 'a' * 3)
|
||||
short_post = FactoryBot.build(:post, title: 'a' * 4)
|
||||
long_post = FactoryBot.build(:post, title: 'a' * 64)
|
||||
too_long_post = FactoryBot.build(:post, title: 'a' * 65)
|
||||
|
||||
expect(too_short_post).to be_invalid
|
||||
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
|
||||
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(empty_description_post).to be_valid
|
||||
|
||||
@@ -8,7 +8,7 @@ RSpec.describe PostStatus, type: :model do
|
||||
end
|
||||
|
||||
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)
|
||||
|
||||
expect(empty_name).to be_invalid
|
||||
@@ -23,11 +23,11 @@ RSpec.describe PostStatus, type: :model do
|
||||
|
||||
it 'has a valid hex color' do
|
||||
nil_color = FactoryBot.build(:post_status, color: nil)
|
||||
empty_color = FactoryBot.build(:post_status, color: "")
|
||||
invalid_color = FactoryBot.build(:post_status, color: "ffffff")
|
||||
invalid_color2 = FactoryBot.build(:post_status, color: "#ffff")
|
||||
valid_color = FactoryBot.build(:post_status, color: "#fff")
|
||||
valid_color2 = FactoryBot.build(:post_status, color: "#ffffff")
|
||||
empty_color = FactoryBot.build(:post_status, color: '')
|
||||
invalid_color = FactoryBot.build(:post_status, color: 'ffffff')
|
||||
invalid_color2 = FactoryBot.build(:post_status, color: '#ffff')
|
||||
valid_color = FactoryBot.build(:post_status, color: '#fff')
|
||||
valid_color2 = FactoryBot.build(:post_status, color: '#ffffff')
|
||||
|
||||
expect(nil_color).to be_invalid
|
||||
expect(empty_color).to be_invalid
|
||||
|
||||
@@ -8,7 +8,7 @@ RSpec.describe User, type: :model do
|
||||
end
|
||||
|
||||
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
|
||||
|
||||
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)
|
||||
admin = FactoryBot.build(:admin)
|
||||
|
||||
expect(user.role).to eq("user")
|
||||
expect(moderator.role).to eq("moderator")
|
||||
expect(admin.role).to eq("admin")
|
||||
expect(user.role).to eq('user')
|
||||
expect(moderator.role).to eq('moderator')
|
||||
expect(admin.role).to eq('admin')
|
||||
|
||||
expect(user).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
|
||||
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(empty_name_user).to be_invalid
|
||||
end
|
||||
|
||||
it 'has a full name between 2 and 32 characters' do
|
||||
too_short_user = FactoryBot.build(:user, full_name: "a" * 1)
|
||||
short_user = FactoryBot.build(:user, full_name: "a" * 2)
|
||||
long_user = FactoryBot.build(:user, full_name: "a" * 32)
|
||||
too_long_user = FactoryBot.build(:user, full_name: "a" * 33)
|
||||
too_short_user = FactoryBot.build(:user, full_name: 'a' * 1)
|
||||
short_user = FactoryBot.build(:user, full_name: 'a' * 2)
|
||||
long_user = FactoryBot.build(:user, full_name: 'a' * 32)
|
||||
too_long_user = FactoryBot.build(:user, full_name: 'a' * 33)
|
||||
|
||||
expect(too_short_user).to be_invalid
|
||||
expect(short_user).to be_valid
|
||||
@@ -46,7 +46,7 @@ RSpec.describe User, type: :model do
|
||||
end
|
||||
|
||||
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
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user