Commit Graph

1589 Commits

Author SHA1 Message Date
Benjamin Fleischer
ec1022ecb3 Test bugfix 2017-01-10 00:41:09 -06:00
Benjamin Fleischer
b5f886cb95 Randomize testing of compatibility layer against regressions 2017-01-10 00:41:09 -06:00
Benjamin Fleischer
ec905d8179 Fix typos 2017-01-10 00:41:08 -06:00
Benjamin Fleischer
c25f2f3863 Fix model attributes accessors 2017-01-10 00:41:08 -06:00
Benjamin Fleischer
2a6d373cb2 Merge pull request #1981 from groyoh/link_doc
Fix relationship links doc
2017-01-09 23:57:37 -06:00
Benjamin Fleischer
4e6bd61350 Merge pull request #2021 from bf4/make_tests_explicit
Add Model#attributes helper; make test attributes explicit
2017-01-08 16:37:53 -05:00
Benjamin Fleischer
d5babdd060 Add Model#attributes helper; make test attributes explicit 2017-01-07 21:50:11 -06:00
Benjamin Fleischer
85dfef9072 Merge pull request #2012 from bf4/cleanup_isolated_jsonapi_renderer_tests_a_bit
Cleanup assertions in isolated jsonapi renderer tests a bit
2017-01-07 16:31:45 -06:00
Ankit Shah
59aed4d00e Updated isolated tests to assert correct behavior. (#2010)
* Updated isolated tests to assert correct behavior.
* Added check to get unsafe params if rails version is great than 5
2017-01-07 16:27:57 -06:00
Benjamin Fleischer
a5423dab20 Merge pull request #2017 from bf4/remove_warnings
Fix mt6 assert_nil warnings
2017-01-07 16:26:34 -06:00
Benjamin Fleischer
9a2e1e4743 Merge pull request #2020 from bf4/silence_grape_warnings
Silence Grape warnings
2017-01-07 16:26:24 -06:00
Benjamin Fleischer
0dd7680fe5 Merge pull request #2019 from bf4/fix_method_redefined_warning
Fix AMS warnings
2017-01-07 16:26:18 -06:00
Benjamin Fleischer
21bcfd891d Merge pull request #2018 from rails-api/bump_version
Bump to v0.10.4 [ci skip]
Conflicts:
	CHANGELOG.md
2017-01-07 16:25:50 -06:00
Benjamin Fleischer
3b155de03f Merge pull request #2017 from bf4/remove_warnings
Fix mt6 assert_nil warnings
2017-01-07 16:23:34 -05:00
Benjamin Fleischer
c52af54b4e Improve tests found by assert_nil 2017-01-06 23:17:43 -06:00
Benjamin Fleischer
4dfbe2747b Fix test bug found by assert_nil 2017-01-06 22:49:50 -06:00
Benjamin Fleischer
6acb4055c9 Fix MT6 assert_nil warnings 2017-01-06 22:06:23 -06:00
Benjamin Fleischer
98194cc0be Merge pull request #2020 from bf4/silence_grape_warnings
Silence Grape warnings
2017-01-06 23:05:45 -05:00
Benjamin Fleischer
7efb3629e4 Merge pull request #2019 from bf4/fix_method_redefined_warning
Fix AMS warnings
2017-01-06 23:04:21 -05:00
Benjamin Fleischer
b620c275e5 Silence Grape warnings 2017-01-06 17:18:08 -06:00
Benjamin Fleischer
ced317d827 Fix thor warning to set type: :boolean, was setting { banner: "" }
```
require "rails/generators/rails/model/model_generator"

module Rails
  module Generators
    class ResourceGenerator < ModelGenerator # :nodoc:
      include ResourceHelpers

      hook_for :resource_controller, required: true do |controller|
        invoke controller, [ controller_name, options[:actions] ]
      end

      class_option :actions, type: :array, banner: "ACTION ACTION", default: [],
                             desc: "Actions for the resource controller"

      hook_for :resource_route, required: true
    end
  end
end
```

```
 # .bundle/ruby/2.2.0/bundler/gems/rails-4c5f1bc9d45e/railties/lib/rails/generators/base.rb
      # Invoke a generator based on the value supplied by the user to the
      # given option named "name". A class option is created when this method
      # is invoked and you can set a hash to customize it.
      #
      # ==== Examples
      #
      #   module Rails::Generators
      #     class ControllerGenerator < Base
      #       hook_for :test_framework, aliases: "-t"
      #     end
      #   end
      #
      # The example above will create a test framework option and will invoke
      # a generator based on the user supplied value.
      #
      # For example, if the user invoke the controller generator as:
      #
      #   rails generate controller Account --test-framework=test_unit
      #
      # The controller generator will then try to invoke the following generators:
      #
      #   "rails:test_unit", "test_unit:controller", "test_unit"
      #
      # Notice that "rails:generators:test_unit" could be loaded as well, what
      # Rails looks for is the first and last parts of the namespace. This is what
      # allows any test framework to hook into Rails as long as it provides any
      # of the hooks above.
      #
      # ==== Options
      #
      # The first and last part used to find the generator to be invoked are
      # guessed based on class invokes hook_for, as noticed in the example above.
      # This can be customized with two options: :in and :as.
      #
      # Let's suppose you are creating a generator that needs to invoke the
      # controller generator from test unit. Your first attempt is:
      #
      #   class AwesomeGenerator < Rails::Generators::Base
      #     hook_for :test_framework
      #   end
      #
      # The lookup in this case for test_unit as input is:
      #
      #   "test_unit:awesome", "test_unit"
      #
      # Which is not the desired lookup. You can change it by providing the
      # :as option:
      #
      #   class AwesomeGenerator < Rails::Generators::Base
      #     hook_for :test_framework, as: :controller
      #   end
      #
      # And now it will look up at:
      #
      #   "test_unit:controller", "test_unit"
      #
      # Similarly, if you want it to also look up in the rails namespace, you
      # just need to provide the :in value:
      #
      #   class AwesomeGenerator < Rails::Generators::Base
      #     hook_for :test_framework, in: :rails, as: :controller
      #   end
      #
      # And the lookup is exactly the same as previously:
      #
      #   "rails:test_unit", "test_unit:controller", "test_unit"
      #
      # ==== Switches
      #
      # All hooks come with switches for user interface. If you do not want
      # to use any test framework, you can do:
      #
      #   rails generate controller Account --skip-test-framework
      #
      # Or similarly:
      #
      #   rails generate controller Account --no-test-framework
      #
      # ==== Boolean hooks
      #
      # In some cases, you may want to provide a boolean hook. For example, webrat
      # developers might want to have webrat available on controller generator.
      # This can be achieved as:
      #
      #   Rails::Generators::ControllerGenerator.hook_for :webrat, type: :boolean
      #
      # Then, if you want webrat to be invoked, just supply:
      #
      #   rails generate controller Account --webrat
      #
      # The hooks lookup is similar as above:
      #
      #   "rails:generators:webrat", "webrat:generators:controller", "webrat"
      #
      # ==== Custom invocations
      #
      # You can also supply a block to hook_for to customize how the hook is
      # going to be invoked. The block receives two arguments, an instance
      # of the current class and the class to be invoked.
      #
      # For example, in the resource generator, the controller should be invoked
      # with a pluralized class name. But by default it is invoked with the same
      # name as the resource generator, which is singular. To change this, we
      # can give a block to customize how the controller can be invoked.
      #
      #   hook_for :resource_controller do |instance, controller|
      #     instance.invoke controller, [ instance.name.pluralize ]
      #   end
      #
      def self.hook_for(*names, &block)
        options = names.extract_options!
        in_base = options.delete(:in) || base_name
        as_hook = options.delete(:as) || generator_name

        names.each do |name|
          unless class_options.key?(name)
            defaults = if options[:type] == :boolean
              {}
            elsif [true, false].include?(default_value_for_option(name, options))
              { banner: "" }
            else
              { desc: "#{name.to_s.humanize} to be invoked", banner: "NAME" }
            end

            class_option(name, defaults.merge!(options))
          end

          hooks[name] = [ in_base, as_hook ]
          invoke_from_option(name, options, &block)
        end
      end
```

```
  # .bundle/ruby/2.2.0/gems/thor-0.19.4/lib/thor/parser/option.rb:113:in `validate!'
    #   parse :foo => true
    #   #=> Option foo with default value true and type boolean
    #
    # The valid types are :boolean, :numeric, :hash, :array and :string. If none
    # is given a default type is assumed. This default type accepts arguments as
    # string (--foo=value) or booleans (just --foo).
    #
    # By default all options are optional, unless :required is given.
    def validate_default_type!
      default_type = case @default
      when nil
        return
      when TrueClass, FalseClass
        required? ? :string : :boolean
      when Numeric
        :numeric
      when Symbol
        :string
      when Hash, Array, String
        @default.class.name.downcase.to_sym
      end

      # TODO: This should raise an ArgumentError in a future version of Thor
      if default_type != @type
        warn "Expected #{@type} default value for '#{switch_name}'; got #{@default.inspect} (#{default_type})"
      end
    end
```
2017-01-06 17:16:57 -06:00
Benjamin Fleischer
40489fa8a2 Fix method redefined warning 2017-01-06 17:14:56 -06:00
Benjamin Fleischer
ef19a9e703 Merge pull request #2018 from rails-api/bump_version
Bump to v0.10.4 [ci skip]
2017-01-06 18:11:01 -05:00
Benjamin Fleischer
655c721d0d Bump to v0.10.4
Conflicts:
	CHANGELOG.md
2017-01-06 16:23:54 -06:00
Benjamin Fleischer
82db1301f6 Bump to v0.10.4 2017-01-06 16:21:04 -06:00
Benjamin Fleischer
23f03ffd30 Merge pull request #2016 from rails-api/prepare_release
Prepare release of 0.10.4
2017-01-06 17:14:08 -05:00
Benjamin Fleischer
97b587b14c Merge pull request #2005 from kofronpi/support-ruby-2.4
Update jsonapi runtime dependency to 0.1.1.beta6
2017-01-06 14:17:37 -06:00
L. Preston Sego III
adf110f4df Swap out KeyTransform for CaseTransform (#1993)
* delete KeyTransform, use CaseTransform

* added changelog

Conflicts:
	CHANGELOG.md
2017-01-06 14:17:37 -06:00
Benjamin Fleischer
2c0b15d22f Merge pull request #2007 from bf4/check_ci
Test was failing due to change in JSON exception message when parsing empty string
2017-01-06 14:17:35 -06:00
Benjamin Fleischer
dfa6caac27 Merge pull request #2000 from berfarah/patch-1
Link to 0.10.3 tag instead of `master` branch
2017-01-05 21:36:32 -06:00
Benjamin Fleischer
49f2dca730 Merge pull request #1999 from bf4/typos
Fix typos [ci skip]
2017-01-05 21:36:25 -06:00
Benjamin Fleischer
4054f43309 Merge pull request #1994 from bf4/promote_architecture
Promote important architecture description that answers a lot of questions we get
Conflicts:
	docs/ARCHITECTURE.md
2017-01-05 21:35:57 -06:00
L. Preston Sego III
e036b71e0c Merge pull request #1992 from ojiry/bump_ruby_versions
Run tests by Ruby 2.2.6 and 2.3.3
2017-01-05 21:33:07 -06:00
Benjamin Fleischer
6e11d6234e Merge pull request #1990 from mxie/mx-result-typo
Fix typos and capitalization in Relationship Links docs [ci skip]
2017-01-05 21:32:31 -06:00
Yohan Robert
91128fadb8 [skip ci] Fix relationship link documentation 2016-12-30 21:02:03 +01:00
Benjamin Fleischer
ec045a5388 Merge pull request #2012 from bf4/cleanup_isolated_jsonapi_renderer_tests_a_bit
Cleanup assertions in isolated jsonapi renderer tests a bit
2016-12-25 13:42:33 -06:00
Benjamin Fleischer
6cf84c11e0 Less strict exception matching 2016-12-24 21:29:46 -06:00
Benjamin Fleischer
4394f76b86 Cleanup assertions in isolated jsonapi renderer tests a bit 2016-12-24 21:28:15 -06:00
Ankit Shah
f246741cc5 Updated isolated tests to assert correct behavior. (#2010)
* Updated isolated tests to assert correct behavior.
* Added check to get unsafe params if rails version is great than 5
2016-12-24 20:34:07 -06:00
Benjamin Fleischer
4e430132db Merge pull request #2005 from kofronpi/support-ruby-2.4
Update jsonapi runtime dependency to 0.1.1.beta6
2016-12-23 11:24:38 -06:00
Benjamin Fleischer
3f46846891 Merge pull request #2007 from bf4/check_ci
Test was failing due to change in JSON exception message when parsing empty string
2016-12-23 11:24:23 -06:00
Benjamin Fleischer
c1fc0e4371 Handle different messages from different versions of JSON gem 2016-12-23 11:14:59 -06:00
Pierre-Alexandre Kofron
9eacf9f3b7 Update jsonapi runtime dependency to 0.1.1.beta6 2016-12-16 18:00:49 +01:00
Benjamin Fleischer
95f832fd0e Merge pull request #2000 from berfarah/patch-1
Link to 0.10.3 tag instead of `master` branch
2016-12-14 20:30:59 -06:00
Bernardo Farah
0976bdc4d0 Link to 0.10.3 tag instead of master branch
It may be less confusing for new users if the docs link them to the current stable release. It could reduce issues like [this one](https://github.com/rails-api/active_model_serializers/issues/1988)
2016-12-14 11:37:18 -08:00
Benjamin Fleischer
bbcadec96a Merge pull request #1999 from bf4/typos
Fix typos [ci skip]
2016-12-13 09:23:29 -06:00
Benjamin Fleischer
05430fb233 Fix typos
```
go get -u github.com/client9/misspell/cmd/misspell
misspell  -w -q -error -source=text {app,config,lib,test}/**/*
```

>   workers   = flag.Int("j", 0, "Number of workers, 0 = number of CPUs")
>   writeit   = flag.Bool("w", false, "Overwrite file with corrections (default is just to display)")
>   quietFlag = flag.Bool("q", false, "Do not emit misspelling output")
>   outFlag   = flag.String("o", "stdout", "output file or [stderr|stdout|]")
>   format    = flag.String("f", "", "'csv', 'sqlite3' or custom Golang template for output")
>   ignores   = flag.String("i", "", "ignore the following corrections, comma separated")
>   locale    = flag.String("locale", "", "Correct spellings using locale perferances for US or UK.  Default is to use a neutral variety of English.  Setting locale to US will correct the British spelling of 'colour' to 'color'")
>   mode      = flag.String("source", "auto", "Source mode: auto=guess, go=golang source, text=plain or markdown-like text")
>   debugFlag = flag.Bool("debug", false, "Debug matching, very slow")
>   exitError = flag.Bool("error", false, "Exit with 2 if misspelling found")
2016-12-11 23:41:23 -06:00
L. Preston Sego III
0422a1e772 Swap out KeyTransform for CaseTransform (#1993)
* delete KeyTransform, use CaseTransform

* added changelog
2016-12-07 10:49:38 -05:00
Benjamin Fleischer
fca2d4515d Merge pull request #1994 from bf4/promote_architecture
Promote important architecture description that answers a lot of questions we get
2016-12-07 07:07:26 -06:00
Benjamin Fleischer
847f50a13c Merge pull request #1984 from bf4/make_test_attributes_explicit
Make test attributes explicit
2016-12-06 14:53:13 -06:00