Skip to content

Commit

Permalink
adding header changes (#1883)
Browse files Browse the repository at this point in the history
  • Loading branch information
20LM22 authored Aug 2, 2024
1 parent 5c512cb commit 72a310f
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 6 deletions.
9 changes: 9 additions & 0 deletions app/assets/stylesheets/application.scss
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@
@import "components/users.scss";
@import "components/nav.scss";


#pdc-discovery-label {
float: left;
margin: 0 auto;
height: 40px;
line-height: 40px;
text-align: center;
}

.welcome-headers, #welcome-to-pdc {
font-size: 2rem !important;
}
Expand Down
18 changes: 13 additions & 5 deletions app/views/shared/_header.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,19 @@
<% if current_user && (current_user.super_admin? || current_user.moderator?) %>
<%= render 'shared/admin_actions' %>
<% end %>
<nav id="menu" class="col-sm" role="menu">
<%= link_to "About","#{root_url}about", :class => "btn btn-primary about", :role => "menuitem" %>
<%= link_to "How to Submit", "#{root_url}#how-to-submit", :class => "btn btn-primary how-to-submit", :role => "menuitem" %>
<%= link_to "Help", "#{root_url}help", :class =>"btn btn-secondary help", :role => "menuitem" %>
</nav>
<% if current_user %>
<nav id="menu" class="col-sm" role="menu">
<%= link_to "How to Submit", "#{root_url}#how-to-submit", :class => "btn btn-primary how-to-submit", :role => "menuitem" %>
<%= link_to "Need Help?", "#{root_url}help", :class =>"btn btn-secondary help", :role => "menuitem" %>
</nav>
<% else %>
<div id="pdc-discovery-label">Looking for data? Go to</div>
<nav id="menu" class="col-sm" role="menu">
<%= link_to "Princeton Data Commons: Discovery","https://datacommons.princeton.edu/discovery/", :class => "btn btn-primary about", :role => "menuitem" %>
<%= link_to "How to Submit", "#{root_url}#how-to-submit", :class => "btn btn-primary how-to-submit", :role => "menuitem" %>
<%= link_to "Need Help?", "#{root_url}help", :class =>"btn btn-secondary help", :role => "menuitem" %>
</nav>
<% end %>
<nav id="user-actions" class="col-sm">
<% if current_user %>
<%= render 'shared/user_actions' %>
Expand Down
1 change: 0 additions & 1 deletion spec/system/front_page_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

it "has a header with links to helpful info" do
visit "/"
expect(page).to have_link "About", href: /about/
expect(page).to have_link "How to Submit", href: /how-to-submit/
end

Expand Down
65 changes: 65 additions & 0 deletions spec/views/_header.html.erb_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# frozen_string_literal: true
require "rails_helper"

describe "header", type: :system do
context "for logged-out users" do
it "renders the correct links on homepage" do
visit "/"
expect(page).to have_link("Princeton Data Commons: Discovery", href: "https://datacommons.princeton.edu/discovery/")
expect(page).to have_selector(:link_or_button, "How to Submit")
expect(page).to have_selector(:link_or_button, "Need Help?")
expect(page).to have_selector(:link_or_button, "Log In")
end

it "renders the correct links on help page" do
visit "/help"
expect(page).to have_link("Princeton Data Commons: Discovery", href: "https://datacommons.princeton.edu/discovery/")
expect(page).to have_selector(:link_or_button, "How to Submit")
expect(page).to have_selector(:link_or_button, "Need Help?")
expect(page).to have_selector(:link_or_button, "Log In")
end
end

context "for logged-in users" do
let(:user) { FactoryBot.create :princeton_submitter }

before do
login_as user
end

it "renders the correct links on homepage" do
visit "/"
expect(page).to have_selector(:link_or_button, "How to Submit")
expect(page).to have_selector(:link_or_button, "Need Help?")
expect(page).to have_selector(:link_or_button, user.uid.to_s)
end

it "renders the correct links on help page" do
visit "/help"
expect(page).to have_selector(:link_or_button, "How to Submit")
expect(page).to have_selector(:link_or_button, "Need Help?")
expect(page).to have_selector(:link_or_button, user.uid.to_s)
end

it "renders the correct links on notifications page" do
visit "/work_activity_notifications"
expect(page).to have_selector(:link_or_button, "How to Submit")
expect(page).to have_selector(:link_or_button, "Need Help?")
expect(page).to have_selector(:link_or_button, user.uid.to_s)
end

it "renders the correct links on profile page" do
visit "/users/#{user.uid}/edit"
expect(page).to have_selector(:link_or_button, "How to Submit")
expect(page).to have_selector(:link_or_button, "Need Help?")
expect(page).to have_selector(:link_or_button, user.uid.to_s)
end

it "renders the correct links on dashboard page" do
visit "users/#{user.uid}"
expect(page).to have_selector(:link_or_button, "How to Submit")
expect(page).to have_selector(:link_or_button, "Need Help?")
expect(page).to have_selector(:link_or_button, user.uid.to_s)
end
end
end

0 comments on commit 72a310f

Please sign in to comment.