Skip to content

Commit

Permalink
Merge branch 'master' into add-gravatars
Browse files Browse the repository at this point in the history
  • Loading branch information
drusepth committed Sep 23, 2016
2 parents 48996d0 + 6a08ffd commit 16ef4f7
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 4 deletions.
12 changes: 8 additions & 4 deletions app/views/cards/serendipitous/_content_question.html.erb
@@ -1,5 +1,5 @@
<% if question && !content.send(question[:field]).is_a?(ActiveRecord::Associations::CollectionProxy) %>
<div class="card-panel hoverable light-blue lighten-4">
<div class="content-question card-panel hoverable light-blue lighten-4">
<i class="material-icons <%= content.class.color %> circle right white-text"><%= content.class.icon %>`</i>
<%= question[:question] %>
Expand All @@ -14,14 +14,18 @@
else
%>
<div class="input-field">
<%= f.text_field question[:field] %>
<label for="last_name"><%= question[:field].humanize %></label>
<%= f.text_field question[:field], class: 'content-question-input' %>
<%= f.label question[:field], question[:field].humanize %>
</div>
<%
end
%>
<%= f.submit 'Save', class: 'waves-effect waves-light btn' %>
<%# Using a plain old form.submit creates a button that only responds to a click on the button text,
not anywhere else on the button. %>
<%= button_tag(type: 'submit', class: "content-question-submit waves-effect waves-light btn") do %>
Save
<% end %>
<% end %>
</div>
<% end %>
27 changes: 27 additions & 0 deletions test/integration/serendipitous_card_test.rb
@@ -0,0 +1,27 @@
require 'test_helper'

# Tests for the Serendipitous cards on content pages
class SerendipitousCardTest < ActionDispatch::IntegrationTest
test 'changing character info' do
@user = log_in_as_user
@character = create(:character, user: @user)
@character.save

visit character_path(@character)

modified_field_name = find(:css, '.content-question-input')[:id].split('_', 2)[1]
@character[modified_field_name] = 'Previous Value'
@character.save
previous_field_value = @character[modified_field_name]

find(:css, '.content-question-input').set('Content Question Answer')
find('.content-question-submit').click

# We can't use @character.changed? because after the form is submitted,
# the changes were saved.

@character.reload
assert_equal 'Content Question Answer', @character[modified_field_name],
"expected field #{modified_field_name} to change from '#{previous_field_value}' to 'Content Question Answer', but it was '#{@character[modified_field_name]}'"
end
end

0 comments on commit 16ef4f7

Please sign in to comment.