Skip to content

Commit

Permalink
Merge branch 'master' into rails-42
Browse files Browse the repository at this point in the history
Conflicts:
	spec/rails_helper.rb
  • Loading branch information
mvz committed Jan 13, 2015
2 parents a96713c + 8a01a90 commit 41d8e80
Show file tree
Hide file tree
Showing 33 changed files with 182 additions and 274 deletions.
8 changes: 6 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
sudo: false
language: ruby
cache: bundler
rvm:
- 2.0.0
- 2.1
Expand All @@ -7,7 +9,9 @@ env:
- DB=sqlite
- DB=mysql
- DB=postgresql

before_script:
- sudo apt-get install python-feedvalidator
- bundle exec rake db:create db:migrate

addons:
code_climate:
repo_token: 8850bccc6911d74965627b1fafe753beb368fab00d33de0c7576c6598fc1220e
5 changes: 5 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ group :development, :test do
gem 'quiet_assets'
end

group :test do
gem 'feedjira'
gem "codeclimate-test-reporter", require: nil
end

# Install gems from each theme
Dir.glob(File.join(File.dirname(__FILE__), 'themes', '**', "Gemfile")) do |gemfile|
eval(IO.read(gemfile), binding)
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/admin/feedback_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def bulkops
when 'Delete all spam'
if request.post?
Feedback.delete_all(['state = ?', 'spam'])
flash[:success] = I18n.t('admin.feedback.bulkops.success')
flash[:success] = I18n.t('admin.feedback.bulkops.success_deleted_spam')
end
else
flash[:error] = I18n.t('admin.feedback.bulkops.error')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class AuthorController < ContentController
class AuthorsController < ContentController
layout :theme_layout

def show
Expand Down
4 changes: 2 additions & 2 deletions app/models/text_filter.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
require 'net/http'

class TextFilter < ActiveRecord::Base
serialize :filters
serialize :params
serialize :filters, Array
serialize :params, Hash

@text_helper = ContentTextHelpers.new

Expand Down
6 changes: 3 additions & 3 deletions app/views/admin/dashboard/_welcome.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
<% if current_user.can_access_to_feedback? %>
<h4 class='page-header'><%= t(".feedback") %></h4>
<p><%= link_to(t('.comments_count', count: @statcomments), controller: 'admin/feedback') %></p>
<p><%= link_to(t('.approved_count', count: @confirmed), controller: 'admin/feedback', "ham" => "f") %></p>
<p><%= link_to(t('.unconfirmed_count', count: @unconfirmed), controller: 'admin/feedback', "presumed_ham" => "f") %></p>
<p><%= link_to(t(".spam_count", count: @statspam), controller: 'admin/feedback', "spam" => "f") %></p>
<p><%= link_to(t('.approved_count', count: @confirmed), controller: 'admin/feedback', only: 'ham') %></p>
<p><%= link_to(t('.unconfirmed_count', count: @unconfirmed), controller: 'admin/feedback', only: 'unapproved') %></p>
<p><%= link_to(t(".spam_count", count: @statspam), controller: 'admin/feedback', only: 'spam') %></p>
<% end %>
</div>
</div>
Expand Down
8 changes: 5 additions & 3 deletions app/views/articles/read.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,11 @@
<%= t(".use_the_following_link_to_trackback")%>:<br>
<span class="light-bg"><%= @article.trackback_url %></span>
</p>
<%= content_tag(:ol,
render("trackback", :collection => @article.published_trackbacks),
:id => 'trackbackList', :class => 'trackback-list') unless @article.published_trackbacks.blank? %>
<%- unless @article.published_trackbacks.blank? %>
<ol id="trackbackList" class="trackback-list">
<%= render(partial: "trackback", collection: @article.published_trackbacks) %>
</ol>
<% end -%>
<% end -%>

<p class="postmetadata alt">
Expand Down
File renamed without changes.
File renamed without changes.
1 change: 0 additions & 1 deletion app/views/shared/_atom_header.atom.builder
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@ unless this_blog.blog_subtitle.blank?
end
feed.updated items.first.updated_at if items.first
feed.generator "Publify", :uri => "http://www.publify.co", :version => PUBLIFY_VERSION

11 changes: 0 additions & 11 deletions app/views/xml/rsd.rsd.builder
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,5 @@ xml.rsd "version"=>"1.0", "xmlns"=>"http://archipelago.phrasewise.com/rsd" do
xml.engineName "Publify"
xml.engineLink "http://www.publify.co"
xml.homePageLink url_for(:controller => "articles")
xml.apis do
xml.api "name" => "Movable Type", "preferred"=>"true",
"apiLink" => url_for(:controller => "backend", :action => "xmlrpc", :only_path => false),
"blogID" => "1"
xml.api "name" => "MetaWeblog", "preferred"=>"false",
"apiLink" => url_for(:controller => "backend", :action => "xmlrpc", :only_path => false),
"blogID" => "1"
xml.api "name" => "Blogger", "preferred"=>"false",
"apiLink" => url_for(:controller => "backend", :action => "xmlrpc", :only_path => false),
"blogID" => "1"
end
end
end
2 changes: 1 addition & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
get '/tag/:id/page/:page', :to => 'tags#show', :format => false
get '/tags/page/:page', :to => 'tags#index', :format => false

resources :author, only: :show
resources :authors, path: 'author', only: :show

# ThemesController
scope :controller => 'theme', :filename => /.*/ do
Expand Down
12 changes: 6 additions & 6 deletions spec/controllers/admin/dashboard_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@
end

it "should have a link to Spam" do
expect(response.body).to have_selector("a[href='/admin/feedback?spam=f']", :text => "no spam")
expect(response.body).to have_selector("a[href='/admin/feedback?only=spam']", text: "no spam")
end

it "should have a link to Spam queue" do
expect(response.body).to have_selector("a[href='/admin/feedback?presumed_ham=f']", :text => "no unconfirmed")
expect(response.body).to have_selector("a[href='/admin/feedback?only=unapproved']", text: "no unconfirmed")
end
end

Expand Down Expand Up @@ -103,11 +103,11 @@
end

it "should have a link to Spam" do
expect(response.body).to have_selector("a[href='/admin/feedback?spam=f']", :text => "no spam")
expect(response.body).to have_selector("a[href='/admin/feedback?only=spam']", text: "no spam")
end

it "should have a link to Spam queue" do
expect(response.body).to have_selector("a[href='/admin/feedback?presumed_ham=f']", :text => "no unconfirmed")
expect(response.body).to have_selector("a[href='/admin/feedback?only=unapproved']", text: "no unconfirmed")
end
end

Expand Down Expand Up @@ -158,11 +158,11 @@
end

it "should not have a link to Spam" do
expect(response.body).not_to have_selector("a[href='/admin/feedback?published=f']", :text => "Spam comments:")
expect(response.body).not_to have_selector("a[href='/admin/feedback?only=spam']", text: "no spam")
end

it "should not have a link to Spam queue" do
expect(response.body).not_to have_selector("a[href='/admin/feedback?presumed_spam=f']", :text => "In your spam queue:")
expect(response.body).not_to have_selector("a[href='/admin/feedback?only=unapproved']", text: "no unconfirmed")
end
end
end
21 changes: 17 additions & 4 deletions spec/controllers/articles_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -457,10 +457,23 @@
let!(:article) { create(:article, :permalink => 'second-blog-article', :published_at => '2004-04-01 02:00:00', :updated_at => '2004-04-01 02:00:00', :created_at => '2004-04-01 02:00:00') }

with_each_theme do |theme, view_path|
it "renders template #{view_path}/articles/read" do
blog.theme = theme
get :redirect, from: "#{article.permalink}.html"
expect(response).to render_template('articles/read')
context "for theme #{theme}" do
before do
blog.theme = theme
blog.save!
end

it "renders without errors when no comments or trackbacks are present" do
get :redirect, from: "#{article.permalink}.html"
expect(response).to be_success
end

it "renders without errors when comments and trackbacks are present" do
create :trackback, article: article
create :comment, article: article
get :redirect, from: "#{article.permalink}.html"
expect(response).to be_success
end
end
end
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'rails_helper'

describe AuthorController, :type => :controller do
describe AuthorsController, :type => :controller do
let!(:blog) { create(:blog, limit_article_display: 1) }
let(:now) { DateTime.new(2012,12,23,3,45) }

Expand Down
2 changes: 2 additions & 0 deletions spec/controllers/xml_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ def assert_moved_permanently_to(location)

# TODO: make this more robust
describe "#rsd" do
render_views
before do
get :rsd
end
Expand All @@ -168,6 +169,7 @@ def assert_moved_permanently_to(location)

# TODO: make this more robust
describe "#feed with googlesitemap format" do
render_views
before do
FactoryGirl.create(:tag)
get :feed, :format => 'googlesitemap', :type => 'sitemap'
Expand Down
6 changes: 3 additions & 3 deletions spec/factories.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@
name "markdown"
description "Markdown"
markup 'markdown'
filters '--- []'
params '--- {}'
filters []
params {}

after :stub do |filter|
TextFilter.stub(:find_by_name).with(filter.name) { filter }
Expand All @@ -108,7 +108,7 @@
m.name "smartypants"
m.description "SmartyPants"
m.markup 'none'
m.filters %q{ [:smartypants].to_yaml.inspect }
m.filters [:smartypants]
end

factory 'markdown smartypants', :parent => :smartypants do |m|
Expand Down
8 changes: 8 additions & 0 deletions spec/models/article_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,8 @@

# FIXME: This spec is way too complex
it 'sends a pingback to urls linked in the body' do
expect(Thread.list.count).to eq 3

expect(ActiveRecord::Base.observers).to include(:email_notifier)
expect(ActiveRecord::Base.observers).to include(:web_notifier)
a = Article.new(:body => %{<a href="#{referenced_url}">},
Expand All @@ -177,6 +179,12 @@

expect(a.html_urls.size).to eq(1)
a.save!

10.times do
break if Thread.list.count <= 3
sleep 0.1
end

expect(a).to be_just_published
a = Article.find(a.id)
expect(a).not_to be_just_published
Expand Down
92 changes: 17 additions & 75 deletions spec/rails_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,25 +66,32 @@ def create_file_in_spec_public_cache_directory(file)

# TODO: Clean up use of these Test::Unit style expectations
def assert_xml(xml)
expect(xml).not_to be_empty
expect do
assert REXML::Document.new(xml)
end.not_to raise_error
end

def assert_atom10 feed, count
doc = Nokogiri::XML.parse(feed)
root = doc.css(':root').first
expect(root.name).to eq("feed")
expect(root.namespace.href).to eq("http://www.w3.org/2005/Atom")
expect(root.css('entry').count).to eq(count)
doc = Feedjira::Feed.parse(feed)
expect(doc).to be_instance_of Feedjira::Parser::Atom
expect(doc.title).not_to be_nil
expect(doc.entries.count).to eq count
end

def assert_correct_atom_generator feed
xml = Nokogiri::XML.parse(feed)
generator = xml.css("generator").first
expect(generator.content).to eq("Publify")
expect(generator["version"]).to eq(PUBLIFY_VERSION)
end

def assert_rss20 feed, count
doc = Nokogiri::XML.parse(feed)
root = doc.css(':root').first
expect(root.name).to eq("rss")
expect(root['version']).to eq("2.0")
expect(root.css('channel item').count).to eq(count)
doc = Feedjira::Feed.parse(feed)
expect(doc).to be_instance_of Feedjira::Parser::RSS
expect(doc.version).to eq "2.0"
expect(doc.title).not_to be_nil
expect(doc.entries.count).to eq count
end

def stub_full_article(time=Time.now)
Expand Down Expand Up @@ -115,68 +122,3 @@ def with_each_theme
yield theme, view_path
end
end

# This test now has optional support for validating the generated RSS feeds.
# Since Ruby doesn't have a RSS/Atom validator, I'm using the Python source
# for http://feedvalidator.org and calling it via 'system'.
#
# To install the validator, download the source from
# http://sourceforge.net/cvs/?group_id=99943
# Then copy src/feedvalidator and src/rdflib into a Python lib directory.
# Finally, copy src/demo.py into your path as 'feedvalidator', make it executable,
# and change the first line to something like '#!/usr/bin/python'.

if($validator_installed == nil)
$validator_installed = false
begin
IO.popen("feedvalidator 2> /dev/null","r") do |pipe|
if (pipe.read =~ %r{Validating http://www.intertwingly.net/blog/index.})
puts "Using locally installed Python feed validator"
$validator_installed = true
end
end
rescue
nil
end
end

def assert_feedvalidator(rss, todo=nil)
unless $validator_installed
puts 'Not validating feed because no validator (feedvalidator in python) is installed'
return
end

begin
file = Tempfile.new(['publify-feed-test', '.xml'])
filename = file.path
file.write(rss)
file.close

messages = ''

IO.popen("feedvalidator file://#{filename}") do |pipe|
messages = pipe.read
end

okay, messages = parse_validator_messages(messages)

if todo && ! ENV['RUN_TODO_TESTS']
assert !okay, messages + "\nTest unexpectedly passed!\nFeed text:\n"+rss
else
assert okay, messages + "\nFeed text:\n"+rss
end
end
end

def parse_validator_messages(message)
messages=message.split(/\n/).reject do |m|
m =~ /Feeds should not be served with the "text\/plain" media type/ ||
m =~ /Self reference doesn't match document location/
end

if(messages.size > 1)
[false, messages.join("\n")]
else
[true, ""]
end
end
5 changes: 5 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
# users commonly want.
#
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
#
# Code climate for coverage reporting into Travis CI
require "codeclimate-test-reporter"
CodeClimate::TestReporter.start

RSpec.configure do |config|
# These two settings work together to allow you to limit a spec run
# to individual examples or groups you care about by tagging them with
Expand Down
Loading

0 comments on commit 41d8e80

Please sign in to comment.