adva-core 0.0.9 → 0.0.13
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.
- data/app/models/section.rb +0 -6
- data/app/views/admin/sites/index.html.rb +2 -2
- data/config/redirects.rb +2 -1
- data/lib/adva.rb +41 -0
- data/lib/adva/controller/internal_redirect.rb +2 -1
- data/lib/adva/core.rb +8 -0
- data/lib/adva/engine.rb +1 -0
- data/lib/adva/generators/app.rb +7 -8
- data/lib/adva/generators/templates/app/Gemfile +4 -4
- data/lib/adva/generators/templates/app/Thorfile +9 -0
- data/lib/adva/generators/templates/app/app_template.rb +4 -2
- data/lib/adva/generators/templates/engine/Gemfile.erb +15 -0
- data/lib/adva/testing.rb +9 -2
- data/lib/adva/testing/engine.rb +1 -0
- data/lib/adva/view/form.rb +4 -1
- data/lib/adva_core/version.rb +1 -1
- data/lib/bundler/repository.rb +117 -0
- data/lib/patches/inherited_resources.rb +4 -3
- data/lib/patches/rails/integretion_runner_respond_to.rb +1 -1
- data/lib/patches/rails/polymorphic_url_for.rb +3 -1
- data/lib/patches/rails/recognize_path_env.rb +33 -29
- data/lib/patches/rails/route_set_to_param.rb +19 -17
- data/lib/patches/rails/route_set_trailing_segment.rb +1 -1
- data/lib/patches/rails/sti_associations.rb +10 -4
- data/lib/patches/rails/translation_helper.rb +2 -1
- data/lib/patches/responders/flash_responder.rb +1 -0
- data/lib/patches/simple_form.rb +2 -2
- data/lib/testing/env.rb +19 -13
- data/lib/testing/factories.rb +5 -1
- data/lib/testing/paths.rb +4 -4
- data/lib/testing/selectors.rb +72 -0
- data/lib/testing/step_definitions/capybara_steps.rb +211 -0
- data/lib/testing/step_definitions/common_steps.rb +87 -98
- data/lib/testing/step_definitions/debug_steps.rb +11 -4
- data/lib/testing/step_definitions/email_steps.rb +195 -0
- data/lib/testing/step_definitions/menu_steps.rb +7 -2
- data/lib/testing/step_definitions/more_web_steps.rb +4 -0
- data/lib/testing/step_definitions/pickle_steps.rb +104 -0
- data/lib/testing/step_definitions/transforms.rb +10 -1
- data/lib/testing/support/pickle.rb +24 -0
- data/public/javascripts/adva-core/jquery/jquery.table_tree.js +5 -1
- metadata +340 -305
- data/lib/patches/rails/asset_expansion_multiple_registrations.rb +0 -21
- data/lib/patches/rails/template_resolver_caching.rb +0 -9
- data/lib/patches/webrat/links-data-method.rb +0 -15
- data/lib/patches/webrat/logger.rb +0 -14
- data/lib/patches/webrat/upload_file.rb +0 -23
- data/lib/patches/webrat/within_xpath.rb +0 -13
- data/lib/testing/step_definitions/webrat_steps.rb +0 -284
- data/lib/testing/step_definitions/within_steps.rb +0 -16
    
        data/app/models/section.rb
    CHANGED
    
    
| @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            class Admin::Sites::Index < Minimal::Template
         | 
| 2 2 | 
             
              include do
         | 
| 3 3 | 
             
                def to_html
         | 
| 4 | 
            -
                	table_for collection do |t|
         | 
| 4 | 
            +
                	table_for collection.all do |t|
         | 
| 5 5 | 
             
                		t.column :site
         | 
| 6 6 | 
             
                		t.column :actions, :class => :actions
         | 
| 7 7 |  | 
| 8 8 | 
             
                		t.row do |r, site|
         | 
| 9 9 | 
             
                			r.cell link_to_site(site)
         | 
| 10 10 | 
             
                      r.cell links_to_actions([:view, :edit, :destroy], site)
         | 
| 11 | 
            -
                		end unless collection. | 
| 11 | 
            +
                		end unless collection.count == 0
         | 
| 12 12 | 
             
                	end
         | 
| 13 13 | 
             
                end
         | 
| 14 14 |  | 
    
        data/config/redirects.rb
    CHANGED
    
    | @@ -4,5 +4,6 @@ Adva::Registry.set :redirect, { | |
| 4 4 |  | 
| 5 5 | 
             
              'admin/sites#update'    => lambda { |c| c.edit_url        },
         | 
| 6 6 | 
             
              'admin/pages#update'    => lambda { |c| c.show_url        },
         | 
| 7 | 
            -
              'admin/pages#destroy'   => lambda { |c| c.index_url       }
         | 
| 7 | 
            +
              'admin/pages#destroy'   => lambda { |c| c.index_url       },
         | 
| 8 | 
            +
              'admin/sections#destroy' => lambda { |c| c.index_url      }
         | 
| 8 9 | 
             
            }
         | 
    
        data/lib/adva.rb
    CHANGED
    
    | @@ -34,6 +34,47 @@ module Adva | |
| 34 34 | 
             
                  engine_names.include?(name)
         | 
| 35 35 | 
             
                end
         | 
| 36 36 | 
             
                alias :installed? :engine?
         | 
| 37 | 
            +
             | 
| 38 | 
            +
                # Helps you slice and dice your addons to adva-cms
         | 
| 39 | 
            +
                #
         | 
| 40 | 
            +
                # load and slice (patch) the class +Existing::Stuff+
         | 
| 41 | 
            +
                # in 'ur/engine/existing/stuff_slice.rb' 
         | 
| 42 | 
            +
                # Adva.slice 'existing/stuff' do
         | 
| 43 | 
            +
                #   include do
         | 
| 44 | 
            +
                #     def fn0rd
         | 
| 45 | 
            +
                #       23 + 42
         | 
| 46 | 
            +
                #     end
         | 
| 47 | 
            +
                #   end
         | 
| 48 | 
            +
                #   attr_accessor :things
         | 
| 49 | 
            +
                # end
         | 
| 50 | 
            +
                def slice(path_with_namespace, &block)
         | 
| 51 | 
            +
                  raise ArgumentError, 'must give block to slice and dice' unless block_given?
         | 
| 52 | 
            +
                  if path_with_namespace =~ /^([^#]+)#([^#]+)$/
         | 
| 53 | 
            +
                    path, namespace = $1, $2
         | 
| 54 | 
            +
                  else
         | 
| 55 | 
            +
                    raise ArgumentError, "first argument must be class_to_slice#your_slice_identifier"
         | 
| 56 | 
            +
                  end
         | 
| 57 | 
            +
                  unless loaded_slices.include?(path_with_namespace)
         | 
| 58 | 
            +
                    class_name = path.sub(/\.\w+$/,'').pluralize.classify # cut out extension for minimal templates
         | 
| 59 | 
            +
                    begin
         | 
| 60 | 
            +
                      class_name.constantize.class_eval(&block)
         | 
| 61 | 
            +
                    rescue NameError => e
         | 
| 62 | 
            +
                      if e.message.include?(class_name)
         | 
| 63 | 
            +
                        require_dependency(path)
         | 
| 64 | 
            +
                      else
         | 
| 65 | 
            +
                        raise e
         | 
| 66 | 
            +
                      end
         | 
| 67 | 
            +
                    ensure
         | 
| 68 | 
            +
                      loaded_slices << path_with_namespace
         | 
| 69 | 
            +
                    end
         | 
| 70 | 
            +
                  else
         | 
| 71 | 
            +
                    Rails.logger.debug { "Adva.slice: already loaded #{path_with_namespace}, skipping" }
         | 
| 72 | 
            +
                  end
         | 
| 73 | 
            +
                end
         | 
| 74 | 
            +
             | 
| 75 | 
            +
                def loaded_slices
         | 
| 76 | 
            +
                  @loaded_slices ||= Set.new
         | 
| 77 | 
            +
                end
         | 
| 37 78 | 
             
              end
         | 
| 38 79 | 
             
            end
         | 
| 39 80 |  | 
| @@ -13,6 +13,7 @@ module Adva | |
| 13 13 | 
             
                    params = yield(params) if block_given?
         | 
| 14 14 |  | 
| 15 15 | 
             
                    rack_endpoint = "#{controller}_controller".classify.constantize.action(action)
         | 
| 16 | 
            +
                    Rails.logger.debug { "redirecting internally to #{controller}##{action}" }
         | 
| 16 17 | 
             
                    env['action_dispatch.request.parameters'] = params
         | 
| 17 18 | 
             
                    response = rack_endpoint.call(env)
         | 
| 18 19 |  | 
| @@ -23,4 +24,4 @@ module Adva | |
| 23 24 | 
             
                  end
         | 
| 24 25 | 
             
                end
         | 
| 25 26 | 
             
              end
         | 
| 26 | 
            -
            end
         | 
| 27 | 
            +
            end
         | 
    
        data/lib/adva/core.rb
    CHANGED
    
    
    
        data/lib/adva/engine.rb
    CHANGED
    
    
    
        data/lib/adva/generators/app.rb
    CHANGED
    
    | @@ -11,7 +11,7 @@ module Adva | |
| 11 11 | 
             
              module Generators
         | 
| 12 12 | 
             
                class App
         | 
| 13 13 | 
             
                  DEFAULT_OPTIONS = {
         | 
| 14 | 
            -
                    : | 
| 14 | 
            +
                    :core_dir  => File.expand_path('../../../..', __FILE__),
         | 
| 15 15 | 
             
                    :target    => File.expand_path('.'),
         | 
| 16 16 | 
             
                    :template  => File.expand_path('../templates/app/app_template.rb', __FILE__),
         | 
| 17 17 | 
             
                    :engines   => [:all],
         | 
| @@ -21,13 +21,13 @@ module Adva | |
| 21 21 | 
             
                    :force     => false
         | 
| 22 22 | 
             
                  }
         | 
| 23 23 |  | 
| 24 | 
            -
                  def initialize(name, options = {} | 
| 24 | 
            +
                  def initialize(name, options = {})
         | 
| 25 25 | 
             
                    @options = options.reverse_merge!(DEFAULT_OPTIONS)
         | 
| 26 | 
            -
                    @name    = name || File.basename( | 
| 27 | 
            -
                    raise ArgumentError, "#{ | 
| 26 | 
            +
                    @name    = name || File.basename( File.expand_path('../', core_dir) )
         | 
| 27 | 
            +
                    raise ArgumentError, "#{core_dir.inspect} is not a directory" unless File.directory?(core_dir)
         | 
| 28 28 | 
             
                  end
         | 
| 29 29 |  | 
| 30 | 
            -
                  def invoke
         | 
| 30 | 
            +
                  def invoke(&block)
         | 
| 31 31 | 
             
                    if force? || build?
         | 
| 32 32 | 
             
                      build
         | 
| 33 33 | 
             
                      generate_resources  if generate_resources?
         | 
| @@ -44,7 +44,7 @@ module Adva | |
| 44 44 | 
             
                  protected
         | 
| 45 45 |  | 
| 46 46 | 
             
                    attr_reader :name
         | 
| 47 | 
            -
                    option_reader : | 
| 47 | 
            +
                    option_reader :core_dir, :target, :template, :engines, :resources, :migrate, :bundle, :force
         | 
| 48 48 |  | 
| 49 49 | 
             
                    def root
         | 
| 50 50 | 
             
                      "#{target}/#{name}"
         | 
| @@ -57,8 +57,7 @@ module Adva | |
| 57 57 | 
             
                        options = force? || ENV.key?('REGENERATE_APP') ? ['-f'] : []
         | 
| 58 58 | 
             
                        generator = Rails::Generators::AppGenerator.new([root], options, :shell => shell)
         | 
| 59 59 | 
             
                        generator.invoke_all
         | 
| 60 | 
            -
                        generator.apply(template, : | 
| 61 | 
            -
                        FileUtils.cp("#{source}/Thorfile", "#{root}/Thorfile")
         | 
| 60 | 
            +
                        generator.apply(template, :adva_core => Pathname.new(core_dir))
         | 
| 62 61 | 
             
                      end
         | 
| 63 62 | 
             
                    end
         | 
| 64 63 |  | 
| @@ -10,15 +10,15 @@ gem  'adva-markup' | |
| 10 10 |  | 
| 11 11 | 
             
            group :test do
         | 
| 12 12 | 
             
              gem 'sqlite3-ruby', '1.2.5'
         | 
| 13 | 
            -
              gem  | 
| 14 | 
            -
              gem 'cucumber | 
| 15 | 
            -
              gem ' | 
| 13 | 
            +
              gem "capybara", ">= 0.4.1.1"
         | 
| 14 | 
            +
              gem 'cucumber', '~> 0.10.2'
         | 
| 15 | 
            +
              gem 'cucumber-rails', '~> 0.4.1'
         | 
| 16 16 | 
             
              gem 'thor'
         | 
| 17 17 | 
             
              gem 'ruby-debug'
         | 
| 18 18 | 
             
              gem 'mocha'
         | 
| 19 19 | 
             
              gem 'fakefs', :require => 'fakefs/safe'
         | 
| 20 20 | 
             
              gem 'test_declarative'
         | 
| 21 | 
            -
              gem 'database_cleaner', '0. | 
| 21 | 
            +
              gem 'database_cleaner', ' ~> 0.6.7'
         | 
| 22 22 | 
             
              gem 'launchy'
         | 
| 23 23 | 
             
              gem 'factory_girl', '1.3.2'
         | 
| 24 24 | 
             
            end
         | 
| @@ -1,3 +1,5 @@ | |
| 1 | 
            -
            copy_file config[: | 
| 2 | 
            -
            copy_file config[: | 
| 1 | 
            +
            copy_file config[:adva_core].join('lib/bundler/repository.rb'), "#{app_path}/lib/bundler/repository.rb"
         | 
| 2 | 
            +
            copy_file config[:adva_core].join('lib/adva/generators/templates/app/Thorfile'), "#{app_path}/Thorfile"
         | 
| 3 | 
            +
            remove_file 'Gemfile' # we do not want to confirm overwriting the Gemfile
         | 
| 4 | 
            +
            copy_file config[:adva_core].join('lib/adva/generators/templates/app/Gemfile'), "#{app_path}/Gemfile"
         | 
| 3 5 | 
             
            remove_file 'public/index.html'
         | 
| @@ -1,3 +1,18 @@ | |
| 1 1 | 
             
            source :rubygems
         | 
| 2 2 |  | 
| 3 3 | 
             
            gemspec
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            group :test do
         | 
| 6 | 
            +
              gem 'sqlite3-ruby', '1.2.5'
         | 
| 7 | 
            +
              gem "capybara", ">= 0.4.1.1"
         | 
| 8 | 
            +
              gem 'cucumber', '~> 0.10.2'
         | 
| 9 | 
            +
              gem 'cucumber-rails', '~> 0.4.1'
         | 
| 10 | 
            +
              gem 'thor'
         | 
| 11 | 
            +
              gem 'ruby-debug'
         | 
| 12 | 
            +
              gem 'mocha'
         | 
| 13 | 
            +
              gem 'fakefs', :require => 'fakefs/safe'
         | 
| 14 | 
            +
              gem 'test_declarative'
         | 
| 15 | 
            +
              gem 'database_cleaner', ' ~> 0.6.7'
         | 
| 16 | 
            +
              gem 'launchy'
         | 
| 17 | 
            +
              gem 'factory_girl', '1.3.2'
         | 
| 18 | 
            +
            end
         | 
    
        data/lib/adva/testing.rb
    CHANGED
    
    | @@ -6,6 +6,10 @@ module Adva | |
| 6 6 |  | 
| 7 7 | 
             
                class << self
         | 
| 8 8 | 
             
                  def setup(options = {})
         | 
| 9 | 
            +
                    options = {
         | 
| 10 | 
            +
                      :migrate => true
         | 
| 11 | 
            +
                    }.merge(options)
         | 
| 12 | 
            +
             | 
| 9 13 | 
             
                    Adva.out = StringIO.new('')
         | 
| 10 14 | 
             
                    setup_logging(options)
         | 
| 11 15 | 
             
                    setup_active_record
         | 
| @@ -14,7 +18,10 @@ module Adva | |
| 14 18 | 
             
                    ActiveSupport::Slices.register
         | 
| 15 19 |  | 
| 16 20 | 
             
                    each_engine { |e| e.new.require_patches }
         | 
| 17 | 
            -
             | 
| 21 | 
            +
             | 
| 22 | 
            +
                    if options[:migrate]
         | 
| 23 | 
            +
                      each_engine { |e| e.migrate }
         | 
| 24 | 
            +
                    end
         | 
| 18 25 |  | 
| 19 26 | 
             
                    load_assertions
         | 
| 20 27 | 
             
                    load_factories
         | 
| @@ -43,7 +50,7 @@ module Adva | |
| 43 50 | 
             
                  def setup_logging(options)
         | 
| 44 51 | 
             
                    if log = options[:log]
         | 
| 45 52 | 
             
                      FileUtils.touch(log) unless File.exists?(log)
         | 
| 46 | 
            -
                       | 
| 53 | 
            +
                      Rails.logger = Logger.new(log)
         | 
| 47 54 | 
             
                      ActiveRecord::LogSubscriber.attach_to(:active_record)
         | 
| 48 55 | 
             
                    end
         | 
| 49 56 | 
             
                  end
         | 
    
        data/lib/adva/testing/engine.rb
    CHANGED
    
    
    
        data/lib/adva/view/form.rb
    CHANGED
    
    
    
        data/lib/adva_core/version.rb
    CHANGED
    
    
| @@ -0,0 +1,117 @@ | |
| 1 | 
            +
            require 'pathname'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            # Bundler gemfile support for local/remote workspaces/repositories for work in
         | 
| 4 | 
            +
            # development teams.
         | 
| 5 | 
            +
            #
         | 
| 6 | 
            +
            # Usage:
         | 
| 7 | 
            +
            #
         | 
| 8 | 
            +
            #   # define paths to be searched for repositories:
         | 
| 9 | 
            +
            #   workspace '~/.projects ~/Development/{projects,work}'
         | 
| 10 | 
            +
            #
         | 
| 11 | 
            +
            #   # define developer preferences for using local or remote repositories (uses ENV['user']):
         | 
| 12 | 
            +
            #   developer :sven, :prefer => :local
         | 
| 13 | 
            +
            #
         | 
| 14 | 
            +
            #   # define repositories to be used for particular gems:
         | 
| 15 | 
            +
            #   adva_cms  = repository('adva-cms2', :git => 'git@github.com:svenfuchs/adva-cms2.git', :ref => 'c2af0de')
         | 
| 16 | 
            +
            #   adva_shop = repository('adva-shop', :source => :local)
         | 
| 17 | 
            +
            #
         | 
| 18 | 
            +
            #   # now use repositories to define gems:
         | 
| 19 | 
            +
            #   adva_cms.gem  'adva-core'
         | 
| 20 | 
            +
            #   adva_shop.gem 'adva-catalog'
         | 
| 21 | 
            +
            #
         | 
| 22 | 
            +
            #   # The gem definition will now be proxied to Bundler with arguments according
         | 
| 23 | 
            +
            #   # to the setup defined earlier. E.g. as:
         | 
| 24 | 
            +
            #
         | 
| 25 | 
            +
            #   gem 'adva-core', :path => 'Development/projects/adva-cms2'                           # for developer 'sven'
         | 
| 26 | 
            +
            #   gem 'adva-core', :git => 'git@github.com:svenfuchs/adva-cms2.git', :ref => 'c2af0de' # for other developers
         | 
| 27 | 
            +
            #   gem 'adva-catalog', :path => 'Development/projects/adva-shop'                        # for all developers
         | 
| 28 | 
            +
            #
         | 
| 29 | 
            +
            #  One can also set an environment variable FORCE_REMOTE which will force remote
         | 
| 30 | 
            +
            #  repositories to be used *except* when a repository was defined with :source => :local
         | 
| 31 | 
            +
            #  which always forces the local repository to be used.
         | 
| 32 | 
            +
            #
         | 
| 33 | 
            +
            class Repository
         | 
| 34 | 
            +
              class << self
         | 
| 35 | 
            +
                def paths
         | 
| 36 | 
            +
                  @paths ||= []
         | 
| 37 | 
            +
                end
         | 
| 38 | 
            +
             | 
| 39 | 
            +
                def path(*paths)
         | 
| 40 | 
            +
                  paths.join(' ').split(' ').each do |path|
         | 
| 41 | 
            +
                    self.paths.concat(Pathname.glob(File.expand_path(path)))
         | 
| 42 | 
            +
                  end
         | 
| 43 | 
            +
                end
         | 
| 44 | 
            +
             | 
| 45 | 
            +
                def developer(name, preferences)
         | 
| 46 | 
            +
                  developers[name] = preferences
         | 
| 47 | 
            +
                  workspaces(preferences[:workspace])
         | 
| 48 | 
            +
                end
         | 
| 49 | 
            +
             | 
| 50 | 
            +
                def current_developer
         | 
| 51 | 
            +
                  developers[ENV['USER'].to_sym] || {}
         | 
| 52 | 
            +
                end
         | 
| 53 | 
            +
             | 
| 54 | 
            +
                def developers(developers = nil)
         | 
| 55 | 
            +
                  @developers ||= {}
         | 
| 56 | 
            +
                end
         | 
| 57 | 
            +
              end
         | 
| 58 | 
            +
             | 
| 59 | 
            +
              class Gem < Array
         | 
| 60 | 
            +
                def initialize(name, repository)
         | 
| 61 | 
            +
                  if repository.local?
         | 
| 62 | 
            +
                    super([name, { :path => repository.path.to_s }])
         | 
| 63 | 
            +
                  else
         | 
| 64 | 
            +
                    super([name, repository.options.dup])
         | 
| 65 | 
            +
                  end
         | 
| 66 | 
            +
                end
         | 
| 67 | 
            +
              end
         | 
| 68 | 
            +
             | 
| 69 | 
            +
              attr_reader :bundler, :name, :options, :source
         | 
| 70 | 
            +
             | 
| 71 | 
            +
              def initialize(bundler, name, options)
         | 
| 72 | 
            +
                @bundler = bundler
         | 
| 73 | 
            +
                @name    = name
         | 
| 74 | 
            +
                @source  = options.delete(:source)
         | 
| 75 | 
            +
                @options = options
         | 
| 76 | 
            +
              end
         | 
| 77 | 
            +
             | 
| 78 | 
            +
              def gem(name)
         | 
| 79 | 
            +
                bundler.gem(*Gem.new(name, self))
         | 
| 80 | 
            +
              end
         | 
| 81 | 
            +
             | 
| 82 | 
            +
              def local?
         | 
| 83 | 
            +
                source == :local # && path
         | 
| 84 | 
            +
              end
         | 
| 85 | 
            +
             | 
| 86 | 
            +
              def source
         | 
| 87 | 
            +
                @source ||= forced_source || preferred_source || :remote
         | 
| 88 | 
            +
              end
         | 
| 89 | 
            +
             | 
| 90 | 
            +
              def forced_source
         | 
| 91 | 
            +
                :remote if ENV['FORCE_REMOTE']
         | 
| 92 | 
            +
              end
         | 
| 93 | 
            +
             | 
| 94 | 
            +
              def preferred_source
         | 
| 95 | 
            +
                self.class.current_developer[:prefer] || self.class.current_developer[name.to_sym]
         | 
| 96 | 
            +
              end
         | 
| 97 | 
            +
             | 
| 98 | 
            +
              def path
         | 
| 99 | 
            +
                @path ||= begin
         | 
| 100 | 
            +
                  path = self.class.paths.detect { |path| path.join(name).exist? }
         | 
| 101 | 
            +
                  path ? path.join(name) : Pathname.new('.')
         | 
| 102 | 
            +
                end
         | 
| 103 | 
            +
              end
         | 
| 104 | 
            +
            end
         | 
| 105 | 
            +
             | 
| 106 | 
            +
            def workspace(*paths)
         | 
| 107 | 
            +
              Repository.path(*paths)
         | 
| 108 | 
            +
            end
         | 
| 109 | 
            +
            alias :workspaces :workspace
         | 
| 110 | 
            +
             | 
| 111 | 
            +
            def developer(name, preferences)
         | 
| 112 | 
            +
              Repository.developer(name, preferences)
         | 
| 113 | 
            +
            end
         | 
| 114 | 
            +
             | 
| 115 | 
            +
            def repository(*args)
         | 
| 116 | 
            +
              Repository.new(self, *args)
         | 
| 117 | 
            +
            end
         | 
| @@ -1,7 +1,9 @@ | |
| 1 1 | 
             
            require 'gem-patching'
         | 
| 2 2 | 
             
            require 'inherited_resources'
         | 
| 3 3 |  | 
| 4 | 
            -
             | 
| 4 | 
            +
            # FIXME is any of this still neccessary?
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            Gem.patching('inherited_resources', '1.2.2') do
         | 
| 5 7 | 
             
              InheritedResources::Actions.module_eval do
         | 
| 6 8 | 
             
                module Actions
         | 
| 7 9 | 
             
                  def index(options={}, &block)
         | 
| @@ -15,14 +17,13 @@ Gem.patching('inherited_resources', '1.1.2') do | |
| 15 17 | 
             
                def collection
         | 
| 16 18 | 
             
                  get_collection_ivar || begin
         | 
| 17 19 | 
             
                    collection = end_of_association_chain
         | 
| 18 | 
            -
                    collection = collection.find(:all) unless collection.respond_to?(:each)
         | 
| 19 20 | 
             
                    set_collection_ivar(collection)
         | 
| 20 21 | 
             
                  end
         | 
| 21 22 | 
             
                end
         | 
| 22 23 |  | 
| 23 24 | 
             
                def build_resource
         | 
| 24 25 | 
             
                  get_resource_ivar || begin
         | 
| 25 | 
            -
                    resource = end_of_association_chain.send(method_for_build,  | 
| 26 | 
            +
                    resource = end_of_association_chain.send(method_for_build, resource_params)
         | 
| 26 27 | 
             
                    # check if resource is included to prevent deleting from a relation
         | 
| 27 28 | 
             
                    if method_for_build == :build && end_of_association_chain.include?(resource)
         | 
| 28 29 | 
             
                      end_of_association_chain.delete(resource)
         | 
| @@ -4,7 +4,7 @@ require 'gem-patching' | |
| 4 4 | 
             
            # respond_to? method. It thus doesn't respond_to? to named route url helpers even
         | 
| 5 5 | 
             
            # though it actually responds to them. Happens with the PolymorphicRoutes patch
         | 
| 6 6 | 
             
            # above, so this patch is here as well.
         | 
| 7 | 
            -
            Gem.patching('rails', '3.0. | 
| 7 | 
            +
            Gem.patching('rails', '3.0.9') do
         | 
| 8 8 | 
             
              ActionDispatch::Integration::Runner.module_eval do
         | 
| 9 9 | 
             
                def respond_to?(method, include_private = false)
         | 
| 10 10 | 
             
                  @integration_session.respond_to?(method, include_private) || super
         | 
| @@ -1,7 +1,9 @@ | |
| 1 1 | 
             
            # Walks up the inheritance chain for given records if the generated named route
         | 
| 2 2 | 
             
            # helper does not exist. Caches resulting method names.
         | 
| 3 3 | 
             
            # see https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/2986-polymorphic_url-should-handle-sti-better
         | 
| 4 | 
            -
             | 
| 4 | 
            +
            #
         | 
| 5 | 
            +
            # FIXME: this should not blindly overwrite ActionDispatch::Routing::PolymorphicRoutes.build_named_route_call
         | 
| 6 | 
            +
            Gem.patching('rails', '3.0.9') do
         | 
| 5 7 | 
             
              require 'action_dispatch/routing/polymorphic_routes'
         | 
| 6 8 |  | 
| 7 9 | 
             
              ActionDispatch::Routing::PolymorphicRoutes.module_eval do
         |