Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Finish Chapter 8

  • Loading branch information...
commit 814916777641ba29394ef80f50673bbe0529d391 1 parent 20e58f2
@dirksiemers authored
View
5 app/helpers/users_helper.rb
@@ -1,8 +1,9 @@
module UsersHelper
# Returns the Gravatar (http://gravatar.com/) for the given user.
- def gravatar_for(user)
+ def gravatar_for(user, options = { size: 50 })
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")
end
end
View
2  app/views/layouts/application.html.erb
@@ -11,7 +11,7 @@
<%= render 'layouts/header' %>
<div class="container">
<% flash.each do |key, value| %>
- <div class="alert alert-<%= key %>"><%= value %></div>
+ <%= content_tag(:div, value, class: "alert alert-#{key}") %>
<% end %>
<%= yield %>
<%= render 'layouts/footer' %>
View
4 config/locales/en.yml
@@ -2,4 +2,8 @@
# See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
en:
+ activerecord:
+ attributes:
+ user:
+ password_digest: "Password"
hello: "Hello world"
View
13 spec/requests/user_pages_spec.rb
@@ -29,6 +29,12 @@
it "should not create a user" do
expect { click_button submit }.not_to change(User, :count)
end
+ describe "after submission" do
+ before { click_button submit }
+
+ it { should have_selector('title', text: 'Sign up') }
+ it { should have_content('error') }
+ end
end
describe "with valid information" do
@@ -42,6 +48,13 @@
it "should create a user" do
expect { click_button submit }.to change(User, :count).by(1)
end
+ describe "after saving the user" do
+ before { click_button submit }
+ let(:user) { User.find_by_email('user@example.com') }
+
+ it { should have_selector('title', text: user.name) }
+ it { should have_selector('div.alert.alert-success', text: 'Welcome') }
+ end
end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.