commit: b49dafeb78ec2e919400c184df0d01e395c93537 Author: Hans de Graaff <hans <AT> degraaff <DOT> org> AuthorDate: Tue Apr 19 11:39:34 2016 +0000 Commit: Hans de Graaff <graaff <AT> gentoo <DOT> org> CommitDate: Tue Apr 19 11:39:34 2016 +0000 URL: https://gitweb.gentoo.org/dev/graaff.git/commit/?id=b49dafeb
dev-ruby/draper: add patch for rails runner https://github.com/drapergem/draper/pull/739 Package-Manager: portage-2.2.26 dev-ruby/draper/draper-2.1.0-r1.ebuild | 50 ++++++++++++++++++++++ .../draper/files/draper-2.1.0-rails-runner.patch | 29 +++++++++++++ 2 files changed, 79 insertions(+) diff --git a/dev-ruby/draper/draper-2.1.0-r1.ebuild b/dev-ruby/draper/draper-2.1.0-r1.ebuild new file mode 100644 index 0000000..c408ed6 --- /dev/null +++ b/dev-ruby/draper/draper-2.1.0-r1.ebuild @@ -0,0 +1,50 @@ +# Copyright 1999-2016 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Id$ + +EAPI=5 +USE_RUBY="ruby20 ruby21" + +RUBY_FAKEGEM_EXTRADOC="CHANGELOG.md README.md" + +RUBY_FAKEGEM_DOCDIR="doc" +RUBY_FAKEGEM_TASK_DOC="" +RUBY_FAKEGEM_RECIPE_TEST="rspec" + +inherit ruby-fakegem + +DESCRIPTION="View Models for Rails" +HOMEPAGE="https://github.com/drapergem/draper" +LICENSE="MIT" + +KEYWORDS="~amd64" +SLOT="2" +IUSE="test" + +ruby_add_rdepend " + >=dev-ruby/actionpack-3.0:* + >=dev-ruby/activemodel-3.0:* + >=dev-ruby/activesupport-3.0:* + >=dev-ruby/request_store-1.0.3" + +ruby_add_bdepend "test? ( + >=dev-ruby/ammeter-0.2.2 + dev-ruby/active_model_serializers + )" + +RUBY_PATCHES=( ${P}-rails-runner.patch ) + +all_ruby_prepare() { + rm Gemfile || die + sed -e '/[Bb]undler/ s:^:#:' \ + -e '1igem "rails", "~>4.0"' \ + -i spec/spec_helper.rb || die + + # Avoid tests also failing on 1.2.1 which we already use. Could be + # more precise for the 4 specific specs failing. + rm spec/draper/{decorator,decoratable}_spec.rb || die +} + +each_ruby_test() { + ${RUBY} -S rspec spec/draper || die +} diff --git a/dev-ruby/draper/files/draper-2.1.0-rails-runner.patch b/dev-ruby/draper/files/draper-2.1.0-rails-runner.patch new file mode 100644 index 0000000..5a30dd9 --- /dev/null +++ b/dev-ruby/draper/files/draper-2.1.0-rails-runner.patch @@ -0,0 +1,29 @@ +commit bc72bd876ea5ba3d54a21b155f29c9641d2e6ffa +Author: Hans de Graaff <[email protected]> +Date: Tue Apr 19 13:22:00 2016 +0200 + + Also initialize ViewContext for rails runner + + Initialize Draper's ViewContext when using the runner command in a + similar way to using the console command. Without this code run by the + rails runner command (e.g. when processing commands from a message + queue) will not have a properly initialized ViewContext, and + consequently the helpers will not be initialized. + +diff --git a/lib/draper/railtie.rb b/lib/draper/railtie.rb +index e75bda3..ebceec7 100755 +--- a/lib/draper/railtie.rb ++++ b/lib/draper/railtie.rb +@@ -63,6 +63,12 @@ module Draper + Draper::ViewContext.build + end + ++ runner do ++ require 'action_controller/test_case' ++ ApplicationController.new.view_context ++ Draper::ViewContext.build ++ end ++ + rake_tasks do + Dir[File.join(File.dirname(__FILE__),'tasks/*.rake')].each { |f| load f } + end
