Don't show anything for blank profile values.

This commit is contained in:
Prommah 2015-10-28 02:32:45 +00:00
parent cfc9bdc3aa
commit 3f35776ce6
2 changed files with 19 additions and 8 deletions

24
app/views/users/_general.html.erb Normal file → Executable file
View file

@ -4,10 +4,17 @@
<dl> <dl>
<dt>Age</dt> <dt>Age</dt>
<dd><%= @user.age %></dd> <dd><%= @user.age %></dd>
<dt>Country</dt>
<dd><%= @user.country %></dd> <% if !@user.country.blank? %>
<dt>Town</dt> <dt>Country</dt>
<dd><%= @user.profile.town %></dd> <dd><%= @user.country %></dd>
<% end %>
<% if !@user.profile.town.blank? %>
<dt>Town</dt>
<dd><%= @user.profile.town %></dd>
<% end %>
<dt>SteamID</dt> <dt>SteamID</dt>
<dd> <dd>
<p><%= @user.steamid %></p> <p><%= @user.steamid %></p>
@ -15,9 +22,12 @@
<%= link_to "Search for Steam Account" %> <%= link_to "Search for Steam Account" %>
</div> </div>
</dd> </dd>
<dt>Stream</dt>
<dd><%= @user.profile.stream.blank? ? "No Stream Provided" : @user.profile.stream %></dd> <% if !@user.profile.stream.blank? %>
</dd> <dt>Stream</dt>
<dd><%= @user.profile.stream %></dd>
</dd>
<% end %>
</dl> </dl>
<h4>Contact</h4> <h4>Contact</h4>

3
spec/features/users/stream_spec.rb Normal file → Executable file
View file

@ -7,7 +7,7 @@ feature "User Stream Information" do
feature "stream administration" do feature "stream administration" do
scenario "user updates their stream" do scenario "user updates their stream" do
visit user_path(user) visit user_path(user)
expect(page).to have_content("No Stream Provided") expect(page.html).to_not include("<dt>Stream</dt>")
fill_login_form(user, password) fill_login_form(user, password)
click_button submit(:user, :login) click_button submit(:user, :login)
visit edit_user_path(user) visit edit_user_path(user)
@ -17,6 +17,7 @@ feature "User Stream Information" do
click_button "Update Profile" click_button "Update Profile"
expect(page).to have_content(I18n.t(:users_update)) expect(page).to have_content(I18n.t(:users_update))
visit user_path(user) visit user_path(user)
expect(page.html).to include("<dt>Stream</dt>")
expect(page).to have_content(stream_url) expect(page).to have_content(stream_url)
end end
end end