Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/mw 38 dashboard unread messages #212

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 41 additions & 8 deletions app/views/dashboard/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,49 @@
margin-top: 15px;
}

.box {
width: 350px;
border: 1px solid black;
padding: 5px;
margin: 5px;
margin-bottom: 15px;
.subtitle {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Das sollte mit den neuen Stylesheets nicht mehr nötig sein, oder?

font-family: Roboto, sans-serif;
font-weight: bold;
font-size: 20px;
spacing: auto spacing;
color: #b8043c;
margin-bottom: 7px;
}

.button {
width: 100%;
border: none;
color: white;
padding: 10px 20px;
text-align: center;
text-decoration: none;
display: inline-block;
margin: 4px 2px;
cursor: pointer;
font-family: Roboto, sans-serif;
font-weight: bold;
font-size: 16px;
spacing: auto spacing;
margin-bottom: 18px;
<% if user_signed_in? && @user.notifications.where(unread: true).size > 0 %>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Der Check, ob der user signed in ist, sollte überflüssig sein, da nur auf das Dashboard zugegriffen werden kann, wenn man signed in ist.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An der Stelle sind ohne zumindest immer Tests fehlgeschlagen, weil es user nicht kannte

background-color: #2596be;
<% else %>
background-color: #7cc0d8;
<% end %>
}

.button:hover {
color: white;
}

</style>
<p class="title"><%= t('views.dashboard.greeting', name: @user.first_name)%></p>

<h3 class="subtitle box"><%= t 'views.dashboard.unread_messages' %></h3>
<% if user_signed_in? %>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hier ist der Check auch überflüssig, oder?

<p class="title"><%= t('views.dashboard.greeting', name: @user.first_name)%></p>

<a href="/notifications" class="button" id="notifications-button"><%= t('views.dashboard.unread_messages', num: @user.notifications.where(unread: true).size) %></a>

<h3 class="subtitle"><%= t 'views.dashboard.lent_items.title' %></h3>

<h3 class="subtitle"><%= t 'views.dashboard.lent_items.title' %></h3>
<%= render "lent_items"%>
Expand All @@ -36,3 +68,4 @@

<h3 class=" subtitle place-holder-nav"><%= t 'views.dashboard.wishlist.title' %></h3>
<%= render "wishlist"%>
<% end %>
3 changes: 2 additions & 1 deletion config/locales/de.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ de:
title: "Übersicht"
no_lent_items: "Aktuell hast du keine ausgeliehenen Artikel."
greeting: "Hallo, %{name}!"
unread_messages: "Du hast ... ungelesene Nachrichten"
not_signed_in: "Du bist nicht angemeldet."
unread_messages: "Du hast %{num} ungelesene Nachrichten"
lent_items:
title: "AUSGELIEHENE ARTIKEL"
expired: "abgelaufen am %{date}"
Expand Down
3 changes: 2 additions & 1 deletion config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ en:
title: "Dashboard"
no_lent_items: "Currently you have no lent items."
greeting: "Hello, %{name}!"
unread_messages: "You have ... unread messages"
not_signed_in: "You are not signed in."
unread_messages: "You have %{num} unread messages"
lent_items:
title: "LENT ITEMS"
expired: "expired on %{date}"
Expand Down
6 changes: 3 additions & 3 deletions db/schema.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 12 additions & 3 deletions spec/features/dashboard/dashboard_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
require "rails_helper"

RSpec.describe "Dashboard", type: :feature do
let(:user) { build(:user) }

let(:password) { 'password' }
let(:user) { create(:user, password: password) }
let(:borrower) { create(:max, password: password) }
let(:item) { create(:item, owner: user.id) }

it "redirects to login without user signed in" do
visit dashboard_path
Expand All @@ -15,10 +19,15 @@
expect(page).to have_content(@user.first_name)
end

it "shows unread messages" do
it "shows unread messages and links to notifications" do
sign_in user
visit dashboard_path
expect(page).to have_content I18n.t('views.dashboard.unread_messages')
expect(page).to have_link(href: '/notifications')
expect(page).to have_content I18n.t('views.dashboard.unread_messages', num: 0)
@notifications = create_list(:lend_request_notification, 2, user: user, item: item, borrower: borrower)
@notifications.each(&:save)
page.refresh
expect(page).to have_content I18n.t('views.dashboard.unread_messages', num: 2)
end

it "shows lent items" do
Expand Down