Skip to content

Commit

Permalink
Merge 54a6744 into 3294c30
Browse files Browse the repository at this point in the history
  • Loading branch information
lortza committed Mar 5, 2021
2 parents 3294c30 + 54a6744 commit 42074b8
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 5 deletions.
4 changes: 4 additions & 0 deletions app/helpers/movie_person_profiles_helper.rb
Expand Up @@ -7,4 +7,8 @@ def display_birthday_info(profile)
date = profile.birthday.to_date.stamp('January 1st, 2018')
profile.deathday.blank? ? "#{date} (Age: #{profile.age})" : "#{date}, Deceased (Age: #{profile.age})"
end

def actor_movie_posters_uri(actor)
"#{root_url}tmdb/actor_search?actor=#{actor.name.gsub(' ', '+')}"
end
end
7 changes: 5 additions & 2 deletions app/views/tmdb/_movie_credits.html.erb
@@ -1,8 +1,11 @@
<h3>Movie Credits (<%= @person_movie_credits.actor.size %>)</h3>
<h3>
<%= link_to 'Movie Poster View', actor_movie_posters_uri(person_profile), style: 'float: right;' %>
Movie Credits (<%= @person_movie_credits.actor.size %>)
</h3>
<ul>
<% @person_movie_credits.actor.each do |credit| %>
<li><%= link_to credit.title, movie_more_path(tmdb_id: "#{credit.tmdb_id}") %>
<%= " | #{credit.date} " if credit.date != "Date unavailable" %>
<%= "| As #{credit.character}" if credit.character.present? %></li>
<% end %>
</ul>
</ul>
2 changes: 1 addition & 1 deletion app/views/tmdb/actor_more.html.erb
Expand Up @@ -13,7 +13,7 @@
<div class="row">
<div class="credits">

<%= render "movie_credits" %>
<%= render partial: "movie_credits", locals: { person_profile: @person_profile } %>
<%= render "tv_credits" %>
Expand Down
11 changes: 9 additions & 2 deletions spec/helpers/movie_person_profiles_helper_spec.rb
Expand Up @@ -3,11 +3,10 @@
require 'rails_helper'

describe MoviePersonProfilesHelper, type: :helper do
let(:profile) { build(:movie_person_profile) }
let(:profile) { build(:movie_person_profile, name: 'Geoff Jefferson') }
let(:living_profile) { build(:living_movie_person_profile) }
let(:deceased_profile) { build(:deceased_movie_person_profile) }


describe '#display_birthday_info' do
it 'includes the word version of the birthdate in the returned string' do
profile.birthday = '2000-01-28'
Expand Down Expand Up @@ -43,4 +42,12 @@
expect(display_birthday_info(profile)).to eq('Not available')
end
end

describe '#actor_movie_posters_uri' do
it "generates a uri based on the actor's name" do
expected_segment = 'tmdb/actor_search?actor=Geoff+Jefferson'
actual_uri = actor_movie_posters_uri(profile)
expect(actual_uri).to include(expected_segment)
end
end
end

0 comments on commit 42074b8

Please sign in to comment.