proclaim 0.2.1 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b0fa65204bd314dae948730f9a98faa94967d29f
4
- data.tar.gz: fd5c1946614f5e5b5252a762e500d4d6d7118eaf
3
+ metadata.gz: 0f01a5d261bff3eb7daf30ba4bde79f074c20e58
4
+ data.tar.gz: 1519808eae64115a710a98131470e6b4fa61cd5f
5
5
  SHA512:
6
- metadata.gz: e9b5098b7ede9acedb336fcb367af05dd553088d9b7fb056754d4c27a8339aaf334c090c7f7209fab696c751e099c8fd833779a20466aaa40571c2a5fc019d25
7
- data.tar.gz: ff2b49ba432b3a00a092cc33eea9d9a0fcf9f08115cfb21156f3554fa15eb3951f3a3530f797abb758ae0e5d49e3f668d15b542f093193d6a2c4c149a63d4d39
6
+ metadata.gz: ef0e2bdf09f08125eaf80c8f7fd91c7831b8081b4414ba28b472463d8f29db4fb196772d01f10185261c3eb57b9a0d8bc3d9797591134ca803f707a499866f2b
7
+ data.tar.gz: ce8688fb5521fa7777645fb4fabdaa7ae7a75e95860974cd2c769f9eb91b6e19b0cf75518a527b3167a58f4df6a6643fa74e10fd625e703f3618d8231cf47e86
data/CHANGELOG CHANGED
@@ -1,3 +1,7 @@
1
+ v 0.2.2
2
+ - Fixed post titles showing HTML entities
3
+ - Fixed posts index to show published time instead of updated time
4
+
1
5
  v 0.2.1
2
6
  - Fixed out-of-date initializer template
3
7
 
data/README.md CHANGED
@@ -28,7 +28,7 @@ scheme is given below.
28
28
  Proclaim 0.1 works with Rails 4.2 and on. Add it to your Gemfile with:
29
29
 
30
30
  ```ruby
31
- gem 'proclaim', "~> 0.2.1"
31
+ gem 'proclaim', "~> 0.2.2"
32
32
  ```
33
33
 
34
34
  Run `bundle install` to install it.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.1
1
+ 0.2.2
@@ -100,7 +100,7 @@ module Proclaim
100
100
  def post_params
101
101
  # Ensure post title is sanitized of all HTML
102
102
  if params[:post].include? :title
103
- params[:post][:title] = Rails::Html::FullSanitizer.new.sanitize(params[:post][:title])
103
+ params[:post][:title] = HTMLEntities.new.decode(Rails::Html::FullSanitizer.new.sanitize(params[:post][:title]))
104
104
  end
105
105
 
106
106
  params.require(:post).permit(:title,
@@ -49,7 +49,7 @@ module Proclaim
49
49
  end
50
50
 
51
51
  def body_plaintext
52
- Rails::Html::FullSanitizer.new.sanitize(body.gsub(/\r\n?/, ' '))
52
+ HTMLEntities.new.decode(Rails::Html::FullSanitizer.new.sanitize(body.gsub(/\r\n?/, ' ')))
53
53
  end
54
54
 
55
55
  def excerpt
@@ -1,7 +1,7 @@
1
1
  <!DOCTYPE html>
2
2
  <html>
3
3
  <head>
4
- <meta content='text/html; charset=UTF-8' http-equiv='Content-Type' />
4
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
5
5
 
6
6
  <style>
7
7
  * {
@@ -7,14 +7,14 @@
7
7
  $(document).find("form.new_post h1.editable"),
8
8
  $(document).find("input#post_body"),
9
9
  $(document).find("form.new_post div.editable"),
10
- <%= raw Proclaim.editor_toolbar_buttons.to_json %>);
10
+ <%= Proclaim.editor_toolbar_buttons.to_json.html_safe %>);
11
11
  <% else %>
12
12
  new Editor($(document).find("form.edit_post"),
13
13
  $(document).find("input#post_title"),
14
14
  $(document).find("form.edit_post h1.editable"),
15
15
  $(document).find("input#post_body"),
16
16
  $(document).find("form.edit_post div.editable"),
17
- <%= raw Proclaim.editor_toolbar_buttons.to_json %>);
17
+ <%= Proclaim.editor_toolbar_buttons.to_json.html_safe %>);
18
18
  <% end %>
19
19
  });
20
20
  </script>
@@ -36,7 +36,7 @@
36
36
  <h1 class = "post_title editable" data-disable-return="true" data-disable-toolbar="true" data-placeholder="Post Title"><%= @post.title %></h1>
37
37
 
38
38
  <div class = "post_body editable" data-placeholder = "Post Body" data-image-upload-path="<%= cache_image_path %>" data-image-delete-path="<%= discard_image_path %>">
39
- <%= raw @post.body %>
39
+ <%= @post.body.html_safe %>
40
40
  </div>
41
41
 
42
42
  <div class = "post_information" style = "margin-bottom: 30px;">
@@ -31,7 +31,7 @@
31
31
  <% end %>
32
32
  </div>
33
33
  <%= post.author.send(Proclaim.author_name_method) %><br />
34
- <%= timeago_tag post.updated_at, format: "%B %d, %Y" %>
34
+ <%= timeago_tag post.published_at, format: "%B %d, %Y" %>
35
35
  </div>
36
36
  <% end %>
37
37
  </td>
@@ -31,7 +31,7 @@
31
31
  <h1 class = "post_title"><%= @post.title %></h1>
32
32
 
33
33
  <div class = "post_body show">
34
- <%= raw @post.body %>
34
+ <%= @post.body.html_safe %>
35
35
  </div>
36
36
 
37
37
  <div class = "post_information">
@@ -4,7 +4,7 @@
4
4
  </tr>
5
5
 
6
6
  <tr>
7
- <td class = "post_body"><%= raw @post.body %></td>
7
+ <td class = "post_body"><%= @post.body.html_safe %></td>
8
8
  </tr>
9
9
 
10
10
  <tr>
@@ -3,23 +3,23 @@ Proclaim.setup do |config|
3
3
  # `current_author_method` and `authentication_method`. For example, setting
4
4
  # `author_class = "Admin"` changes the default `current_author_method` to be
5
5
  # `:current_admin`, etc.
6
- #author_class = "User"
6
+ #config.author_class = "User"
7
7
 
8
8
  # Method to obtain the name of the author. This should be a method on the
9
9
  # author class.
10
- #author_name_method = :name
10
+ #config.author_name_method = :name
11
11
 
12
12
  # Method to obtain the currently-authenticated user. Should return nil if
13
13
  # no user is currently authenticated.
14
- #current_author_method = :current_user
14
+ #config.current_author_method = :current_user
15
15
 
16
16
  # Method to verify that a user is authenticated, and if not, will redirect
17
17
  # to some sort of authentication page.
18
- #authentication_method = :authenticate_user!
18
+ #config.authentication_method = :authenticate_user!
19
19
 
20
20
  # Maximum length for the excerpts shown on the posts index.
21
- #excerpt_length = 500
21
+ #config.excerpt_length = 500
22
22
 
23
23
  # Buttons to display on post editor toolbar
24
- #editor_toolbar_buttons = ['bold', 'italic', 'underline', 'anchor', 'header1', 'header2', 'quote']
24
+ #config.editor_toolbar_buttons = ['bold', 'italic', 'underline', 'anchor', 'header1', 'header2', 'quote']
25
25
  end
@@ -1,3 +1,3 @@
1
1
  module Proclaim
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2"
3
3
  end
@@ -33,17 +33,19 @@ class PostFormTest < ActionDispatch::IntegrationTest
33
33
 
34
34
  within('#new_post') do
35
35
  element = find('h1.editable')
36
- element.click()
36
+ #element.click()
37
37
  element.set("Post Title") # Set the title text
38
38
  element = find('div.editable')
39
- element.click() # Select the element
39
+ #element.click() # Select the element
40
40
  element.set("Paragraph 1\nParagraph 2") # Set the body text
41
41
  end
42
42
 
43
- assert_difference('Proclaim::Post.count') do
43
+ assert_difference('Proclaim::Post.count', 1,
44
+ "A post should have been created") do
44
45
  click_button "Create"
45
- assert page.has_text? "Post Title"
46
- assert page.has_text? "Paragraph 1\nParagraph 2"
46
+ assert page.has_text?("Post Title"), "Post title should be shown"
47
+ assert page.has_text?("Paragraph 1\nParagraph 2"),
48
+ "Post body should be shown"
47
49
  wait_for_ajax
48
50
  end
49
51
  end
@@ -137,6 +139,48 @@ class PostFormTest < ActionDispatch::IntegrationTest
137
139
  assert File.exist?(saved_file_path), "File should still be saved: #{saved_file_path}"
138
140
  end
139
141
 
142
+ test "form should not replace non-alphanumeric text in title with HTML entities" do
143
+ user = FactoryGirl.create(:user)
144
+ sign_in user
145
+
146
+ visit proclaim.new_post_path
147
+
148
+ within('#new_post') do
149
+ element = find('h1.editable')
150
+ #element.click()
151
+ element.set("\"quotes\"") # Set the title text
152
+ # Don't fill in body
153
+ end
154
+
155
+ click_button "Create"
156
+
157
+ assert page.has_css? "div#error_explanation"
158
+
159
+ assert page.has_text?("\"quotes\""), "Form should still be showing quotes in title!"
160
+ assert page.has_no_text?("&quot;quotes&quot;"), "Form should not be showing HTML entities in title!"
161
+ end
162
+
163
+ test "show should not replace non-alphanumeric text in title with HTML entities" do
164
+ user = FactoryGirl.create(:user)
165
+ sign_in user
166
+
167
+ visit proclaim.new_post_path
168
+
169
+ within('#new_post') do
170
+ element = find('h1.editable')
171
+ #element.click()
172
+ element.set("\"quotes\"") # Set the title text
173
+ element = find('div.editable')
174
+ #element.click() # Select the element
175
+ element.set("Paragraph 1\nParagraph 2") # Set the body text
176
+ end
177
+
178
+ click_button "Create"
179
+
180
+ assert page.has_text?("\"quotes\""), "Show page should be showing quotes in title!"
181
+ assert page.has_no_text?("&quot;quotes&quot;"), "Show page should not be showing HTML entities in title!"
182
+ end
183
+
140
184
  test "should show error without title" do
141
185
  user = FactoryGirl.create(:user)
142
186
  sign_in user
@@ -146,13 +190,15 @@ class PostFormTest < ActionDispatch::IntegrationTest
146
190
  within('#new_post') do
147
191
  # Don't fill in title
148
192
  element = find('div.editable')
149
- element.click() # Select the element
193
+ #element.click() # Select the element
150
194
  element.set("Paragraph 1\nParagraph 2") # Set the text
151
195
  end
152
196
 
153
- assert_no_difference('Proclaim::Post.count') do
197
+ assert_no_difference('Proclaim::Post.count',
198
+ "No post should have been created without a title") do
154
199
  click_button "Create"
155
- assert page.has_css? "div#error_explanation"
200
+ assert page.has_css?("div#error_explanation"),
201
+ "Should show error complaining about lack of title"
156
202
  wait_for_ajax
157
203
  end
158
204
  end
@@ -165,7 +211,7 @@ class PostFormTest < ActionDispatch::IntegrationTest
165
211
 
166
212
  within('#new_post') do
167
213
  element = find('h1.editable')
168
- element.click()
214
+ #element.click()
169
215
  element.set("Post Title") # Set the title text
170
216
  # Don't fill in the body
171
217
  end
@@ -0,0 +1,47 @@
1
+ require 'test_helper'
2
+
3
+ class PostShowTest < ActionDispatch::IntegrationTest
4
+ self.use_transactional_fixtures = false
5
+
6
+ setup do
7
+ ApplicationController.any_instance.stubs(:current_user).returns(nil)
8
+ ApplicationController.any_instance.stubs(:authenticate_user).returns(false)
9
+
10
+ DatabaseCleaner.strategy = :truncation
11
+ DatabaseCleaner.start
12
+
13
+ Capybara.current_driver = :selenium
14
+
15
+ @show_pag = ShowPage.new
16
+ end
17
+
18
+ teardown do
19
+ DatabaseCleaner.clean
20
+ Capybara.use_default_driver
21
+ end
22
+
23
+ test "show should include edit/delete buttons if logged in" do
24
+ user = FactoryGirl.create(:user)
25
+ sign_in user
26
+
27
+ post = FactoryGirl.create(:published_post)
28
+
29
+ visit proclaim.post_path(post)
30
+
31
+ assert page.has_css?('a', text: "Edit"),
32
+ "The show page should include a link to edit if logged in!"
33
+ assert page.has_css?('a', text: "Delete"),
34
+ "The show page should include a link to delete if logged in!"
35
+ end
36
+
37
+ test "show should not include edit/delete buttons if not logged in" do
38
+ post = FactoryGirl.create(:published_post)
39
+
40
+ visit proclaim.post_path(post)
41
+
42
+ assert page.has_no_css?('a', text: "Edit"),
43
+ "The show page should not include a link to edit if not logged in!"
44
+ assert page.has_no_css?('a', text: "Delete"),
45
+ "The show page should not include a link to delete if not logged in!"
46
+ end
47
+ end
data/test/test_helper.rb CHANGED
@@ -11,7 +11,6 @@ require 'database_cleaner'
11
11
  require 'test_after_commit'
12
12
  require 'coffee_script'
13
13
  require 'sass'
14
- #Capybara.app = Proclaim::Engine
15
14
 
16
15
  Rails.backtrace_cleaner.remove_silencers!
17
16
 
@@ -25,6 +24,12 @@ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
25
24
  # include Proclaim::Engine.routes.url_helpers
26
25
  #end
27
26
 
27
+ # Selenium isn't working with Firefox 35 (01/16/14). Use Chrome instead, for
28
+ # now. Too bad, really... I hate Chrome.
29
+ Capybara.register_driver :selenium do |app|
30
+ Capybara::Selenium::Driver.new(app, :browser => :chrome)
31
+ end
32
+
28
33
  class ActionDispatch::IntegrationTest
29
34
  # Make the Capybara DSL available in all integration tests
30
35
  include Capybara::DSL
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: proclaim
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kyle Fazzari
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-10 00:00:00.000000000 Z
11
+ date: 2015-01-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -447,6 +447,7 @@ files:
447
447
  - test/helpers/proclaim/subscriptions_helper_test.rb
448
448
  - test/integration/with_javascript/comment_test.rb
449
449
  - test/integration/with_javascript/post_form_test.rb
450
+ - test/integration/with_javascript/post_show_test.rb
450
451
  - test/integration/with_javascript/post_subscription_test.rb
451
452
  - test/integration/without_javascript/blog_subscription_test.rb
452
453
  - test/integration/without_javascript/post_test.rb
@@ -544,6 +545,7 @@ test_files:
544
545
  - test/integration/with_javascript/comment_test.rb
545
546
  - test/integration/with_javascript/post_subscription_test.rb
546
547
  - test/integration/with_javascript/post_form_test.rb
548
+ - test/integration/with_javascript/post_show_test.rb
547
549
  - test/integration/without_javascript/post_test.rb
548
550
  - test/integration/without_javascript/subscription_email_test.rb
549
551
  - test/integration/without_javascript/unsubscribe_test.rb