Skip to content

Commit

Permalink
Merge branch 'master' into swap-alt-with-redux
Browse files Browse the repository at this point in the history
* master:
  fixed rubocop error, leaving js errors for next PR
  Several slight enhancements, most importantly sanitization
  • Loading branch information
justin808 committed Aug 9, 2015
2 parents 5347021 + d344715 commit dc23ef2
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion client/assets/javascripts/components/Comment.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const Comment = React.createClass({
},

render() {
const rawMarkup = marked(this.props.text);
const rawMarkup = marked(this.props.text, { gfm: true, sanitize: true });
return (
<div className="comment">
<h2 className="comment-author">
Expand Down
1 change: 1 addition & 0 deletions client/assets/javascripts/components/CommentBox.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const CommentBox = React.createClass({
return (
<div className='commentBox container'>
<h1>Comments { this.props.ajaxCounter > 0 ? `SENDING AJAX REQUEST! Ajax Counter is ${this.props.ajaxCounter}` : '' }</h1>
<p>Text take Github Flavored Markdown. Comments older than 24 hours are deleted.</p>
<CommentForm ajaxSending={this.props.ajaxCounter > 0} actions={actions}/>
<CommentList comments={data.get('comments')}/>
</div>
Expand Down
8 changes: 8 additions & 0 deletions lib/tasks/daily.rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
task daily: :environment do
t = 1.day.ago
older_comments = Comment.where("created_at < ?", t)
newer_comments = Comment.where("created_at >= ?", t)
Rails.logger.info "Deleting #{older_comments.count} comments older than #{t}"
Rails.logger.info "Keeping #{newer_comments.count} comments newer than #{t}"
older_comments.delete_all
end
8 changes: 8 additions & 0 deletions spec/features/comments_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@
expect(page).to have_css(".commentList .comment", text: "Tommy")
expect(page).to have_css(".commentList .comment", text: "Surf's up dude!")

click_link "Horizontal Form"
fill_in "Your Name", with: "Jason"
fill_in "Say something...", with: "<iframe src=\"http://www.w3schools.com\"></iframe>"
click_button "Post"
expect(page).to have_css(".commentList .comment", text: "Jason")
expect(page).not_to have_css("iframe")
expect(page).to have_css(".commentList .comment", text: "<iframe src=\"http://www.w3schools.com\"")

click_link "Stacked Form"
fill_in "Your Name", with: "Spicoli"
fill_in hint_text, with: "Cowabunga dude!"
Expand Down
1 change: 0 additions & 1 deletion spec/rails_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
DatabaseCleaner.clean
end


Capybara.javascript_driver = :poltergeist

# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
Expand Down

0 comments on commit dc23ef2

Please sign in to comment.