Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ---_like.html.erb---
- <% if micropost.like_user(current_user.id) %>
- <%= button_to micropost_like_path(likes, micropost_id:
- micropost.id), method: :delete, id: "like-button", remote: true do %>
- <%= image_tag("icon_red_heard.png") %>
- <span>
- <%= micropost.likes_count %>
- </span>
- <% end %>
- <% else %>
- <%= button_to micropost_likes_path(micropost),id: "like-button",
- remote: true do %>
- <%= image_tag("icon_red_heart.png") %>
- <span>
- <%= micropost.likes_count %>
- </span>
- <% end %>
- <% end %>
- ---_micropost.html.erb---
- <li id="micropost-<%= micropost.id %>">
- <%= link_to gravatar_for(micropost.user, size: 50), micropost.user %>
- <span class="user"><%= link_to micropost.user.name, micropost.user %></span>
- <span class="content">
- <%= micropost.content %>
- <%= image_tag micropost.picture.url if micropost.picture? %>
- </span>
- <span class="timestamp">
- Posted <%= time_ago_in_words(micropost.created_at) %> ago.
- <% if current_user?(micropost.user) %>
- <%= link_to "delete", micropost, method: :delete,
- data: { confirm: "You sure?" } %>
- <% end %>
- </span>
- <!--like拡張機能-->
- <%= render partial: 'likes/like', locals: { micropost: micropost,
- likes: @likes } %>
- </li>
- ---show.html.erb---
- <% provide(:title, @user.name) %>
- <div class="row">
- <aside class="col-md-4">
- <section class="user_info">
- <h1>
- <%= gravatar_for @user %>
- <%= @user.name %>
- </h1>
- </section>
- <section class="stats">
- <%= render 'shared/stats' %>
- </section>
- </aside>
- <div class="col-md-8">
- <%= render 'follow_form' if logged_in? %>
- <% if @user.microposts.any? %>
- <h3>Microposts (<%= @user.microposts.count %>)</h3>
- <ol class="microposts">
- <%= render @microposts %>
- </ol>
- <%= will_paginate @microposts %>
- <% end %>
- </div>
- </div>
- ---users_profile_test.rb---
- require 'test_helper'
- class UsersProfileTest < ActionDispatch::IntegrationTest
- include ApplicationHelper
- def setup
- @user = users(:michael)
- end
- test "profile display" do
- get user_path(@user)
- assert_template 'users/show'
- assert_select 'title', full_title(@user.name)
- assert_select 'h1', text: @user.name
- assert_select 'h1>img.gravatar'
- assert_match @user.microposts.count.to_s, response.body
- assert_select 'div.pagination'
- @user.microposts.paginate(page: 1).each do |micropost|
- assert_match micropost.content, response.body
- end
- end
- end
Add Comment
Please, Sign In to add comment