Last active
August 29, 2015 14:00
-
-
Save drager/ef63b9cef5b2ae713624 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
= form_for([@forum, @topic]) do |f| | |
- if @topic.errors.any? | |
%div{class: 'alert'} | |
%h2 | |
= pluralize(@topic.errors.count, 'error') | |
prohibited this topic from being saved: | |
- for message in @topic.errors.full_messages | |
%li | |
= message | |
= f.label :name | |
%div{class: 'field'} | |
= f.text_field :name | |
= f.fields_for :posts, post do |p| | |
= render partial: 'posts/form', locals: { :f => p } | |
%div{class: 'actions'} | |
= f.submit | |
- if @topic.new_record? | |
asd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<form accept-charset="UTF-8" action="/forums/ruby/topics/asdasdasdasdasd" class="edit_topic" id="edit_topic_1" method="post"><div style="display:none"><input name="utf8" type="hidden" value="✓" /><input name="_method" type="hidden" value="patch" /><input name="authenticity_token" type="hidden" value="eDv4pcLTU0m3os+7OImIOdNQxouyQoSb3FojGMXMNh8=" /></div> <label for="topic_name">Name</label> | |
<div class='field'> | |
<input id="topic_name" name="topic[name]" type="text" value="asdasdasdasdasd" /> | |
</div> | |
<label for="topic_posts_attributes_0_bodytext">Bodytext</label> | |
<div class='field'> | |
<textarea id="topic_posts_attributes_0_bodytext" name="topic[posts_attributes][0][bodytext]"> | |
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa</textarea> | |
</div> | |
<input id="topic_posts_attributes_0_id" name="topic[posts_attributes][0][id]" type="hidden" value="1" /> | |
<div class='actions'> | |
<input name="commit" type="submit" value="Update Topic" /> | |
</div> | |
</form> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- title "Edit topic - #{@topic.name} - #{@forum.name} - #{@forum.category.name} - Forum" | |
%h1 | |
Edit topic | |
= @topic.name | |
= render 'form', post: @topic.posts.first |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"<!DOCTYPE html>\n<html>\n<head>\n<title>Edit topic - Forward Mobility Coordinator - Lead Infrastructure Strategist - Lead Group Planner - Forum - RailsForum</title>\n<link data-turbolinks-track=\"true\" href=\"/assets/application.css\" media=\"all\" rel=\"stylesheet\" />\n<script data-turbolinks-track=\"true\" src=\"/assets/application.js\"></script>\n\n</head>\n<body>\n<h1><a href=\"/\">Ruby on Rails Forum application</a></h1>\nWelcome back\n<span class='bold'>rusty</span>\n<ul>\n<li><a href=\"/\">Forum</a></li>\n<li><a href=\"/logout\">Logout</a></li>\n</ul>\n<h1>\nEdit topic\nForward Mobility Coordinator\n</h1>\n<form accept-charset=\"UTF-8\" action=\"/forums/lead-infrastructure-strategist/topics/forward-mobility-coordinator\" class=\"edit_topic\" id=\"edit_topic_2\" method=\"post\"><div style=\"display:none\"><input name=\"utf8\" type=\"hidden\" value=\"✓\" /><input name=\"_method\" type=\"hidden\" value=\"patch\" /></div><label for=\"topic_name\">Name</label>\n<div class='field'>\n<input id=\"topic_name\" name=\"topic[name]\" type=\"text\" value=\"Forward Mobility Coordinator\" />\n</div>\n<div class='actions'>\n<input name=\"commit\" type=\"submit\" value=\"Update Topic\" />\n</div>\n</form>\n\n\n\n</body>\n</html>\n" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
= f.label :bodytext | |
%div{class: 'field'} | |
= f.text_area :bodytext |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'spec_helper' | |
require 'faker' | |
feature 'Update topic' do | |
let(:category) { create(:category) } | |
let(:forum) { create(:forum) } | |
let(:user) { create(:user) } | |
let(:topic) { create(:topic) } | |
scenario 'updates a topic successfully with a valid name and bodytext' do | |
login_user(user) | |
update_topic('Another World', 'asaaaaaaaaaaaaaaaaaaaaaaa') | |
user_sees_success_message('Topic was successfully updated.') | |
end | |
scenario 'notifies the user if the name is too short' do | |
login_user(user) | |
update_topic(nil, 'asaaaaaaaaaaaaaaaaaaaaaaa') | |
user_sees_error_message('Name is too short (minimum is 6 characters)') | |
end | |
scenario 'notifies the user if the bodytext is too short' do | |
login_user(user) | |
update_topic('test-name', nil) | |
user_sees_error_message('Posts bodytext is too short (minimum is 20 characters)') | |
end | |
def update_topic(name, bodytext) | |
visit edit_forum_topic_path(forum, topic) | |
fill_in 'Name', with: name | |
fill_in 'Bodytext', with: bodytext | |
click_button 'Update Topic' | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment