mirror of
https://github.com/Freika/dawarich.git
synced 2026-01-10 17:21:38 -05:00
Update some tests and svg icons
This commit is contained in:
parent
9bc0e2accc
commit
54661a1d52
7 changed files with 31 additions and 62 deletions
File diff suppressed because one or more lines are too long
1
app/assets/svg/icons/lucide/outline/circle-alert.svg
Normal file
1
app/assets/svg/icons/lucide/outline/circle-alert.svg
Normal file
|
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-circle-alert-icon lucide-circle-alert"><circle cx="12" cy="12" r="10"/><line x1="12" x2="12" y1="8" y2="12"/><line x1="12" x2="12.01" y1="16" y2="16"/></svg>
|
||||
|
After Width: | Height: | Size: 360 B |
1
app/assets/svg/icons/lucide/outline/circle-check.svg
Normal file
1
app/assets/svg/icons/lucide/outline/circle-check.svg
Normal file
|
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-circle-check-icon lucide-circle-check"><circle cx="12" cy="12" r="10"/><path d="m9 12 2 2 4-4"/></svg>
|
||||
|
After Width: | Height: | Size: 305 B |
1
app/assets/svg/icons/lucide/outline/circle-x.svg
Normal file
1
app/assets/svg/icons/lucide/outline/circle-x.svg
Normal file
|
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-circle-x-icon lucide-circle-x"><circle cx="12" cy="12" r="10"/><path d="m15 9-6 6"/><path d="m9 9 6 6"/></svg>
|
||||
|
After Width: | Height: | Size: 313 B |
|
|
@ -3,37 +3,21 @@
|
|||
module ApplicationHelper
|
||||
def flash_alert_class(type)
|
||||
case type.to_sym
|
||||
when :notice, :success
|
||||
'alert-success'
|
||||
when :alert, :error
|
||||
'alert-error'
|
||||
when :warning
|
||||
'alert-warning'
|
||||
when :info
|
||||
'alert-info'
|
||||
else
|
||||
'alert-info'
|
||||
when :notice, :success then 'alert-success'
|
||||
when :alert, :error then 'alert-error'
|
||||
when :warning then 'alert-warning'
|
||||
when :info then 'alert-info'
|
||||
else 'alert-info'
|
||||
end
|
||||
end
|
||||
|
||||
def flash_icon(type)
|
||||
case type.to_sym
|
||||
when :notice, :success
|
||||
content_tag :svg, class: 'w-5 h-5 flex-shrink-0', fill: 'currentColor', viewBox: '0 0 20 20' do
|
||||
content_tag :path, '', fill_rule: 'evenodd', d: 'M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z', clip_rule: 'evenodd'
|
||||
end
|
||||
when :alert, :error
|
||||
content_tag :svg, class: 'w-5 h-5 flex-shrink-0', fill: 'currentColor', viewBox: '0 0 20 20' do
|
||||
content_tag :path, '', fill_rule: 'evenodd', d: 'M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7 4a1 1 0 11-2 0 1 1 0 012 0zm-1-9a1 1 0 00-1 1v4a1 1 0 102 0V6a1 1 0 00-1-1z', clip_rule: 'evenodd'
|
||||
end
|
||||
when :warning
|
||||
content_tag :svg, class: 'w-5 h-5 flex-shrink-0', fill: 'currentColor', viewBox: '0 0 20 20' do
|
||||
content_tag :path, '', fill_rule: 'evenodd', d: 'M8.257 3.099c.765-1.36 2.722-1.36 3.486 0l5.58 9.92c.75 1.334-.213 2.98-1.742 2.98H4.42c-1.53 0-2.493-1.646-1.743-2.98l5.58-9.92zM11 13a1 1 0 11-2 0 1 1 0 012 0zm-1-8a1 1 0 00-1 1v3a1 1 0 002 0V6a1 1 0 00-1-1z', clip_rule: 'evenodd'
|
||||
end
|
||||
when :notice, :success then icon 'circle-check'
|
||||
when :alert, :error then icon 'circle-x'
|
||||
when :warning then icon 'circle-alert'
|
||||
else
|
||||
content_tag :svg, class: 'w-5 h-5 flex-shrink-0', fill: 'currentColor', viewBox: '0 0 20 20' do
|
||||
content_tag :path, '', fill_rule: 'evenodd', d: 'M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a1 1 0 000 2v3a1 1 0 001 1h1a1 1 0 100-2v-3a1 1 0 00-1-1H9z', clip_rule: 'evenodd'
|
||||
end
|
||||
icon 'info'
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -54,7 +54,6 @@
|
|||
|
||||
<div class="space-y-3">
|
||||
<% @members.each do |member| %>
|
||||
<!-- DaisyUI Card for each member -->
|
||||
<div class="card bg-base-200 shadow-sm">
|
||||
<div class="card-body p-4">
|
||||
<div class="flex items-center justify-between">
|
||||
|
|
|
|||
|
|
@ -14,25 +14,8 @@ RSpec.describe 'Families', type: :request do
|
|||
sign_in user
|
||||
end
|
||||
|
||||
describe 'GET /families' do
|
||||
context 'when user is not in a family' do
|
||||
let(:user_without_family) { create(:user) }
|
||||
|
||||
before { sign_in user_without_family }
|
||||
|
||||
it 'renders the index page' do
|
||||
get '/families'
|
||||
expect(response).to have_http_status(:ok)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when user is in a family' do
|
||||
it 'redirects to family show page' do
|
||||
get '/families'
|
||||
expect(response).to redirect_to(family_path(family))
|
||||
end
|
||||
end
|
||||
end
|
||||
# GET /families route no longer exists - we use singular resource /family
|
||||
# Users without a family should go to /family/new instead
|
||||
|
||||
describe 'GET /family' do
|
||||
it 'shows the family page' do
|
||||
|
|
@ -45,34 +28,34 @@ RSpec.describe 'Families', type: :request do
|
|||
|
||||
before { sign_in outsider }
|
||||
|
||||
it 'redirects to families index' do
|
||||
it 'redirects to new family path' do
|
||||
get "/family"
|
||||
expect(response).to redirect_to(family_path)
|
||||
expect(response).to redirect_to(new_family_path)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'GET /families/new' do
|
||||
describe 'GET /family/new' do
|
||||
context 'when user is not in a family' do
|
||||
let(:user_without_family) { create(:user) }
|
||||
|
||||
before { sign_in user_without_family }
|
||||
|
||||
it 'renders the new family form' do
|
||||
get '/families/new'
|
||||
get '/family/new'
|
||||
expect(response).to have_http_status(:ok)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when user is already in a family' do
|
||||
it 'redirects to family show page' do
|
||||
get '/families/new'
|
||||
expect(response).to redirect_to(family_path(family))
|
||||
get '/family/new'
|
||||
expect(response).to redirect_to(family_path)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'POST /families' do
|
||||
describe 'POST /family' do
|
||||
let(:user_without_family) { create(:user) }
|
||||
|
||||
before { sign_in user_without_family }
|
||||
|
|
@ -82,13 +65,13 @@ RSpec.describe 'Families', type: :request do
|
|||
|
||||
it 'creates a new family' do
|
||||
expect do
|
||||
post '/families', params: valid_attributes
|
||||
post '/family', params: valid_attributes
|
||||
end.to change(Family, :count).by(1)
|
||||
end
|
||||
|
||||
it 'creates a family membership for the user' do
|
||||
expect do
|
||||
post '/families', params: valid_attributes
|
||||
post '/family', params: valid_attributes
|
||||
end.to change(FamilyMembership, :count).by(1)
|
||||
end
|
||||
|
||||
|
|
@ -106,7 +89,7 @@ RSpec.describe 'Families', type: :request do
|
|||
|
||||
it 'does not create a family' do
|
||||
expect do
|
||||
post '/families', params: invalid_attributes
|
||||
post '/family', params: invalid_attributes
|
||||
end.not_to change(Family, :count)
|
||||
end
|
||||
|
||||
|
|
@ -117,7 +100,7 @@ RSpec.describe 'Families', type: :request do
|
|||
end
|
||||
end
|
||||
|
||||
describe 'GET /families/:id/edit' do
|
||||
describe 'GET /family/edit' do
|
||||
it 'shows the edit form' do
|
||||
get "/family/edit"
|
||||
expect(response).to have_http_status(:ok)
|
||||
|
|
@ -134,7 +117,7 @@ RSpec.describe 'Families', type: :request do
|
|||
end
|
||||
end
|
||||
|
||||
describe 'PATCH /families/:id' do
|
||||
describe 'PATCH /family' do
|
||||
let(:new_attributes) { { family: { name: 'Updated Family Name' } } }
|
||||
|
||||
context 'with valid attributes' do
|
||||
|
|
@ -142,7 +125,7 @@ RSpec.describe 'Families', type: :request do
|
|||
patch "/family", params: new_attributes
|
||||
family.reload
|
||||
expect(family.name).to eq('Updated Family Name')
|
||||
expect(response).to redirect_to(family_path(family))
|
||||
expect(response).to redirect_to(family_path)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -169,7 +152,7 @@ RSpec.describe 'Families', type: :request do
|
|||
end
|
||||
end
|
||||
|
||||
describe 'DELETE /families/:id' do
|
||||
describe 'DELETE /family' do
|
||||
context 'when family has only one member' do
|
||||
it 'deletes the family' do
|
||||
expect do
|
||||
|
|
@ -188,7 +171,7 @@ RSpec.describe 'Families', type: :request do
|
|||
expect do
|
||||
delete "/family"
|
||||
end.not_to change(Family, :count)
|
||||
expect(response).to redirect_to(family_path(family))
|
||||
expect(response).to redirect_to(family_path)
|
||||
follow_redirect!
|
||||
expect(response.body).to include('Cannot delete family with members')
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue