Commit e97d813a by Tan Phat Nguyen

add test flash

parent e3024bdf
module UsersHelper module UsersHelper
# Returns the Gravatar for the given user. # Returns the Gravatar for the given user.
def gravatar_for(user) def gravatar_for(user, options = { size: 80 })
gravatar_id = Digest::MD5::hexdigest(user.email.downcase) gravatar_id = Digest::MD5::hexdigest(user.email.downcase)
gravatar_url = "https://secure.gravatar.com/avatar/#{gravatar_id}" size = options[:size]
gravatar_url = "https://secure.gravatar.com/avatar/#{gravatar_id}?s=#{size}"
image_tag(gravatar_url, alt: user.name, class: "gravatar") image_tag(gravatar_url, alt: user.name, class: "gravatar")
end end
end end
...@@ -12,7 +12,8 @@ ...@@ -12,7 +12,8 @@
<%= render 'layouts/header' %> <%= render 'layouts/header' %>
<div class="container"> <div class="container">
<% flash.each do |message_type, message| %> <% flash.each do |message_type, message| %>
<div class="alert alert-<%= message_type %>"><%= message %></div> <!-- <div class="alert alert-<%= message_type %>"><%= message %></div> -->
<%= content_tag(:div, message, class: "alert alert-#{message_type}") %>
<% end %> <% end %>
<%= yield %> <%= yield %>
<%= render 'layouts/footer' %> <%= render 'layouts/footer' %>
......
...@@ -7,6 +7,8 @@ class UsersSignupTest < ActionDispatch::IntegrationTest ...@@ -7,6 +7,8 @@ class UsersSignupTest < ActionDispatch::IntegrationTest
post users_path, user: {name: "", email: "user@invalid", password: "foo", password_confirmation: "bar"} post users_path, user: {name: "", email: "user@invalid", password: "foo", password_confirmation: "bar"}
end end
assert_template 'users/new' assert_template 'users/new'
assert_select 'div#error_explanation'
assert_select 'div.alert'
end end
test "valid signup information" do test "valid signup information" do
...@@ -15,5 +17,6 @@ class UsersSignupTest < ActionDispatch::IntegrationTest ...@@ -15,5 +17,6 @@ class UsersSignupTest < ActionDispatch::IntegrationTest
post_via_redirect users_path, user: {name: "Example User", email: "user@example.com", password: "password", password_confirmation: "password"} post_via_redirect users_path, user: {name: "Example User", email: "user@example.com", password: "password", password_confirmation: "password"}
end end
assert_template 'users/show' assert_template 'users/show'
assert_not flash.empty?
end end
end end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment