mirror of
				https://github.com/varvet/pundit.git
				synced 2022-11-09 12:30:11 -05:00 
			
		
		
		
	Travis build change: Fix build, use latest JRuby
- Lint only 1 time, on modern Ruby
This commit is contained in:
		
							parent
							
								
									8b2d638103
								
							
						
					
					
						commit
						9691355fca
					
				
					 8 changed files with 67 additions and 26 deletions
				
			
		
							
								
								
									
										13
									
								
								.rubocop.yml
									
										
									
									
									
								
							
							
						
						
									
										13
									
								
								.rubocop.yml
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -1,14 +1,23 @@
 | 
			
		|||
inherit_from: .rubocop_todo.yml
 | 
			
		||||
AllCops:
 | 
			
		||||
  DisplayCopNames: true
 | 
			
		||||
  TargetRubyVersion: 1.9
 | 
			
		||||
  Exclude:
 | 
			
		||||
    - "gemfiles/**/*"
 | 
			
		||||
    - "vendor/**/*"
 | 
			
		||||
    - "lib/generators/**/*"
 | 
			
		||||
 | 
			
		||||
Metrics/BlockLength:
 | 
			
		||||
  Exclude:
 | 
			
		||||
    - "**/*_spec.rb"
 | 
			
		||||
 | 
			
		||||
Metrics/MethodLength:
 | 
			
		||||
  Max: 40
 | 
			
		||||
 | 
			
		||||
Metrics/ModuleLength:
 | 
			
		||||
  Max: 200
 | 
			
		||||
  Exclude:
 | 
			
		||||
    - "**/*_spec.rb"
 | 
			
		||||
 | 
			
		||||
Metrics/LineLength:
 | 
			
		||||
  Max: 120
 | 
			
		||||
| 
						 | 
				
			
			@ -50,7 +59,7 @@ Documentation:
 | 
			
		|||
  Enabled: false # TODO: Enable again once we have more docs
 | 
			
		||||
 | 
			
		||||
Style/CaseIndentation:
 | 
			
		||||
  IndentWhenRelativeTo: case
 | 
			
		||||
  EnforcedStyle: case
 | 
			
		||||
  SupportedStyles:
 | 
			
		||||
    - case
 | 
			
		||||
    - end
 | 
			
		||||
| 
						 | 
				
			
			@ -74,7 +83,7 @@ Style/TrivialAccessors:
 | 
			
		|||
  ExactNameMatch: true
 | 
			
		||||
 | 
			
		||||
Lint/EndAlignment:
 | 
			
		||||
  AlignWith: variable
 | 
			
		||||
  EnforcedStyleAlignWith: variable
 | 
			
		||||
 | 
			
		||||
Lint/DefEndAlignment:
 | 
			
		||||
  Enabled: false
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										13
									
								
								.rubocop_todo.yml
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								.rubocop_todo.yml
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,13 @@
 | 
			
		|||
# This configuration was generated by
 | 
			
		||||
# `rubocop --auto-gen-config`
 | 
			
		||||
# on 2016-12-06 09:57:39 +0100 using RuboCop version 0.41.2.
 | 
			
		||||
# The point is for the user to remove these configuration records
 | 
			
		||||
# one by one as the offenses are removed from the code base.
 | 
			
		||||
# Note that changes in the inspected code, or installation of new
 | 
			
		||||
# versions of RuboCop, may require this file to be generated again.
 | 
			
		||||
 | 
			
		||||
# Offense count: 1
 | 
			
		||||
# Cop supports --auto-correct.
 | 
			
		||||
Lint/UnneededDisable:
 | 
			
		||||
  Exclude:
 | 
			
		||||
    - 'lib/pundit/rspec.rb'
 | 
			
		||||
							
								
								
									
										28
									
								
								.travis.yml
									
										
									
									
									
								
							
							
						
						
									
										28
									
								
								.travis.yml
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -1,12 +1,20 @@
 | 
			
		|||
language: ruby
 | 
			
		||||
sudo: false
 | 
			
		||||
rvm:
 | 
			
		||||
  - 2.0.0
 | 
			
		||||
  - 2.1
 | 
			
		||||
  - 2.2
 | 
			
		||||
  - 2.3.0
 | 
			
		||||
  - jruby-19mode
 | 
			
		||||
  - rbx-2
 | 
			
		||||
env:
 | 
			
		||||
  - RSPEC_VERSION="<2.99"
 | 
			
		||||
  - RSPEC_VERSION="~>3.0
 | 
			
		||||
before_install:
 | 
			
		||||
  - gem update --system
 | 
			
		||||
  - gem install bundler
 | 
			
		||||
 | 
			
		||||
matrix:
 | 
			
		||||
  include:
 | 
			
		||||
    - rvm: 2.4.0
 | 
			
		||||
      script: bundle exec rake rubocop # ONLY lint once, first
 | 
			
		||||
    - rvm: 2.1
 | 
			
		||||
    - rvm: 2.2
 | 
			
		||||
    - rvm: 2.3.3
 | 
			
		||||
    - rvm: 2.4.0
 | 
			
		||||
    - rvm: jruby-1.7.26
 | 
			
		||||
      env:
 | 
			
		||||
        - JRUBY_OPTS="--debug"
 | 
			
		||||
    - rvm: jruby-9.1.8.0
 | 
			
		||||
      env:
 | 
			
		||||
        - JRUBY_OPTS="--debug"
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										14
									
								
								Gemfile
									
										
									
									
									
								
							
							
						
						
									
										14
									
								
								Gemfile
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -1,4 +1,16 @@
 | 
			
		|||
source "https://rubygems.org"
 | 
			
		||||
 | 
			
		||||
gem "rspec", ENV["RSPEC_VERSION"] unless ENV["RSPEC_VERSION"].to_s.empty?
 | 
			
		||||
ruby RUBY_VERSION
 | 
			
		||||
 | 
			
		||||
gemspec
 | 
			
		||||
 | 
			
		||||
group :development, :test do
 | 
			
		||||
  gem "actionpack"
 | 
			
		||||
  gem "activemodel"
 | 
			
		||||
  gem "bundler"
 | 
			
		||||
  gem "pry"
 | 
			
		||||
  gem "rake"
 | 
			
		||||
  gem "rspec"
 | 
			
		||||
  gem "rubocop"
 | 
			
		||||
  gem "yard"
 | 
			
		||||
end
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										1
									
								
								Rakefile
									
										
									
									
									
								
							
							
						
						
									
										1
									
								
								Rakefile
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -16,4 +16,3 @@ YARD::Rake::YardocTask.new do |t|
 | 
			
		|||
end
 | 
			
		||||
 | 
			
		||||
task default: :spec
 | 
			
		||||
task default: :rubocop unless RUBY_ENGINE == "rbx"
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -5,6 +5,7 @@ module Pundit
 | 
			
		|||
    module Matchers
 | 
			
		||||
      extend ::RSpec::Matchers::DSL
 | 
			
		||||
 | 
			
		||||
      # rubocop:disable Metrics/BlockLength
 | 
			
		||||
      matcher :permit do |user, record|
 | 
			
		||||
        match_proc = lambda do |policy|
 | 
			
		||||
          @violating_permissions = permissions.find_all do |permission|
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -19,12 +19,4 @@ Gem::Specification.new do |gem|
 | 
			
		|||
  gem.require_paths = ["lib"]
 | 
			
		||||
 | 
			
		||||
  gem.add_dependency "activesupport", ">= 3.0.0"
 | 
			
		||||
  gem.add_development_dependency "activemodel", ">= 3.0.0"
 | 
			
		||||
  gem.add_development_dependency "actionpack", ">= 3.0.0"
 | 
			
		||||
  gem.add_development_dependency "bundler", "~> 1.3"
 | 
			
		||||
  gem.add_development_dependency "rspec", ">=2.0.0"
 | 
			
		||||
  gem.add_development_dependency "pry"
 | 
			
		||||
  gem.add_development_dependency "rake"
 | 
			
		||||
  gem.add_development_dependency "yard"
 | 
			
		||||
  gem.add_development_dependency "rubocop"
 | 
			
		||||
end
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -431,8 +431,8 @@ describe Pundit do
 | 
			
		|||
        admin: true
 | 
			
		||||
      })
 | 
			
		||||
 | 
			
		||||
      expect(Controller.new(user, params).permitted_attributes(post)).to eq("title" => "Hello", "votes" => 5)
 | 
			
		||||
      expect(Controller.new(double, params).permitted_attributes(post)).to eq("votes" => 5)
 | 
			
		||||
      expect(Controller.new(user, params).permitted_attributes(post).to_h).to eq("title" => "Hello", "votes" => 5)
 | 
			
		||||
      expect(Controller.new(double, params).permitted_attributes(post).to_h).to eq("votes" => 5)
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    it "checks policy for permitted attributes for record of a ActiveModel type" do
 | 
			
		||||
| 
						 | 
				
			
			@ -444,6 +444,13 @@ describe Pundit do
 | 
			
		|||
 | 
			
		||||
      expect(Controller.new(user, params).permitted_attributes(customer_post)).to eq("title" => "Hello", "votes" => 5)
 | 
			
		||||
      expect(Controller.new(double, params).permitted_attributes(customer_post)).to eq("votes" => 5)
 | 
			
		||||
      expect(Controller.new(user, params).permitted_attributes(customer_post).to_h).to eq(
 | 
			
		||||
        "title" => "Hello",
 | 
			
		||||
        "votes" => 5
 | 
			
		||||
      )
 | 
			
		||||
      expect(Controller.new(double, params).permitted_attributes(customer_post).to_h).to eq(
 | 
			
		||||
        "votes" => 5
 | 
			
		||||
      )
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -456,7 +463,7 @@ describe Pundit do
 | 
			
		|||
        admin: true
 | 
			
		||||
      })
 | 
			
		||||
 | 
			
		||||
      expect(Controller.new(user, params).permitted_attributes(post)).to eq("body" => "blah")
 | 
			
		||||
      expect(Controller.new(user, params).permitted_attributes(post).to_h).to eq("body" => "blah")
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    it "can be explicitly set" do
 | 
			
		||||
| 
						 | 
				
			
			@ -467,7 +474,7 @@ describe Pundit do
 | 
			
		|||
        admin: true
 | 
			
		||||
      })
 | 
			
		||||
 | 
			
		||||
      expect(Controller.new(user, params).permitted_attributes(post, :revise)).to eq("body" => "blah")
 | 
			
		||||
      expect(Controller.new(user, params).permitted_attributes(post, :revise).to_h).to eq("body" => "blah")
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue