Permalink
Commits on May 15, 2017
  1. Update travis configuration (#807)

    * Update travis configuration for container based builds.
    
    See: https://docs.travis-ci.com/user/trusty-ci-environment#Container-based-with-sudo%3A-false
    
    * Enable caching at travis.
    
    See: https://docs.travis-ci.com/user/caching#Bundler
    biow0lf committed with codebycliff May 15, 2017
Commits on May 9, 2017
  1. Travis CI changes (#805)

    * Add ruby-head to travis. Allow failures on ruby-head.
    
    * Update ruby 2.2.6 to 2.2.7 for travis
    
    * Update ruby 2.3.3 to 2.3.4 for travis
    biow0lf committed with codebycliff May 9, 2017
Commits on May 8, 2017
  1. Release 3.0.0 (#780)

    * Release 3.0.0
    
    * Add breaking change #768 to changelog.
    
    * Add recently merged changes to the changelog.
    
    * Add configuration and custom default controller to the changelog.
    
    * Add entry to changelog for pull request 720
    
    * Add entry to changelog for Rails 5 API-only support.
    
    * Add changelog entry for pull request #795.
    
    * Add changelog entry for pull request #796.
    
    * Add changelog entry for enumerable optimization.
    
    * Update maintainer information in README.
    
    * Add pull request #799 to changelog.
    
    * Add compatability documentation to readme.
    codebycliff committed on GitHub May 8, 2017
  2. Replace hash rockets with new syntax (#802)

    * update rocket hash syntax in Guardfile
    
    * update rocket hash syntax in spec/dummy/lib/tasks/test.rake
    
    * update rocket hash syntax in lib/draper/tasks/test.rake
    
    * update rocket hash syntax in lib/generators/mini_test/decorator_generator.rb
    
    * update rocket hash syntax in schema from dummy app
    DmytroStepaniuk committed with codebycliff May 8, 2017
  3. Clean view context when controller changes (#799)

    When we reassign controller it is the right thing to do to clear current
    view context stored in request store. Consider a case when view context
    was built before the request was made (usage of `h` helper in class level
    context). View context is built from default controller and has no
    information about the request. During first request
    `Draper::ViewContext.current.controller` will be different than
    `Draper::ViewContext.controller`.
    barthez committed with codebycliff May 8, 2017
Commits on May 5, 2017
  1. Revert "Optimization: Optimize CollectionDecorator Enumerable behavior (

    #707)" (#801)
    
    This reverts commit f6a7b17.
    codebycliff committed on GitHub May 5, 2017
  2. Fix failing specs re Rails 5.1 (#800)

    * Fix failing specs re Rails 5.1
    
    Because there is no hard constraint on Rails version, tests run against
    the newest version available. Rails 5.1 removes `to_h` from unpermitted
    parameters class. Using `empty?` is sufficient replacement.
    
    * Fix Dummy app `posts#mail` action rendering
    
    Rails 5.1 does not accept `:text` key for `render`.
    barthez committed with codebycliff May 5, 2017
Commits on Apr 12, 2017
  1. Optimization: Optimize CollectionDecorator Enumerable behavior (#707)

    * Optimization: Prevent duplicate iteration
    
    * Don't delegate Enumerable instance methods since CollectionDecorator includes Enumerable itself
    clemens committed with codebycliff Apr 12, 2017
Commits on Apr 5, 2017
  1. ApplicationDecorator generator (#796)

    * un-skip test and remove unused class definition
    
    * fix build
    
    * add InstallGenerator
    
    * re-namespace generators
    
    * remove module namespacing
    
    * update README with new generator command
    
    * inherit from Base instead of NamedBase
    
    * add inheritance line to Generators section of README
    
    * call #copy_file instead of #template
    
    * remove skip functionality
    
    * refactor once-used variable
    
    * specify application_decorator.rb file instead of class
    
    * move decorator generator back to rails namespace
    
    * revert README change
    
    * specify decorator class
    
    * re-word template help text
    
    * remove unnecessary describe block
    
    * remove delegate_all from application_decorator template
    
    * edit README
    chuck-john committed with codebycliff Apr 5, 2017
Commits on Apr 4, 2017
  1. Never re-raise NameError and always default to CollectionDecorator (#795

    )
    
    * minor fix to error raising on collection decoration.
    
    * Don't re-raise NameError in collection_decorator_class.
    
    * Add more tests.
    codebycliff committed on GitHub Apr 4, 2017
Commits on Apr 3, 2017
  1. Add rubocop development dependency and code climate configuration. (#794

    )
    
    * Add rubocop development dependency and code climate configuration.
    
    * Add some rubocop configuration.
    
    * Remove some configuration.
    codebycliff committed on GitHub Apr 3, 2017
  2. Don't do runtime delegation, delegate explicitly (#789)

    * Don't do runtime delegation, delegate explicitly
    
    If someone accidentally calls `super` instead of `object` inside a decorator,
    all hell breaks loose.
    
    ```rb
    class Post < ActiveRecord::Base
      def title
        "title"
      end
    end
    
    class PostDecorator < Draper::Decorator
      delegate_all
    
      def title
        super and "overriden title"
      end
    end
    
    post = PostDecorator.new(Post.new)
    post.title #=> "overriden title"
    post.title #=> "title"
    ```
    
    This patch makes both `super` and `object` work. I'm not sure why
    runtime delegation was added in the first place, but it seems very wrong
    to add methods on the fly.
    
    * Add documentation and more tests.
    
    * Consistent line spacing in test.
    codebycliff committed on GitHub Apr 3, 2017
Commits on Mar 31, 2017
  1. un-skip test and remove unused class definition (#792)

    * un-skip test and remove unused class definition
    
    * fix build
    chuck-john committed with codebycliff Mar 31, 2017
  2. Only Draper::Decorator types should delegate === to object. (#720)

    Draper::Decorater provides the object method and we should delegate === to this
    method only for these types.
    
    Other classes could respond_to?(:object) so using is_a? clarifies not just any
    class implementing object but only classes that are a Draper::Decorator.
    
    Besides this, another major reason is is_a? is much faster than respond_to?
    in ActiveRecord models because of the number of methods AR provides and the
    layers of delegation. There is a cache specifically for respond_to? [1] because
    it's so slow.
    
    Even with this cache, some of our pages are 10% faster by using the is_a? change
    from this patch.
    
    The original implementation [2] used the method source, which was later renamed
    to object.  The tests seem to indicate the intention was to always have
    this === delegation to source/object for decorated objects... which is what
    Drapper::Decorator types are.
    
    Test changes:
    * verify decorated instances of Product and instances derived from
    decorated instances of Product are === Product.
    * verify unrelated decorated instances and non-decorators that
    happen to implement object are not === Product.
    
    [1] https://github.com/rails/rails/blob/4-2-stable/activemodel/lib/active_model/attribute_methods.rb#L343-L351
    [2] ca11615
    jrafanie committed with codebycliff Mar 31, 2017
  3. Fix the indeterminate test issue. (#791)

    The issue was due to a couple describe blocks
    not matching the definition in .
    Since their name didn't match,
    wasn't getting included in the minitest-specs. Since the
    teardown didn't exist, the view context leaked to the
    next tests to be ran.
    codebycliff committed on GitHub Mar 31, 2017
  4. GitHub pull request template (#790)

    * add GH PR template
    
    * add PR link reference
    chuck-john committed with codebycliff Mar 31, 2017
  5. Add support for custom default controller configuration (#788)

    * Add configure functionality to allow customizing the default.
    
    * Add configuration module and tests.
    
    * Add documentation to the README.md
    
    * Skip tests that only fail when whole suite is ran.
    
    * Fix the double leaking by re-writing the test that caused the issue.
    
    * Clean up railtie - Exract out method, Remove unnecessary compatibility.
    
    * Add new functionality to the dummy app to increase test coverage.
    codebycliff committed on GitHub Mar 31, 2017
Commits on Mar 29, 2017
  1. Also initialize ViewContext for rails runner (#739)

    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.
    graaff committed with codebycliff Mar 29, 2017
  2. Issue 725: Remove conflicting source alias (#786)

    * Remove source, to_source, source_class and source_class? aliases.
    
    * Remove UninferrableSourceError alias.
    codebycliff committed on GitHub Mar 29, 2017
Commits on Mar 28, 2017
  1. Rename UninferrableSourceError to UninferrableObjectError (#768)

    Since source has been renamed to object, it is better for consistency to have UninferrableObjectError
    class name with the error message mentioning 'object' property instead of 'source'.
    ertrzyiks committed with codebycliff Mar 28, 2017
  2. Update ruby versions (#782)

    syguer committed with codebycliff Mar 28, 2017
Commits on Feb 27, 2017
  1. Merge pull request #779 from deivid-rodriguez/warnings

    Fix warnings with recent versions of `thor`
    seanlinsley committed on GitHub Feb 27, 2017
  2. Merge pull request #778 from deivid-rodriguez/generator_fixes

    Reenable generator tests
    seanlinsley committed on GitHub Feb 27, 2017
Commits on Feb 25, 2017
  1. Fix warnings with recent thor versions

    Otherwise running things like `bin/rails g --help` with `draper`
    installed leads to warnings like this:
    
    ```
    Expected string default value for '--decorator'; got true (boolean)
    ```
    
    See erikhuda/thor#538 for reference.
    deivid-rodriguez committed Feb 25, 2017
Commits on Feb 23, 2017
  1. Fix mock error by following error instructions

    Fixes the following error:
    
    ```
    [WARNING] Could not load generator
    "generators/test_unit/decorator_generator". Error: Rails::Generators
    received :require with unexpected arguments
      expected: ("application_decorator")
           got: ("generators/test_unit/decorator_generator")
     Please stub a default value first if message might be received with
    other args as well
    ```
    deivid-rodriguez committed Feb 23, 2017
  2. Renable generator tests

    deivid-rodriguez committed Feb 23, 2017
Commits on Feb 21, 2017
  1. Merge pull request #763 from McRip/feature-view_context

    Bugfix for missing ActionController::TestRequest
    seanlinsley committed on GitHub Feb 21, 2017
Commits on Jan 16, 2017
  1. Bugfix for missing ActionController::TestRequest

    Fixed a bug where helpers were used inside a decorator and this decorator was used outside of controller context
    McRip committed Oct 31, 2016