diff --git a/CHANGES.md b/CHANGES.md index bee65e73..19dcb704 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -18,8 +18,24 @@ * When using HAML, we do not use any of HAML's helper hacks to "fix" ActionView and XSS. While you might not note this, it removes tons of code from our stack. + +## 4.0.0.beta5 + +* Assets bundled in engine cells now work. +* Directory change: Assets like `.css`, `.coffee` and `.js`, no longer have their own `assets/` directory but live inside the views directory of a cell. It turned out that two directories `views/` and `assets/` was too noisy for most users. If you think you have a valid point for re-introducing it, email me, it is not hard to implement. +* When bundling your cell's assets into the asset pipeline, you have to specify the full name of your cell. The names will be constantized. + + ```ruby + config.cells.with_assets = ["song/cell", "user_cell"] #=> Song::Cell, UserCell + ``` + ## 4.0.0.beta4 +* Fixed a bug when rendering more than once with ERB, the output buffer was being reused. +* API change: ViewModel::_prefixes now returns the "fully qualified" pathes including the view paths, prepended to the prefixes. This allows multiple view paths and basically fixes cells in engines. +* The only public way to retrieve prefixes for a cell is `ViewModel::prefixes`. The result is cached. + + ## 4.0.0.beta3 * Introduce `Cell::Testing` for Rspec and MiniTest. diff --git a/Gemfile b/Gemfile index e218dd28..b37311d6 100644 --- a/Gemfile +++ b/Gemfile @@ -3,5 +3,6 @@ source "https://rubygems.org" gem "railties", "~> 4.2.0" gem "activemodel", "~> 4.2.0" gem "minitest", "~> 5.2" +gem "cells-erb", path: "../cells-erb" gemspec \ No newline at end of file diff --git a/Rakefile b/Rakefile index a57c0cfb..6687b107 100644 --- a/Rakefile +++ b/Rakefile @@ -11,3 +11,14 @@ Rake::TestTask.new(:test) do |test| test.pattern = 'test/*_test.rb' test.verbose = true end + +# Rake::TestTask.new(:rails) do |test| +# test.libs << 'test/rails' +# test.test_files = FileList['test/rails4.2/*_test.rb'] +# test.verbose = true +# end + +# rails_task = Rake::Task["rails"] +# test_task = Rake::Task["test"] +# default_task.enhance { test_task.invoke } +# default_task.enhance { rails_task.invoke } \ No newline at end of file diff --git a/lib/cell.rb b/lib/cell.rb index 504049b4..33dec4e1 100644 --- a/lib/cell.rb +++ b/lib/cell.rb @@ -16,8 +16,8 @@ def self.rails_version end class TemplateMissingError < RuntimeError - def initialize(base, prefixes, view, engine, formats) - super("Template missing: view: `#{view.to_s}.#{engine}` prefixes: #{prefixes.inspect} view_paths:#{base.inspect}") + def initialize(prefixes, view, engine, formats) + super("Template missing: view: `#{view.to_s}.#{engine}` prefixes: #{prefixes.inspect}") end end # Error end diff --git a/lib/cell/partial.rb b/lib/cell/partial.rb index 2fba8986..42b5aaa8 100644 --- a/lib/cell/partial.rb +++ b/lib/cell/partial.rb @@ -10,7 +10,7 @@ def process_options!(options) view = parts.pop view = "_#{view}" view += ".#{options[:formats].first}" if options[:formats] - prefixes = [parts.join("/")] + prefixes = self.class.view_paths.collect { |path| parts.unshift(path).join("/") } options.merge!(:view => view, :prefixes => prefixes) end diff --git a/lib/cell/prefixes.rb b/lib/cell/prefixes.rb index 8ffb9ece..503bf335 100644 --- a/lib/cell/prefixes.rb +++ b/lib/cell/prefixes.rb @@ -1,26 +1,31 @@ -# TODO: merge into Rails core. # TODO: cache _prefixes on class layer. module Cell::Prefixes extend ActiveSupport::Concern def _prefixes - self.class._prefixes + self.class.prefixes end + # You're free to override those methods in case you want to alter our view inheritance. module ClassMethods + def prefixes + @prefixes ||= _prefixes + end + + private def _prefixes return [] if abstract? - _local_prefixes + superclass._prefixes + _local_prefixes + superclass.prefixes end def _local_prefixes - [controller_path] + view_paths.collect { |path| "#{path}/#{controller_path}" } end # Instructs Cells to inherit views from a parent cell without having to inherit class code. def inherit_views(parent) define_method :_prefixes do - super() + parent._prefixes + super() + parent.prefixes end end end diff --git a/lib/cell/rails.rb b/lib/cell/rails.rb index 5f441cb9..fa740af6 100644 --- a/lib/cell/rails.rb +++ b/lib/cell/rails.rb @@ -1,5 +1,4 @@ -# These Methods are automatically added to all Controllers and Views when -# the cells plugin is loaded. +# These methods are automatically added to all controllers and views. module Cell module RailsExtensions module ActionController @@ -10,44 +9,6 @@ def cell(name, model=nil, options={}, &block) def concept(name, model=nil, options={}, &block) Concept.cell(name, model, options.merge(controller: self), &block) end - - # # Renders the cell state and returns the content. You may pass options here, too. They will be - # # around in @opts. - # # - # # Example: - # # - # # @box = render_cell(:posts, :latest, :user => current_user) - # # - # # If you need the cell instance before it renders, you can pass a block receiving the cell. - # # - # # Example: - # # - # # @box = render_cell(:comments, :top5) do |cell| - # # cell.markdown! if config.parse_comments? - # # end - # def render_cell(name, state, *args, &block) - # ::Cell::Rails.render_cell(name, state, self, *args, &block) - # end - - # # Expires the cached cell state view, similar to ActionController::expire_fragment. - # # Usually, this method is used in Sweepers. - # # Beside the obvious first two args cell_name and state you can pass - # # in additional cache key args and cache store specific opts. - # # - # # Example: - # # - # # class ListSweeper < ActionController::Caching::Sweeper - # # observe List, Item - # # - # # def after_save(record) - # # expire_cell_state :my_listing, :display_list - # # end - # # - # # will expire the view for state :display_list in the cell MyListingCell. - # def expire_cell_state(cell_class, state, args={}, opts=nil) - # key = cell_class.state_cache_key(state, args) - # cell_class.expire_cache_key(key, opts) - # end end module ActionView diff --git a/lib/cell/railtie.rb b/lib/cell/railtie.rb index 37efd22b..ebe3f3bb 100644 --- a/lib/cell/railtie.rb +++ b/lib/cell/railtie.rb @@ -19,10 +19,9 @@ class Railtie < Rails::Railtie # ruthlessly stolen from the zurb-foundation gem. initializer 'cells.update_asset_paths' do |app| - Array(app.config.cells.with_assets).each do |name| - # FIXME: this doesn't take engine cells into account. - app.config.assets.paths.append "#{app.root}/app/cells/#{name}/assets" - app.config.assets.paths.append "#{app.root}/app/concepts/#{name}/assets" # TODO: find out type. + Array(app.config.cells.with_assets).each do |cell_class| + # puts "@@@@@ #{cell_class.camelize.constantize.prefixes}" + app.config.assets.paths += cell_class.camelize.constantize.prefixes # Song::Cell.prefixes end end diff --git a/lib/cell/templates.rb b/lib/cell/templates.rb index 9af9ea64..16258df5 100644 --- a/lib/cell/templates.rb +++ b/lib/cell/templates.rb @@ -2,10 +2,10 @@ module Cell # Gets cached in production. class Templates # prefixes could be instance variable as they will never change. - def [](bases, prefixes, view, engine, formats=nil) - base = bases.first # FIXME. + def [](prefixes, view, engine, formats=nil) + view = "#{view}.#{engine}" - find_template(base, prefixes, view, engine) + find_template(prefixes, view, engine) end private @@ -14,19 +14,17 @@ def cache @cache ||= Cache.new end - def find_template(base, prefixes, view, engine) - view = "#{view}.#{engine}" - + def find_template(prefixes, view, engine) cache.fetch(prefixes, view) do |prefix| # this block is run once per cell class per process, for each prefix/view tuple. - create(base, prefix, view) + create(prefix, view) end end - def create(base, prefix, view) - # puts "...checking #{base}/#{prefix}/#{view}" - return unless File.exists?("#{base}/#{prefix}/#{view}") # DISCUSS: can we use Tilt.new here? - Tilt.new("#{base}/#{prefix}/#{view}", :escape_html => false, :escape_attrs => false) + def create(prefix, view) + # puts "...checking #{prefix}/#{view}" + return unless File.exists?("#{prefix}/#{view}") # DISCUSS: can we use Tilt.new here? + Tilt.new("#{prefix}/#{view}", escape_html: false, escape_attrs: false) end # {["comment/row/views", comment/views"][show.haml] => "Tpl:comment/view/show.haml"} diff --git a/lib/cell/testing.rb b/lib/cell/testing.rb index bc629281..8d71ab1f 100644 --- a/lib/cell/testing.rb +++ b/lib/cell/testing.rb @@ -42,23 +42,26 @@ def call(*) # Rails specific. - def controller + def controller_for(controller_class) # TODO: test without controller. - return unless self.class.controller_class + return unless controller_class - # TODO: test with controller. - self.class.controller_class.new.tap do |ctl| - ctl.request = ActionController::TestRequest.new - ctl.instance_variable_set :@routes, Rails.application.routes.url_helpers + controller_class.new.tap do |ctl| + ctl.request = ::ActionController::TestRequest.new + ctl.instance_variable_set :@routes, ::Rails.application.routes.url_helpers end end + def controller # FIXME: this won't allow us using let(:controller) in MiniTest. + controller_for(self.class.controller_class) + end + def self.included(base) base.class_eval do extend Uber::InheritableAttr inheritable_attr :controller_class - def self.controller(name) + def self.controller(name) # DSL method for the test. self.controller_class = name end end diff --git a/lib/cell/version.rb b/lib/cell/version.rb index 011f8127..997c87fd 100644 --- a/lib/cell/version.rb +++ b/lib/cell/version.rb @@ -3,7 +3,7 @@ module VERSION MAJOR = 4 MINOR = 0 TINY = 0 - PRE = "beta3" + PRE = "beta4" STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".") end diff --git a/lib/cell/view_model.rb b/lib/cell/view_model.rb index b3b0c44c..281055e5 100644 --- a/lib/cell/view_model.rb +++ b/lib/cell/view_model.rb @@ -25,7 +25,7 @@ def controller_path extend Uber::Delegates inheritable_attr :view_paths - self.view_paths = ["app/cells"] # DISCUSS: provide same API as rails? + self.view_paths = ["app/cells"] inheritable_attr :template_engine self.template_engine = "erb" @@ -172,20 +172,20 @@ def to_s # output_buffer is returned at the end of the precompiled template. end end def output_buffer # called from the precompiled template. FIXME: this is currently not used in Haml. - @output_buffer ||= OutputBuffer.new + OutputBuffer.new # don't cache output_buffer, for every render call we get a fresh one. end attr_writer :output_buffer # FIXME: where is that used? definitely not in Erbse. + # TODO: remove output_buffer in favor or returning the string. module TemplateFor def template_for(options) view = options[:view] engine = options[:template_engine] - base = options[:base] prefixes = options[:prefixes] # we could also pass _prefixes when creating class.templates, because prefixes are never gonna change per instance. not too sure if i'm just assuming this or if people need that. - self.class.templates[base, prefixes, view, engine] or raise TemplateMissingError.new(base, prefixes, view, engine, nil) + self.class.templates[prefixes, view, engine] or raise TemplateMissingError.new(prefixes, view, engine, nil) end end include TemplateFor @@ -199,13 +199,12 @@ def with_layout(options, content) def normalize_options(options, caller) # TODO: rename to #setup_options! to be inline with Trb. options = if options.is_a?(Hash) - options.reverse_merge(:view => state_for_implicit_render(caller)) # TODO: test implicit render! + options.reverse_merge(:view => state_for_implicit_render(caller)) else {:view => options.to_s} end options[:template_engine] ||= self.class.template_engine # DISCUSS: in separate method? - options[:base] ||= self.class.view_paths options[:prefixes] ||= _prefixes process_options!(options) @@ -228,31 +227,8 @@ def state_for_implicit_render(caller) if defined?(ActionView) - # FIXME: this module is to fix a design flaw in Rails 4.0. the problem is that AV::UrlHelper mixes in the wrong #url_for. - # if we could mix in everything else from the helper except for the #url_for, it would be fine. - # FIXME: fix that in rails core. - if Cell.rails_version <= Gem::Version.new('4.0') - include ActionView::Helpers::UrlHelper # gives us breaking #url_for. - - def url_for(options = nil) # from ActionDispatch:R:UrlFor. - case options - when nil - _routes.url_for(url_options.symbolize_keys) - when Hash - _routes.url_for(options.symbolize_keys.reverse_merge!(url_options)) - when String - options - when Array - polymorphic_url(options, options.extract_options!) - else - polymorphic_url(options) - end - end - - public :url_for - else - include ActionView::Helpers::UrlHelper - end + # always include those helpers so we can override the shitty parts. + include ActionView::Helpers::UrlHelper include ActionView::Helpers::FormTagHelper end end diff --git a/test/concept_test.rb b/test/concept_test.rb index dfc83320..605ea3c4 100644 --- a/test/concept_test.rb +++ b/test/concept_test.rb @@ -40,9 +40,9 @@ class ConceptTest < MiniTest::Spec describe "#_prefixes" do - it { Record::Cell.new._prefixes.must_equal ["record/views"] } - it { Record::Cell::Song.new._prefixes.must_equal ["record/song/views", "record/views"] } - it { Record::Cell::Hit.new._prefixes.must_equal ["record/hit/views", "record/views"] } # with inherit_views. + it { Record::Cell.new._prefixes.must_equal ["test/fixtures/concepts/record/views"] } + it { Record::Cell::Song.new._prefixes.must_equal ["test/fixtures/concepts/record/song/views", "test/fixtures/concepts/record/views"] } + it { Record::Cell::Hit.new._prefixes.must_equal ["test/fixtures/concepts/record/hit/views", "test/fixtures/concepts/record/views"] } # with inherit_views. end it { Record::Cell.new("Wayne").call(:show).must_equal "Party on, Wayne!" } diff --git a/test/dummy/config/application.rb b/test/dummy/config/application.rb index a8fe9e38..0ae34c9b 100644 --- a/test/dummy/config/application.rb +++ b/test/dummy/config/application.rb @@ -21,7 +21,7 @@ class Application < Rails::Application # enable asset pipeline as in development. config.assets.enabled = true config.assets.compile = true - config.cells.with_assets = ["album", "song"] + # config.cells.with_assets = ["song/cell"] config.cache_classes = true # Show full error reports and disable caching diff --git a/test/prefixes_test.rb b/test/prefixes_test.rb index 4868bff1..ea084ceb 100644 --- a/test/prefixes_test.rb +++ b/test/prefixes_test.rb @@ -6,6 +6,18 @@ class BassistCell::FenderCell < Cell::ViewModel class BassistCell::IbanezCell < BassistCell end +class WannabeCell < BassistCell::IbanezCell +end + +# engine: shopify +# shopify/cart/cell + +class EngineCell < Cell::ViewModel + self.view_paths << "/var/engine/app/cells" +end +class InheritingFromEngineCell < EngineCell +end + class PrefixesTest < MiniTest::Spec class SingerCell < Cell::ViewModel end @@ -35,17 +47,35 @@ def self._local_prefixes end describe "#_prefixes" do - it { ::BassistCell.new(@controller)._prefixes.must_equal ["bassist"] } - it { ::BassistCell::FenderCell.new(@controller)._prefixes.must_equal ["bassist_cell/fender"] } - it { ::BassistCell::IbanezCell.new(@controller)._prefixes.must_equal ["bassist_cell/ibanez", "bassist"] } + it { ::BassistCell.new(@controller)._prefixes.must_equal ["test/fixtures/bassist"] } + it { ::BassistCell::FenderCell.new(@controller)._prefixes.must_equal ["app/cells/bassist_cell/fender"] } + it { ::BassistCell::IbanezCell.new(@controller)._prefixes.must_equal ["test/fixtures/bassist_cell/ibanez", "test/fixtures/bassist"] } - it { SingerCell.new(@controller)._prefixes.must_equal ["prefixes_test/singer"] } - it { BackgroundVocalsCell.new(@controller)._prefixes.must_equal ["prefixes_test/background_vocals", "prefixes_test/singer"] } - it { ChorusCell.new(@controller)._prefixes.must_equal ["prefixes_test/chorus", "prefixes_test/background_vocals", "prefixes_test/singer"] } + it { SingerCell.new(@controller)._prefixes.must_equal ["app/cells/prefixes_test/singer"] } + it { BackgroundVocalsCell.new(@controller)._prefixes.must_equal ["app/cells/prefixes_test/background_vocals", "app/cells/prefixes_test/singer"] } + it { ChorusCell.new(@controller)._prefixes.must_equal ["app/cells/prefixes_test/chorus", "app/cells/prefixes_test/background_vocals", "app/cells/prefixes_test/singer"] } - it { GuitaristCell.new(@controller)._prefixes.must_equal ["stringer", "prefixes_test/singer"] } - it { BassistCell.new(@controller)._prefixes.must_equal ["prefixes_test/bassist", "basser", "prefixes_test/singer"] } + it { GuitaristCell.new(@controller)._prefixes.must_equal ["stringer", "app/cells/prefixes_test/singer"] } + it { BassistCell.new(@controller)._prefixes.must_equal ["app/cells/prefixes_test/bassist", "basser", "app/cells/prefixes_test/singer"] } # it { DrummerCell.new(@controller)._prefixes.must_equal ["drummer", "stringer", "prefixes_test/singer"] } + + # multiple view_paths. + it { EngineCell.prefixes.must_equal ["app/cells/engine", "/var/engine/app/cells/engine"] } + it do + InheritingFromEngineCell.prefixes.must_equal [ + "app/cells/inheriting_from_engine", "/var/engine/app/cells/inheriting_from_engine", + "app/cells/engine", "/var/engine/app/cells/engine"] + end + + # ::_prefixes is cached. + it do + WannabeCell.prefixes.must_equal ["test/fixtures/wannabe", "test/fixtures/bassist_cell/ibanez", "test/fixtures/bassist"] + WannabeCell.instance_eval { def _local_prefixes; ["more"] end } + # _prefixes is cached. + WannabeCell.prefixes.must_equal ["test/fixtures/wannabe", "test/fixtures/bassist_cell/ibanez", "test/fixtures/bassist"] + # superclasses don't get disturbed. + ::BassistCell.prefixes.must_equal ["test/fixtures/bassist"] + end end # it { Record::Cell.new(@controller).render_state(:show).must_equal "Rock on!" } @@ -65,8 +95,8 @@ def play class FunkerCell < SlapperCell end - it { SlapperCell.new(nil)._prefixes.must_equal ["inherit_views_test/slapper", "bassist"] } - it { FunkerCell.new(nil)._prefixes.must_equal ["inherit_views_test/funker", "inherit_views_test/slapper", "bassist"] } + it { SlapperCell.new(nil)._prefixes.must_equal ["test/fixtures/inherit_views_test/slapper", "test/fixtures/bassist"] } + it { FunkerCell.new(nil)._prefixes.must_equal ["test/fixtures/inherit_views_test/funker", "test/fixtures/inherit_views_test/slapper", "test/fixtures/bassist"] } # test if normal cells inherit views. it { cell('inherit_views_test/slapper').play.must_equal 'Doo' } diff --git a/test/rails4.2/.gitignore b/test/rails4.2/.gitignore new file mode 100644 index 00000000..280c06b1 --- /dev/null +++ b/test/rails4.2/.gitignore @@ -0,0 +1,13 @@ +# See https://help.github.com/articles/ignoring-files for more about ignoring files. +# +# If you find yourself ignoring temporary files generated by your text editor +# or operating system, you probably want to add a global ignore instead: +# git config --global core.excludesfile '~/.gitignore_global' + +# Ignore bundler config. +/.bundle + +# Ignore all logfiles and tempfiles. +/log/* +!/log/.keep +/tmp \ No newline at end of file diff --git a/test/rails4.2/Gemfile b/test/rails4.2/Gemfile new file mode 100644 index 00000000..93dd4bb1 --- /dev/null +++ b/test/rails4.2/Gemfile @@ -0,0 +1,16 @@ +source 'https://rubygems.org' + +gem 'rails', '4.2.1' + +gem "my_engine", path: "engines/my_engine" + +gem 'sass-rails', "~> 4.0.3"#, " ~> 3.1.0" +gem "sprockets", "~> 2.12.3" + +group :development, :test do + gem "minitest-spec-rails" + gem "capybara_minitest_spec" +end + +gem "cells", path: "../../" +gem "cells-erb" diff --git a/test/rails4.2/README.rdoc b/test/rails4.2/README.rdoc new file mode 100644 index 00000000..0140cf42 --- /dev/null +++ b/test/rails4.2/README.rdoc @@ -0,0 +1,3 @@ +== README + +Demo app for Cells 4 and Rails engines diff --git a/test/rails4.2/Rakefile b/test/rails4.2/Rakefile new file mode 100644 index 00000000..ba6b733d --- /dev/null +++ b/test/rails4.2/Rakefile @@ -0,0 +1,6 @@ +# Add your own tasks in files placed in lib/tasks ending in .rake, +# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. + +require File.expand_path('../config/application', __FILE__) + +Rails.application.load_tasks diff --git a/test/rails4.2/app/assets/images/.keep b/test/rails4.2/app/assets/images/.keep new file mode 100644 index 00000000..e69de29b diff --git a/test/rails4.2/app/assets/stylesheets/application.css b/test/rails4.2/app/assets/stylesheets/application.css new file mode 100644 index 00000000..3701c2a0 --- /dev/null +++ b/test/rails4.2/app/assets/stylesheets/application.css @@ -0,0 +1,17 @@ +/* + * This is a manifest file that'll be compiled into application.css, which will include all the files + * listed below. + * + * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets, + * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path. + * + * You're free to add application-wide styles to this file and they'll appear at the bottom of the + * compiled file so the styles you add here take precedence over styles defined in any styles + * defined in the other CSS/SCSS files in this directory. It is generally better to create a new + * file per style scope. + * + *= require_tree . + *= require_self + *= require user + *= require song + */ diff --git a/test/rails4.2/app/cells/song/song.css b/test/rails4.2/app/cells/song/song.css new file mode 100644 index 00000000..da39d118 --- /dev/null +++ b/test/rails4.2/app/cells/song/song.css @@ -0,0 +1 @@ +.song { background: red; } \ No newline at end of file diff --git a/test/rails4.2/app/cells/song_cell.rb b/test/rails4.2/app/cells/song_cell.rb new file mode 100644 index 00000000..a1405cd6 --- /dev/null +++ b/test/rails4.2/app/cells/song_cell.rb @@ -0,0 +1,2 @@ +class SongCell < Cell::ViewModel +end \ No newline at end of file diff --git a/test/rails4.2/app/controllers/application_controller.rb b/test/rails4.2/app/controllers/application_controller.rb new file mode 100644 index 00000000..d83690e1 --- /dev/null +++ b/test/rails4.2/app/controllers/application_controller.rb @@ -0,0 +1,5 @@ +class ApplicationController < ActionController::Base + # Prevent CSRF attacks by raising an exception. + # For APIs, you may want to use :null_session instead. + protect_from_forgery with: :exception +end diff --git a/test/rails4.2/app/controllers/concerns/.keep b/test/rails4.2/app/controllers/concerns/.keep new file mode 100644 index 00000000..e69de29b diff --git a/test/rails4.2/app/controllers/index_controller.rb b/test/rails4.2/app/controllers/index_controller.rb new file mode 100644 index 00000000..3f52a606 --- /dev/null +++ b/test/rails4.2/app/controllers/index_controller.rb @@ -0,0 +1,7 @@ +class IndexController < ApplicationController + + def index + end + +end + diff --git a/test/rails4.2/app/helpers/application_helper.rb b/test/rails4.2/app/helpers/application_helper.rb new file mode 100644 index 00000000..de6be794 --- /dev/null +++ b/test/rails4.2/app/helpers/application_helper.rb @@ -0,0 +1,2 @@ +module ApplicationHelper +end diff --git a/test/rails4.2/app/mailers/.keep b/test/rails4.2/app/mailers/.keep new file mode 100644 index 00000000..e69de29b diff --git a/test/rails4.2/app/models/.keep b/test/rails4.2/app/models/.keep new file mode 100644 index 00000000..e69de29b diff --git a/test/rails4.2/app/models/concerns/.keep b/test/rails4.2/app/models/concerns/.keep new file mode 100644 index 00000000..e69de29b diff --git a/test/rails4.2/app/views/index/index.html.erb b/test/rails4.2/app/views/index/index.html.erb new file mode 100644 index 00000000..aeabffce --- /dev/null +++ b/test/rails4.2/app/views/index/index.html.erb @@ -0,0 +1,6 @@ +

Hello World

+<%= link_to "render", my_engine.user_path %> + + +hello? +<%= concept( "user/cell") %> \ No newline at end of file diff --git a/test/rails4.2/app/views/layouts/application.html.erb b/test/rails4.2/app/views/layouts/application.html.erb new file mode 100644 index 00000000..0a6d69e1 --- /dev/null +++ b/test/rails4.2/app/views/layouts/application.html.erb @@ -0,0 +1,13 @@ + + + + EngineCells + <%= stylesheet_link_tag 'application', media: 'all' %> + <%= csrf_meta_tags %> + + + +<%= yield %> + + + diff --git a/test/rails4.2/bin/bundle b/test/rails4.2/bin/bundle new file mode 100755 index 00000000..66e9889e --- /dev/null +++ b/test/rails4.2/bin/bundle @@ -0,0 +1,3 @@ +#!/usr/bin/env ruby +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) +load Gem.bin_path('bundler', 'bundle') diff --git a/test/rails4.2/bin/rails b/test/rails4.2/bin/rails new file mode 100755 index 00000000..5191e692 --- /dev/null +++ b/test/rails4.2/bin/rails @@ -0,0 +1,4 @@ +#!/usr/bin/env ruby +APP_PATH = File.expand_path('../../config/application', __FILE__) +require_relative '../config/boot' +require 'rails/commands' diff --git a/test/rails4.2/bin/rake b/test/rails4.2/bin/rake new file mode 100755 index 00000000..17240489 --- /dev/null +++ b/test/rails4.2/bin/rake @@ -0,0 +1,4 @@ +#!/usr/bin/env ruby +require_relative '../config/boot' +require 'rake' +Rake.application.run diff --git a/test/rails4.2/bin/setup b/test/rails4.2/bin/setup new file mode 100755 index 00000000..acdb2c13 --- /dev/null +++ b/test/rails4.2/bin/setup @@ -0,0 +1,29 @@ +#!/usr/bin/env ruby +require 'pathname' + +# path to your application root. +APP_ROOT = Pathname.new File.expand_path('../../', __FILE__) + +Dir.chdir APP_ROOT do + # This script is a starting point to setup your application. + # Add necessary setup steps to this file: + + puts "== Installing dependencies ==" + system "gem install bundler --conservative" + system "bundle check || bundle install" + + # puts "\n== Copying sample files ==" + # unless File.exist?("config/database.yml") + # system "cp config/database.yml.sample config/database.yml" + # end + + puts "\n== Preparing database ==" + system "bin/rake db:setup" + + puts "\n== Removing old logs and tempfiles ==" + system "rm -f log/*" + system "rm -rf tmp/cache" + + puts "\n== Restarting application server ==" + system "touch tmp/restart.txt" +end diff --git a/test/rails4.2/config.ru b/test/rails4.2/config.ru new file mode 100644 index 00000000..bd83b254 --- /dev/null +++ b/test/rails4.2/config.ru @@ -0,0 +1,4 @@ +# This file is used by Rack-based servers to start the application. + +require ::File.expand_path('../config/environment', __FILE__) +run Rails.application diff --git a/test/rails4.2/config/application.rb b/test/rails4.2/config/application.rb new file mode 100644 index 00000000..751642a8 --- /dev/null +++ b/test/rails4.2/config/application.rb @@ -0,0 +1,38 @@ +require File.expand_path('../boot', __FILE__) + +require "rails" +# Pick the frameworks you want: +require "active_model/railtie" +require "active_job/railtie" +# require "active_record/railtie" +require "action_controller/railtie" +require "action_mailer/railtie" +require "action_view/railtie" +require "sprockets/railtie" +require "rails/test_unit/railtie" + +# Require the gems listed in Gemfile, including any gems +# you've limited to :test, :development, or :production. +Bundler.require(*Rails.groups) + +module EngineCells + class Application < Rails::Application + # Settings in config/environments/* take precedence over those specified here. + # Application configuration should go into files in config/initializers + # -- all .rb files in that directory are automatically loaded. + + # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. + # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC. + # config.time_zone = 'Central Time (US & Canada)' + + # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. + # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] + # config.i18n.default_locale = :de + + # enable asset pipeline as in development/test. + config.assets.enabled = true + config.assets.compile = true + + config.cells.with_assets = ["user/cell", "song_cell"] + end +end diff --git a/test/rails4.2/config/boot.rb b/test/rails4.2/config/boot.rb new file mode 100644 index 00000000..6b750f00 --- /dev/null +++ b/test/rails4.2/config/boot.rb @@ -0,0 +1,3 @@ +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) + +require 'bundler/setup' # Set up gems listed in the Gemfile. diff --git a/test/rails4.2/config/environment.rb b/test/rails4.2/config/environment.rb new file mode 100644 index 00000000..ee8d90dc --- /dev/null +++ b/test/rails4.2/config/environment.rb @@ -0,0 +1,5 @@ +# Load the Rails application. +require File.expand_path('../application', __FILE__) + +# Initialize the Rails application. +Rails.application.initialize! diff --git a/test/rails4.2/config/environments/development.rb b/test/rails4.2/config/environments/development.rb new file mode 100644 index 00000000..61a2a705 --- /dev/null +++ b/test/rails4.2/config/environments/development.rb @@ -0,0 +1,25 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # In the development environment your application's code is reloaded on + # every request. This slows down response time but is perfect for development + # since you don't have to restart the web server when you make code changes. + config.cache_classes = false + + # Do not eager load code on boot. + config.eager_load = false + + # Show full error reports and disable caching. + config.consider_all_requests_local = true + config.action_controller.perform_caching = false + + # Don't care if the mailer can't send. + config.action_mailer.raise_delivery_errors = false + + # Print deprecation notices to the Rails logger. + config.active_support.deprecation = :log + + + # Raises error for missing translations + # config.action_view.raise_on_missing_translations = true +end diff --git a/test/rails4.2/config/environments/production.rb b/test/rails4.2/config/environments/production.rb new file mode 100644 index 00000000..2babca38 --- /dev/null +++ b/test/rails4.2/config/environments/production.rb @@ -0,0 +1,64 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # Code is not reloaded between requests. + config.cache_classes = true + + # Eager load code on boot. This eager loads most of Rails and + # your application in memory, allowing both threaded web servers + # and those relying on copy on write to perform better. + # Rake tasks automatically ignore this option for performance. + config.eager_load = true + + # Full error reports are disabled and caching is turned on. + config.consider_all_requests_local = false + config.action_controller.perform_caching = true + + # Enable Rack::Cache to put a simple HTTP cache in front of your application + # Add `rack-cache` to your Gemfile before enabling this. + # For large-scale production use, consider using a caching reverse proxy like + # NGINX, varnish or squid. + # config.action_dispatch.rack_cache = true + + # Disable serving static files from the `/public` folder by default since + # Apache or NGINX already handles this. + config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present? + + + # Specifies the header that your server uses for sending files. + # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache + # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX + + # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. + # config.force_ssl = true + + # Use the lowest log level to ensure availability of diagnostic information + # when problems arise. + config.log_level = :debug + + # Prepend all log lines with the following tags. + # config.log_tags = [ :subdomain, :uuid ] + + # Use a different logger for distributed setups. + # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new) + + # Use a different cache store in production. + # config.cache_store = :mem_cache_store + + # Enable serving of images, stylesheets, and JavaScripts from an asset server. + # config.action_controller.asset_host = 'http://assets.example.com' + + # Ignore bad email addresses and do not raise email delivery errors. + # Set this to true and configure the email server for immediate delivery to raise delivery errors. + # config.action_mailer.raise_delivery_errors = false + + # Enable locale fallbacks for I18n (makes lookups for any locale fall back to + # the I18n.default_locale when a translation cannot be found). + config.i18n.fallbacks = true + + # Send deprecation notices to registered listeners. + config.active_support.deprecation = :notify + + # Use default logging formatter so that PID and timestamp are not suppressed. + config.log_formatter = ::Logger::Formatter.new +end diff --git a/test/rails4.2/config/environments/test.rb b/test/rails4.2/config/environments/test.rb new file mode 100644 index 00000000..1c19f08b --- /dev/null +++ b/test/rails4.2/config/environments/test.rb @@ -0,0 +1,42 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # The test environment is used exclusively to run your application's + # test suite. You never need to work with it otherwise. Remember that + # your test database is "scratch space" for the test suite and is wiped + # and recreated between test runs. Don't rely on the data there! + config.cache_classes = true + + # Do not eager load code on boot. This avoids loading your whole application + # just for the purpose of running a single test. If you are using a tool that + # preloads Rails for running tests, you may have to set it to true. + config.eager_load = false + + # Configure static file server for tests with Cache-Control for performance. + config.serve_static_files = true + config.static_cache_control = 'public, max-age=3600' + + # Show full error reports and disable caching. + config.consider_all_requests_local = true + config.action_controller.perform_caching = false + + # Raise exceptions instead of rendering exception templates. + config.action_dispatch.show_exceptions = false + + # Disable request forgery protection in test environment. + config.action_controller.allow_forgery_protection = false + + # Tell Action Mailer not to deliver emails to the real world. + # The :test delivery method accumulates sent emails in the + # ActionMailer::Base.deliveries array. + config.action_mailer.delivery_method = :test + + # Randomize the order test cases are executed. + config.active_support.test_order = :random + + # Print deprecation notices to the stderr. + config.active_support.deprecation = :stderr + + # Raises error for missing translations + # config.action_view.raise_on_missing_translations = true +end diff --git a/test/rails4.2/config/initializers/backtrace_silencers.rb b/test/rails4.2/config/initializers/backtrace_silencers.rb new file mode 100644 index 00000000..59385cdf --- /dev/null +++ b/test/rails4.2/config/initializers/backtrace_silencers.rb @@ -0,0 +1,7 @@ +# Be sure to restart your server when you modify this file. + +# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. +# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } + +# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code. +# Rails.backtrace_cleaner.remove_silencers! diff --git a/test/rails4.2/config/initializers/cookies_serializer.rb b/test/rails4.2/config/initializers/cookies_serializer.rb new file mode 100644 index 00000000..7f70458d --- /dev/null +++ b/test/rails4.2/config/initializers/cookies_serializer.rb @@ -0,0 +1,3 @@ +# Be sure to restart your server when you modify this file. + +Rails.application.config.action_dispatch.cookies_serializer = :json diff --git a/test/rails4.2/config/initializers/filter_parameter_logging.rb b/test/rails4.2/config/initializers/filter_parameter_logging.rb new file mode 100644 index 00000000..4a994e1e --- /dev/null +++ b/test/rails4.2/config/initializers/filter_parameter_logging.rb @@ -0,0 +1,4 @@ +# Be sure to restart your server when you modify this file. + +# Configure sensitive parameters which will be filtered from the log file. +Rails.application.config.filter_parameters += [:password] diff --git a/test/rails4.2/config/initializers/inflections.rb b/test/rails4.2/config/initializers/inflections.rb new file mode 100644 index 00000000..ac033bf9 --- /dev/null +++ b/test/rails4.2/config/initializers/inflections.rb @@ -0,0 +1,16 @@ +# Be sure to restart your server when you modify this file. + +# Add new inflection rules using the following format. Inflections +# are locale specific, and you may define rules for as many different +# locales as you wish. All of these examples are active by default: +# ActiveSupport::Inflector.inflections(:en) do |inflect| +# inflect.plural /^(ox)$/i, '\1en' +# inflect.singular /^(ox)en/i, '\1' +# inflect.irregular 'person', 'people' +# inflect.uncountable %w( fish sheep ) +# end + +# These inflection rules are supported but not enabled by default: +# ActiveSupport::Inflector.inflections(:en) do |inflect| +# inflect.acronym 'RESTful' +# end diff --git a/test/rails4.2/config/initializers/mime_types.rb b/test/rails4.2/config/initializers/mime_types.rb new file mode 100644 index 00000000..dc189968 --- /dev/null +++ b/test/rails4.2/config/initializers/mime_types.rb @@ -0,0 +1,4 @@ +# Be sure to restart your server when you modify this file. + +# Add new mime types for use in respond_to blocks: +# Mime::Type.register "text/richtext", :rtf diff --git a/test/rails4.2/config/initializers/session_store.rb b/test/rails4.2/config/initializers/session_store.rb new file mode 100644 index 00000000..4cebc0bb --- /dev/null +++ b/test/rails4.2/config/initializers/session_store.rb @@ -0,0 +1,3 @@ +# Be sure to restart your server when you modify this file. + +Rails.application.config.session_store :cookie_store, key: '_engine_cells_session' diff --git a/test/rails4.2/config/initializers/wrap_parameters.rb b/test/rails4.2/config/initializers/wrap_parameters.rb new file mode 100644 index 00000000..b81ea74b --- /dev/null +++ b/test/rails4.2/config/initializers/wrap_parameters.rb @@ -0,0 +1,9 @@ +# Be sure to restart your server when you modify this file. + +# This file contains settings for ActionController::ParamsWrapper which +# is enabled by default. + +# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. +ActiveSupport.on_load(:action_controller) do + wrap_parameters format: [:json] if respond_to?(:wrap_parameters) +end diff --git a/test/rails4.2/config/locales/en.yml b/test/rails4.2/config/locales/en.yml new file mode 100644 index 00000000..06539571 --- /dev/null +++ b/test/rails4.2/config/locales/en.yml @@ -0,0 +1,23 @@ +# Files in the config/locales directory are used for internationalization +# and are automatically loaded by Rails. If you want to use locales other +# than English, add the necessary files in this directory. +# +# To use the locales, use `I18n.t`: +# +# I18n.t 'hello' +# +# In views, this is aliased to just `t`: +# +# <%= t('hello') %> +# +# To use a different locale, set it with `I18n.locale`: +# +# I18n.locale = :es +# +# This would use the information in config/locales/es.yml. +# +# To learn more, please read the Rails Internationalization guide +# available at http://guides.rubyonrails.org/i18n.html. + +en: + hello: "Hello world" diff --git a/test/rails4.2/config/routes.rb b/test/rails4.2/config/routes.rb new file mode 100644 index 00000000..f26d943a --- /dev/null +++ b/test/rails4.2/config/routes.rb @@ -0,0 +1,4 @@ +Rails.application.routes.draw do + mount MyEngine::Engine => "/" + root to: "index#index" +end diff --git a/test/rails4.2/config/secrets.yml b/test/rails4.2/config/secrets.yml new file mode 100644 index 00000000..5a695ade --- /dev/null +++ b/test/rails4.2/config/secrets.yml @@ -0,0 +1,22 @@ +# Be sure to restart your server when you modify this file. + +# Your secret key is used for verifying the integrity of signed cookies. +# If you change this key, all old signed cookies will become invalid! + +# Make sure the secret is at least 30 characters and all random, +# no regular words or you'll be exposed to dictionary attacks. +# You can use `rake secret` to generate a secure secret key. + +# Make sure the secrets in this file are kept private +# if you're sharing your code publicly. + +development: + secret_key_base: 0ff2fd9cbf01493f9bc5368f102cfd66e9a69b5fbbdd3c308afccef6de2f7c834cc19618d305f223a1e01a5fbf98d4d41c9017214efe9fa3832282eaca032c7f + +test: + secret_key_base: 8c3a9dbc139ed27c32022254d832f53a3d4d3e545003be31cd5bbc3b81b5ff0a8a6d9b9f6aab6ca206aff92a7ccc6f32354d3c9cf77b4708e1c4778a6d5920a4 + +# Do not keep production secrets in the repository, +# instead read values from the environment. +production: + secret_key_base: <%= ENV["SECRET_KEY_BASE"] %> diff --git a/test/rails4.2/db/seeds.rb b/test/rails4.2/db/seeds.rb new file mode 100644 index 00000000..4edb1e85 --- /dev/null +++ b/test/rails4.2/db/seeds.rb @@ -0,0 +1,7 @@ +# This file should contain all the record creation needed to seed the database with its default values. +# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup). +# +# Examples: +# +# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }]) +# Mayor.create(name: 'Emanuel', city: cities.first) diff --git a/test/rails4.2/engines/my_engine/.gitignore b/test/rails4.2/engines/my_engine/.gitignore new file mode 100644 index 00000000..8619e09c --- /dev/null +++ b/test/rails4.2/engines/my_engine/.gitignore @@ -0,0 +1,3 @@ +.bundle/ +log/*.log +pkg/ diff --git a/test/rails4.2/engines/my_engine/Gemfile b/test/rails4.2/engines/my_engine/Gemfile new file mode 100644 index 00000000..abd6ab95 --- /dev/null +++ b/test/rails4.2/engines/my_engine/Gemfile @@ -0,0 +1,15 @@ +source 'https://rubygems.org' + +# Declare your gem's dependencies in my_engine.gemspec. +# Bundler will treat runtime dependencies like base dependencies, and +# development dependencies will be added by default to the :development group. +gemspec + +# Declare any dependencies that are still in development here instead of in +# your gemspec. These might include edge Rails or gems from your path or +# Git. Remember to move these dependencies to your gemspec before releasing +# your gem to rubygems.org. + +# To use a debugger +# gem 'byebug', group: [:development, :test] + diff --git a/test/rails4.2/engines/my_engine/MIT-LICENSE b/test/rails4.2/engines/my_engine/MIT-LICENSE new file mode 100644 index 00000000..f56a639a --- /dev/null +++ b/test/rails4.2/engines/my_engine/MIT-LICENSE @@ -0,0 +1,20 @@ +Copyright 2015 Alexander Huber + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/test/rails4.2/engines/my_engine/README.rdoc b/test/rails4.2/engines/my_engine/README.rdoc new file mode 100644 index 00000000..b3ffb62a --- /dev/null +++ b/test/rails4.2/engines/my_engine/README.rdoc @@ -0,0 +1,3 @@ += MyEngine + +This project rocks and uses MIT-LICENSE. \ No newline at end of file diff --git a/test/rails4.2/engines/my_engine/Rakefile b/test/rails4.2/engines/my_engine/Rakefile new file mode 100644 index 00000000..f2ad5f43 --- /dev/null +++ b/test/rails4.2/engines/my_engine/Rakefile @@ -0,0 +1,24 @@ +begin + require 'bundler/setup' +rescue LoadError + puts 'You must `gem install bundler` and `bundle install` to run rake tasks' +end + +require 'rdoc/task' + +RDoc::Task.new(:rdoc) do |rdoc| + rdoc.rdoc_dir = 'rdoc' + rdoc.title = 'MyEngine' + rdoc.options << '--line-numbers' + rdoc.rdoc_files.include('README.rdoc') + rdoc.rdoc_files.include('lib/**/*.rb') +end + + + +load 'rails/tasks/statistics.rake' + + + +Bundler::GemHelper.install_tasks + diff --git a/test/rails4.2/engines/my_engine/app/assets/images/my_engine/.keep b/test/rails4.2/engines/my_engine/app/assets/images/my_engine/.keep new file mode 100644 index 00000000..e69de29b diff --git a/test/rails4.2/engines/my_engine/app/assets/stylesheets/my_engine/application.css b/test/rails4.2/engines/my_engine/app/assets/stylesheets/my_engine/application.css new file mode 100644 index 00000000..f9cd5b34 --- /dev/null +++ b/test/rails4.2/engines/my_engine/app/assets/stylesheets/my_engine/application.css @@ -0,0 +1,15 @@ +/* + * This is a manifest file that'll be compiled into application.css, which will include all the files + * listed below. + * + * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets, + * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path. + * + * You're free to add application-wide styles to this file and they'll appear at the bottom of the + * compiled file so the styles you add here take precedence over styles defined in any styles + * defined in the other CSS/SCSS files in this directory. It is generally better to create a new + * file per style scope. + * + *= require_tree . + *= require_self + */ diff --git a/test/rails4.2/engines/my_engine/app/concepts/user/cell.rb b/test/rails4.2/engines/my_engine/app/concepts/user/cell.rb new file mode 100644 index 00000000..c70bfed3 --- /dev/null +++ b/test/rails4.2/engines/my_engine/app/concepts/user/cell.rb @@ -0,0 +1,8 @@ +class User::Cell < Cell::Concept + view_paths << "#{MyEngine::Engine.root}/app/concepts" + + def show + # return _prefixes.inspect + render#(view: :show) + end +end diff --git a/test/rails4.2/engines/my_engine/app/concepts/user/views/show.erb b/test/rails4.2/engines/my_engine/app/concepts/user/views/show.erb new file mode 100644 index 00000000..f4f646be --- /dev/null +++ b/test/rails4.2/engines/my_engine/app/concepts/user/views/show.erb @@ -0,0 +1 @@ +<%= "Just an empty view, rendered by a cell..." %> diff --git a/test/rails4.2/engines/my_engine/app/concepts/user/views/user.scss b/test/rails4.2/engines/my_engine/app/concepts/user/views/user.scss new file mode 100644 index 00000000..e4aedea8 --- /dev/null +++ b/test/rails4.2/engines/my_engine/app/concepts/user/views/user.scss @@ -0,0 +1,3 @@ +user { + background: green; +} \ No newline at end of file diff --git a/test/rails4.2/engines/my_engine/app/controllers/my_engine/application_controller.rb b/test/rails4.2/engines/my_engine/app/controllers/my_engine/application_controller.rb new file mode 100644 index 00000000..ee464113 --- /dev/null +++ b/test/rails4.2/engines/my_engine/app/controllers/my_engine/application_controller.rb @@ -0,0 +1,4 @@ +module MyEngine + class ApplicationController < ActionController::Base + end +end diff --git a/test/rails4.2/engines/my_engine/app/controllers/my_engine/user_controller.rb b/test/rails4.2/engines/my_engine/app/controllers/my_engine/user_controller.rb new file mode 100644 index 00000000..88b5b316 --- /dev/null +++ b/test/rails4.2/engines/my_engine/app/controllers/my_engine/user_controller.rb @@ -0,0 +1,7 @@ +module MyEngine + class UserController < MyEngine::ApplicationController + + def show + end + end +end diff --git a/test/rails4.2/engines/my_engine/app/helpers/my_engine/application_helper.rb b/test/rails4.2/engines/my_engine/app/helpers/my_engine/application_helper.rb new file mode 100644 index 00000000..2b8d6d06 --- /dev/null +++ b/test/rails4.2/engines/my_engine/app/helpers/my_engine/application_helper.rb @@ -0,0 +1,4 @@ +module MyEngine + module ApplicationHelper + end +end diff --git a/test/rails4.2/engines/my_engine/app/models/my_engine/user.rb b/test/rails4.2/engines/my_engine/app/models/my_engine/user.rb new file mode 100644 index 00000000..cde5bbf0 --- /dev/null +++ b/test/rails4.2/engines/my_engine/app/models/my_engine/user.rb @@ -0,0 +1,4 @@ +module MyEngine + class User + end +end diff --git a/test/rails4.2/engines/my_engine/app/views/layouts/my_engine/application.html.erb b/test/rails4.2/engines/my_engine/app/views/layouts/my_engine/application.html.erb new file mode 100644 index 00000000..b83385a1 --- /dev/null +++ b/test/rails4.2/engines/my_engine/app/views/layouts/my_engine/application.html.erb @@ -0,0 +1,14 @@ + + + + MyEngine + <%= stylesheet_link_tag "my_engine/application", media: "all" %> + <%= javascript_include_tag "my_engine/application" %> + <%= csrf_meta_tags %> + + + +<%= yield %> + + + diff --git a/test/rails4.2/engines/my_engine/app/views/my_engine/user/show.html.erb b/test/rails4.2/engines/my_engine/app/views/my_engine/user/show.html.erb new file mode 100644 index 00000000..a0822b4c --- /dev/null +++ b/test/rails4.2/engines/my_engine/app/views/my_engine/user/show.html.erb @@ -0,0 +1,3 @@ +<%- @user = MyEngine::User.new %> + +<%= concept("user/cell", @user) %> diff --git a/test/rails4.2/engines/my_engine/bin/rails b/test/rails4.2/engines/my_engine/bin/rails new file mode 100755 index 00000000..6472cc6d --- /dev/null +++ b/test/rails4.2/engines/my_engine/bin/rails @@ -0,0 +1,12 @@ +#!/usr/bin/env ruby +# This command will automatically be run when you run "rails" with Rails 4 gems installed from the root of your application. + +ENGINE_ROOT = File.expand_path('../..', __FILE__) +ENGINE_PATH = File.expand_path('../../lib/my_engine/engine', __FILE__) + +# Set up gems listed in the Gemfile. +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) +require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE']) + +require 'rails/all' +require 'rails/engine/commands' diff --git a/test/rails4.2/engines/my_engine/config/routes.rb b/test/rails4.2/engines/my_engine/config/routes.rb new file mode 100644 index 00000000..dbbe78a9 --- /dev/null +++ b/test/rails4.2/engines/my_engine/config/routes.rb @@ -0,0 +1,3 @@ +MyEngine::Engine.routes.draw do + get "user" => "user#show" +end diff --git a/test/rails4.2/engines/my_engine/db/migrate/20150530135920_create_my_engine_users.rb b/test/rails4.2/engines/my_engine/db/migrate/20150530135920_create_my_engine_users.rb new file mode 100644 index 00000000..6f062d4f --- /dev/null +++ b/test/rails4.2/engines/my_engine/db/migrate/20150530135920_create_my_engine_users.rb @@ -0,0 +1,8 @@ +class CreateMyEngineUsers < ActiveRecord::Migration + def change + create_table :my_engine_users do |t| + + t.timestamps null: false + end + end +end diff --git a/test/rails4.2/engines/my_engine/lib/my_engine.rb b/test/rails4.2/engines/my_engine/lib/my_engine.rb new file mode 100644 index 00000000..9e62dd37 --- /dev/null +++ b/test/rails4.2/engines/my_engine/lib/my_engine.rb @@ -0,0 +1,6 @@ +require "my_engine/engine" + +module MyEngine + # This also works + # Cell::Concept.view_paths << File.expand_path("#{MyEngine::Engine.root}/app/concepts", __FILE__) +end diff --git a/test/rails4.2/engines/my_engine/lib/my_engine/engine.rb b/test/rails4.2/engines/my_engine/lib/my_engine/engine.rb new file mode 100644 index 00000000..4939829d --- /dev/null +++ b/test/rails4.2/engines/my_engine/lib/my_engine/engine.rb @@ -0,0 +1,9 @@ +require "cells" +puts "eingiiiiiiine loaded" +module MyEngine + class Engine < ::Rails::Engine + isolate_namespace MyEngine + # This also works + # Cell::Concept.view_paths << File.expand_path("#{MyEngine::Engine.root}/app/concepts", __FILE__) + end +end diff --git a/test/rails4.2/engines/my_engine/lib/my_engine/version.rb b/test/rails4.2/engines/my_engine/lib/my_engine/version.rb new file mode 100644 index 00000000..202fe5e9 --- /dev/null +++ b/test/rails4.2/engines/my_engine/lib/my_engine/version.rb @@ -0,0 +1,3 @@ +module MyEngine + VERSION = "0.0.1" +end diff --git a/test/rails4.2/engines/my_engine/lib/tasks/my_engine_tasks.rake b/test/rails4.2/engines/my_engine/lib/tasks/my_engine_tasks.rake new file mode 100644 index 00000000..df3d5768 --- /dev/null +++ b/test/rails4.2/engines/my_engine/lib/tasks/my_engine_tasks.rake @@ -0,0 +1,4 @@ +# desc "Explaining what the task does" +# task :my_engine do +# # Task goes here +# end diff --git a/test/rails4.2/engines/my_engine/my_engine.gemspec b/test/rails4.2/engines/my_engine/my_engine.gemspec new file mode 100644 index 00000000..b4cb3115 --- /dev/null +++ b/test/rails4.2/engines/my_engine/my_engine.gemspec @@ -0,0 +1,24 @@ +$:.push File.expand_path("../lib", __FILE__) + +# Maintain your gem's version: +require "my_engine/version" + +# Describe your gem and declare its dependencies: +Gem::Specification.new do |s| + s.name = "my_engine" + s.version = MyEngine::VERSION + s.authors = ["Alexander Huber"] + s.email = ["alih83@gmx.de"] + s.homepage = "TODO" + s.summary = "TODO: Summary of MyEngine." + s.description = "TODO: Description of MyEngine." + s.license = "MIT" + + s.files = Dir["{app,config,db,lib}/**/*", "MIT-LICENSE", "Rakefile", "README.rdoc"] + + s.add_dependency "rails", "~> 4.2.1" + s.add_dependency "cells", "4.0.0.beta4" + s.add_dependency "cells-erb" + + s.add_development_dependency "sqlite3" +end diff --git a/test/rails4.2/engines/my_engine/test/fixtures/my_engine/users.yml b/test/rails4.2/engines/my_engine/test/fixtures/my_engine/users.yml new file mode 100644 index 00000000..937a0c00 --- /dev/null +++ b/test/rails4.2/engines/my_engine/test/fixtures/my_engine/users.yml @@ -0,0 +1,11 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +# This model initially had no columns defined. If you add columns to the +# model remove the '{}' from the fixture names and add the columns immediately +# below each fixture, per the syntax in the comments below +# +one: {} +# column: value +# +two: {} +# column: value diff --git a/test/rails4.2/engines/my_engine/test/models/my_engine/user_test.rb b/test/rails4.2/engines/my_engine/test/models/my_engine/user_test.rb new file mode 100644 index 00000000..a913216f --- /dev/null +++ b/test/rails4.2/engines/my_engine/test/models/my_engine/user_test.rb @@ -0,0 +1,9 @@ +require 'test_helper' + +module MyEngine + class UserTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end + end +end diff --git a/test/rails4.2/lib/assets/.keep b/test/rails4.2/lib/assets/.keep new file mode 100644 index 00000000..e69de29b diff --git a/test/rails4.2/lib/tasks/.keep b/test/rails4.2/lib/tasks/.keep new file mode 100644 index 00000000..e69de29b diff --git a/test/rails4.2/log/.keep b/test/rails4.2/log/.keep new file mode 100644 index 00000000..e69de29b diff --git a/test/rails4.2/public/404.html b/test/rails4.2/public/404.html new file mode 100644 index 00000000..b612547f --- /dev/null +++ b/test/rails4.2/public/404.html @@ -0,0 +1,67 @@ + + + + The page you were looking for doesn't exist (404) + + + + + + +
+
+

The page you were looking for doesn't exist.

+

You may have mistyped the address or the page may have moved.

+
+

If you are the application owner check the logs for more information.

+
+ + diff --git a/test/rails4.2/public/422.html b/test/rails4.2/public/422.html new file mode 100644 index 00000000..a21f82b3 --- /dev/null +++ b/test/rails4.2/public/422.html @@ -0,0 +1,67 @@ + + + + The change you wanted was rejected (422) + + + + + + +
+
+

The change you wanted was rejected.

+

Maybe you tried to change something you didn't have access to.

+
+

If you are the application owner check the logs for more information.

+
+ + diff --git a/test/rails4.2/public/500.html b/test/rails4.2/public/500.html new file mode 100644 index 00000000..061abc58 --- /dev/null +++ b/test/rails4.2/public/500.html @@ -0,0 +1,66 @@ + + + + We're sorry, but something went wrong (500) + + + + + + +
+
+

We're sorry, but something went wrong.

+
+

If you are the application owner check the logs for more information.

+
+ + diff --git a/test/rails4.2/public/favicon.ico b/test/rails4.2/public/favicon.ico new file mode 100644 index 00000000..e69de29b diff --git a/test/rails4.2/public/robots.txt b/test/rails4.2/public/robots.txt new file mode 100644 index 00000000..3c9c7c01 --- /dev/null +++ b/test/rails4.2/public/robots.txt @@ -0,0 +1,5 @@ +# See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file +# +# To ban all spiders from the entire site uncomment the next two lines: +# User-agent: * +# Disallow: / diff --git a/test/rails4.2/test/integration/asset_pipeline_test.rb b/test/rails4.2/test/integration/asset_pipeline_test.rb new file mode 100644 index 00000000..73af7fb3 --- /dev/null +++ b/test/rails4.2/test/integration/asset_pipeline_test.rb @@ -0,0 +1,17 @@ +require "test_helper" +require "capybara/rails" +require "capybara/dsl" + +# This blog post helped so much: http://rakeroutes.com/blog/write-a-gem-for-the-rails-asset-pipeline/ +# Thanks, Stephen!!! :) + +class AssetPipelineTest < ActionDispatch::IntegrationTest + include ::Capybara::DSL + + it do + visit "/assets/application.css" + + # both engine User::Cell and SongCell provide assets. + page.text.must_equal "user{background:green}.song{background:red}" + end +end diff --git a/test/rails4.2/test/test_helper.rb b/test/rails4.2/test/test_helper.rb new file mode 100644 index 00000000..d601a7fa --- /dev/null +++ b/test/rails4.2/test/test_helper.rb @@ -0,0 +1,14 @@ +ENV['RAILS_ENV'] ||= 'test' +require File.expand_path('../../config/environment', __FILE__) +require 'rails/test_help' + +Rails.backtrace_cleaner.remove_silencers! + +# MiniTest::Spec.class_eval do +# after :each do +# # DatabaseCleaner.clean +# Thing.delete_all +# Comment.delete_all +# User.delete_all +# end +# end \ No newline at end of file diff --git a/test/rails4.2/vendor/assets/stylesheets/.keep b/test/rails4.2/vendor/assets/stylesheets/.keep new file mode 100644 index 00000000..e69de29b diff --git a/test/render_test.rb b/test/render_test.rb index d757ad55..57d09bb7 100644 --- a/test/render_test.rb +++ b/test/render_test.rb @@ -49,7 +49,7 @@ def title end class RenderTest < MiniTest::Spec - # render show.haml calling method. + # render show.haml calling method, implicit render. it { SongCell.new(nil).show.must_equal "Papertiger\n" } # render ivar.haml using instance variable. @@ -70,7 +70,7 @@ class RenderTest < MiniTest::Spec # throws an exception when not found. it do exception = assert_raises(Cell::TemplateMissingError) { SongCell.new(nil).unknown } - exception.message.must_equal "Template missing: view: `unknown.erb` prefixes: [\"song\"] view_paths:[\"test/fixtures\"]" + exception.message.must_equal "Template missing: view: `unknown.erb` prefixes: [\"test/fixtures/song\"]" end # allows locals diff --git a/test/templates_test.rb b/test/templates_test.rb index d34e6c2e..5f41deee 100644 --- a/test/templates_test.rb +++ b/test/templates_test.rb @@ -4,13 +4,11 @@ class TemplatesTest < MiniTest::Spec Templates = Cell::Templates - let (:base) { ['test/fixtures'] } - # existing. - it { Templates.new[base, ['bassist'], 'play', 'erb'].file.must_equal 'test/fixtures/bassist/play.erb' } + it { Templates.new[['test/fixtures/bassist'], 'play', 'erb'].file.must_equal 'test/fixtures/bassist/play.erb' } # not existing. - it { Templates.new[base, ['bassist'], 'not-here', 'erb'].must_equal nil } + it { Templates.new[['test/fixtures/bassist'], 'not-here', 'erb'].must_equal nil } # different caches for different classes diff --git a/test/test_helper.rb b/test/test_helper.rb index 5876b342..90e9bd06 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -8,12 +8,14 @@ require "rails/test_help" # adds stuff like @routes, etc. require 'cells' +require "cells-erb" MiniTest::Spec.class_eval do include Cell::Testing end class BassistCell < Cell::ViewModel + self.view_paths = ['test/fixtures'] end class MusicianController < ActionController::Base