Skip to content

Commit

Permalink
Handle flash messages on welcome page (#1295)
Browse files Browse the repository at this point in the history
  • Loading branch information
hectorcorrea authored Feb 7, 2025
1 parent 4c194ae commit bf736f7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
9 changes: 8 additions & 1 deletion app/views/layouts/welcome.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<meta name="viewport" content="width=device-width,initial-scale=1">
<%= csrf_meta_tags %>
<%= csp_meta_tag %>

<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/font/bootstrap-icons.css">

Expand All @@ -33,6 +33,13 @@
<%= render partial: 'shared/banner' %>
<%= render partial: 'shared/header' %>
<%= render partial: 'shared/emulator' %>

<% if flash[:notice] %>
<div class="alert alert-primary" role="alert" ><%= flash[:notice] %></div>
<% elsif flash[:alert] %>
<div class="alert alert-warning" role="alert"><%= flash[:alert] %></div>
<% end %>

<%= yield %>

<div class="welcome-footer"><%= render partial: 'shared/footer' %></div>
Expand Down
9 changes: 9 additions & 0 deletions spec/system/welcome_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -273,5 +273,14 @@
expect(page).to have_content "Administration"
end
end

context "flash message" do
let(:non_admin_user) { FactoryBot.create(:user) }
it "shows the flash message" do
sign_in non_admin_user
visit "/projects"
expect(page).to have_content("Access Denied")
end
end
end
end

0 comments on commit bf736f7

Please sign in to comment.