Skip to content

Commit

Permalink
Apply rubocop/haml-lint suggestions
Browse files Browse the repository at this point in the history
Signed-off-by: Georg Pfuetzenreuter <mail@georg-pfuetzenreuter.net>
  • Loading branch information
tacerus committed May 30, 2024
1 parent 8c41eda commit d21260f
Show file tree
Hide file tree
Showing 10 changed files with 72 additions and 71 deletions.
2 changes: 1 addition & 1 deletion app/controllers/pastes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class PastesController < ApplicationController
after_action :verify_policy_scoped, only: :index
# Set up activestorage for development
before_action -> { ActiveStorage::Current.url_options = { host: request.base_url } },
if: -> { Rails.env.development? || Rails.env.test? }
if: -> { Rails.env.local? }

def index
@pastes = if params[:user]
Expand Down
3 changes: 2 additions & 1 deletion app/helpers/pastes_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ def media(attachment)
return video(attachment) if attachment.video?
return audio(attachment) if attachment.audio?
return text(attachment) if text?(attachment)
return document(attachment) if attachment.representable?

document(attachment) if attachment.representable?
end

def media?(attachment)
Expand Down
6 changes: 3 additions & 3 deletions app/views/auths/index.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
%i.fas.fa-clipboard
.visually-hidden= t(:copy_to_clipboard)
.dropdown.ms-2
%button.btn.btn-secondary{ type: 'button', 'aria-expanded': 'false',
'data-bs-toggle': 'dropdown',
title: t(:options) }
%button.btn.btn-secondary{type: 'button', 'aria-expanded': 'false',
'data-bs-toggle': 'dropdown',
title: t(:options)}
%i.fas.fa-ellipsis-vertical
.visually-hidden= t(:options)
%ul.dropdown-menu.dropdown-menu-end
Expand Down
20 changes: 10 additions & 10 deletions app/views/layouts/_navbar.html.haml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
%nav.navbar.navbar-expand-sm
.container-fluid
= render 'theme/brand'
%button.navbar-toggler{ data: { bs: { target: '#navbar-content',
toggle: 'collapse' } },
type: 'button',
aria: { controls: 'navbar-content',
expanded: 'false',
label: t(:toggle_navigation) } }
%button.navbar-toggler{data: { bs: { target: '#navbar-content',
toggle: 'collapse' } },
type: 'button',
aria: { controls: 'navbar-content',
expanded: 'false',
label: t(:toggle_navigation) }}
%span.navbar-toggler-icon
.collapse.navbar-collapse#navbar-content
%ul.navbar-nav.me-auto
Expand All @@ -17,9 +17,9 @@
.navbar-nav
- if user_signed_in?
.dropdown.nav-item
%a.nav-link.dropdown-toggle{ 'aria-expanded': 'false', href: '#',
role: 'button',
'data-bs-toggle': 'dropdown' }
%a.nav-link.dropdown-toggle{'aria-expanded': 'false', href: '#',
role: 'button',
'data-bs-toggle': 'dropdown'}
= avatar current_user
= current_user.username
%ul.dropdown-menu.dropdown-menu-end
Expand All @@ -40,7 +40,7 @@
- if Rails.env.development?
= render 'sessions/form', provider: { id: 'developer',
name: 'Developer' }
- auth&.each do |_, value|
- auth&.each_value do |value|
= render 'sessions/form', provider: { id: value[:name] }
- if (sign_up_link = Rails.configuration.site[:sign_up_link])
= link_to t(:sign_up), sign_up_link,
Expand Down
10 changes: 5 additions & 5 deletions app/views/layouts/application.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@
- flash.each do |type, text|
- type = 'success' if type == 'notice'
- type = 'danger' if type == 'alert'
%div{ class: "toast align-items-center text-bg-#{type} border-0 show",
aria: { atomic: 'true', live: 'assertive' }, role: 'alert' }
%div{class: "toast align-items-center text-bg-#{type} border-0 show",
aria: { atomic: 'true', live: 'assertive' }, role: 'alert'}
.d-flex
.toast-body
= text
%button.btn-close.me-2.m-auto{ 'aria-label': t(:close),
'data-bs-dismiss': 'toast',
type: 'button' }
%button.btn-close.me-2.m-auto{'aria-label': t(:close),
'data-bs-dismiss': 'toast',
type: 'button'}
%main.flex-fill.d-flex.h-100
.container.my-3.flex-fill
= yield
Expand Down
18 changes: 9 additions & 9 deletions app/views/pastes/new.html.haml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.h-100{ data: { controller: 'editor',
'editor-filled-class': 'file-field-filled',
'editor-full-size-class': 'full-size' } }
.h-100{data: { controller: 'editor',
'editor-filled-class': 'file-field-filled',
'editor-full-size-class': 'full-size' }}
= form_for @paste, html: { 'data-action': 'editor#submit',
class: 'd-flex flex-column h-100' } do |f|
- @paste.errors.full_messages.each do |message|
Expand Down Expand Up @@ -29,20 +29,20 @@
class: 'form-control border-0 rounded-0 rounded-bottom',
'data-editor-target': 'textarea'
.float-end.sticky-top
%a.btn.btn-sm.btn-expand{ data: { action: 'editor#expand' },
title: t(:expand) }
%a.btn.btn-sm.btn-expand{data: { action: 'editor#expand' },
title: t(:expand)}
%i.fas.fa-up-right-and-down-left-from-center
%a.btn.btn-sm.btn-contract{ data: { action: 'editor#contract' },
title: t(:contract) }
%a.btn.btn-sm.btn-contract{data: { action: 'editor#contract' },
title: t(:contract)}
%i.fas.fa-down-left-and-up-right-to-center
.input-group.mt-3
= f.file_field :content,
class: 'form-control',
data: { 'editor-target': 'file',
action: 'editor#hideText' }
#file-remove-button
%a.btn.btn-secondary.border{ data: { 'editor-target': 'clearFileButton',
action: 'editor#clearFile' } }
%a.btn.btn-secondary.border{data: { 'editor-target': 'clearFileButton',
action: 'editor#clearFile' }}
Clear
.d-flex.justify-content-between.align-items-center.mt-3
.form-check
Expand Down
18 changes: 9 additions & 9 deletions app/views/pastes/show.html.haml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
- exts = extensions(@paste.content.attachment)
.card{ data: { controller: 'editor',
'editor-read-only-value': 'true',
'editor-extensions-value': exts,
'editor-full-size-class': 'full-size',
'editor-target': 'fullSize' } }
.card{data: { controller: 'editor',
'editor-read-only-value': 'true',
'editor-extensions-value': exts,
'editor-full-size-class': 'full-size',
'editor-target': 'fullSize' }}
.card-header.pe-1
.d-flex.justify-content-between.align-items-center.flex-wrap
.info
Expand All @@ -27,10 +27,10 @@
method: :delete,
class: 'btn p-0 text-danger'
%li.list-inline-item
%a.btn.btn-sm.btn-expand{ data: { action: 'editor#expand' },
title: t(:expand) }
%a.btn.btn-sm.btn-expand{data: { action: 'editor#expand' },
title: t(:expand)}
%i.fas.fa-up-right-and-down-left-from-center
%a.btn.btn-sm.btn-contract{ data: { action: 'editor#contract' },
title: t(:contract) }
%a.btn.btn-sm.btn-contract{data: { action: 'editor#contract' },
title: t(:contract)}
%i.fas.fa-down-left-and-up-right-to-center
= represent @paste.content.attachment
8 changes: 4 additions & 4 deletions spec/features/auths_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
OmniAuth.config.test_mode = true
OmniAuth.config.add_mock(:suse, { uid: '12345', info: { email: 'test@opensuse.org', nickname: 'testing' } })
visit '/'
click_button 'Log in'
click_link_or_button 'Log in'
end

it 'tries to access auth keys' do
Expand All @@ -28,7 +28,7 @@
visit '/auths'
click_on 'Create key'
fill_in 'auth_name', with: 'new_auth'
click_button 'Save'
click_link_or_button 'Save'
end

it 'creates auth key with correct data' do
Expand All @@ -38,7 +38,7 @@
it 'removes the additional auth' do
within all('.list-group-item .dropdown').last do
click_on 'Options'
click_button 'Remove the key'
click_link_or_button 'Remove the key'
end
expect(page).to have_text('Key was successfully destroyed.')
end
Expand All @@ -47,7 +47,7 @@
it 'removes the auth the user is logged in as' do
visit '/auths'
click_on 'Options'
expect(page).not_to have_text('Remove the key')
expect(page).to have_no_text('Remove the key')
end
end
end
52 changes: 26 additions & 26 deletions spec/features/pastes_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
context 'when an anonymous user creates a new paste' do
it 'without entering any content' do
visit '/'
click_button 'Save'
click_link_or_button 'Save'
expect(page).to have_text("Content can't be blank")
end

it 'with text file content' do
visit '/'
attach_file('paste_content', 'spec/fixtures/files/file.txt')
click_button 'Save'
click_link_or_button 'Save'
expect(page).to have_text('🌶️ Hot')
end

Expand All @@ -24,26 +24,26 @@
end

it 'creates a valid paste' do
click_button 'Save'
click_link_or_button 'Save'
expect(page).to have_text('John')
end

it 'without changing the private state' do
click_button 'Save'
click_link_or_button 'Save'
expect(page).to have_text('Private')
end

it 'with private selected' do
check('paste_private')
click_button 'Save'
click_link_or_button 'Save'
expect(page).to have_text('Private')
end

it 'with private selected cannot see it in the list' do
check('paste_private')
click_button 'Save'
click_link_or_button 'Save'
visit '/pastes'
expect(page).not_to have_text('Anonymous paste created by')
expect(page).to have_no_text('Anonymous paste created by')
end
end

Expand All @@ -52,11 +52,11 @@
visit '/'
fill_in('paste_code', with: 'John')
uncheck('paste_private')
click_button 'Save'
click_link_or_button 'Save'
end

it 'creates a new paste' do
expect(page).not_to have_text('Private')
expect(page).to have_no_text('Private')
end

it 'can see it in the list' do
Expand All @@ -67,7 +67,7 @@
it 'cannot destroy their own paste' do
visit '/pastes'
click_on 'paste created by'
expect(page).not_to have_text('Remove')
expect(page).to have_no_text('Remove')
end
end
end
Expand All @@ -77,61 +77,61 @@
OmniAuth.config.test_mode = true
OmniAuth.config.add_mock(:suse, { uid: '12345', info: { email: 'test@opensuse.org', nickname: 'testing' } })
visit '/'
click_button 'Log in'
click_link_or_button 'Log in'
end

it 'without entering any content' do
visit '/'
click_button 'Save'
click_link_or_button 'Save'
expect(page).to have_text("Content can't be blank")
end

it 'with text file content' do
visit '/'
attach_file('paste_content', 'spec/fixtures/files/file.txt')
click_button 'Save'
click_link_or_button 'Save'
expect(page).to have_text('🌶️ Hot')
end

it 'with shell script file content' do
visit '/'
attach_file('paste_content', 'spec/fixtures/files/file.sh')
click_button 'Save'
click_link_or_button 'Save'
expect(page).to have_text('echo "🌶️ Hot"')
end

it 'with image file content' do
visit '/'
attach_file('paste_content', 'spec/fixtures/files/file.png')
click_button 'Save'
click_link_or_button 'Save'
expect(page).to have_css('.card-body img')
end

it 'with video file content' do
visit '/'
attach_file('paste_content', 'spec/fixtures/files/file.webm')
click_button 'Save'
click_link_or_button 'Save'
expect(page).to have_css('.card-body video')
end

it 'with audio file content' do
visit '/'
attach_file('paste_content', 'spec/fixtures/files/file.flac')
click_button 'Save'
click_link_or_button 'Save'
expect(page).to have_css('.card-body audio')
end

it 'with document file content' do
visit '/'
attach_file('paste_content', 'spec/fixtures/files/file.pdf')
click_button 'Save'
click_link_or_button 'Save'
expect(page).to have_text('You can only see the full document, if you download it')
end

it 'with unrepresentable file content' do
visit '/'
attach_file('paste_content', 'spec/fixtures/files/file.tar.xz')
click_button 'Save'
click_link_or_button 'Save'
expect(page).to have_css('.card-body a')
end

Expand All @@ -142,24 +142,24 @@
end

it 'creates a valid paste' do
click_button 'Save'
click_link_or_button 'Save'
expect(page).to have_text('John')
end

it 'without changing the private state' do
click_button 'Save'
click_link_or_button 'Save'
expect(page).to have_text('Private')
end

it 'with private selected' do
check('paste_private')
click_button 'Save'
click_link_or_button 'Save'
expect(page).to have_text('Private')
end

it 'with private selected can see it in the list' do
check('paste_private')
click_button 'Save'
click_link_or_button 'Save'
visit '/pastes'
expect(page).to have_text('paste Private created by')
end
Expand All @@ -170,11 +170,11 @@
visit '/'
fill_in('paste_code', with: 'John')
uncheck('paste_private')
click_button 'Save'
click_link_or_button 'Save'
end

it 'creates a new paste' do
expect(page).not_to have_text('Private')
expect(page).to have_no_text('Private')
end

it 'can see it in the list' do
Expand All @@ -185,7 +185,7 @@
it 'can destroy their own paste' do
visit '/pastes'
click_on 'paste created by'
click_button 'Remove'
click_link_or_button 'Remove'
expect(page).to have_text('Paste was successfully destroyed.')
end
end
Expand Down
Loading

0 comments on commit d21260f

Please sign in to comment.