Skip to content

Commit

Permalink
Merge branch 'release/3.2.0' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
coorasse committed Dec 12, 2020
2 parents d284e87 + abfa504 commit f0fbe69
Show file tree
Hide file tree
Showing 71 changed files with 3,907 additions and 639 deletions.
31 changes: 23 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,48 +1,63 @@
language: ruby
cache: bundler
sudo: false
addons:
postgresql: "9.6"
rvm:
- 2.3.5
- 2.4.2
- 2.5.1
- 2.6.3
- 2.7.0
- ruby-head
- jruby-9.1.17.0
- jruby-9.2.7.0
- jruby-9.2.11.1
- jruby-head
- truffleruby-head

gemfile:
- gemfiles/activerecord_4.2.0.gemfile
- gemfiles/activerecord_5.0.2.gemfile
- gemfiles/activerecord_5.1.0.gemfile
- gemfiles/activerecord_5.2.2.gemfile
- gemfiles/activerecord_6.0.0.gemfile
- gemfiles/activerecord_6.1.0.gemfile
- gemfiles/activerecord_master.gemfile
env:
- DB=sqlite
- DB=postgres

matrix:
fast_finish: true
exclude:
- rvm: 2.2.6
- rvm: 2.4.2
gemfile: gemfiles/activerecord_6.0.0.gemfile
- rvm: 2.2.6
gemfile: gemfiles/activerecord_master.gemfile
- rvm: 2.3.5
gemfile: gemfiles/activerecord_6.0.0.gemfile
gemfile: gemfiles/activerecord_master.gemfile
- rvm: 2.4.2
gemfile: gemfiles/activerecord_6.0.0.gemfile
gemfile: gemfiles/activerecord_master.gemfile
- rvm: 2.7.0
gemfile: gemfiles/activerecord_4.2.0.gemfile
- rvm: ruby-head
gemfile: gemfiles/activerecord_4.2.0.gemfile
- rvm: truffleruby-head
gemfile: gemfiles/activerecord_4.2.0.gemfile
- rvm: jruby-9.1.17.0
gemfile: gemfiles/activerecord_5.0.2.gemfile
- rvm: jruby-9.1.17.0
gemfile: gemfiles/activerecord_6.0.0.gemfile
- rvm: jruby-9.2.7.0
- rvm: jruby-9.1.17.0
gemfile: gemfiles/activerecord_6.1.0.gemfile
- rvm: jruby-9.1.17.0
gemfile: gemfiles/activerecord_master.gemfile
- rvm: jruby-9.2.11.1
gemfile: gemfiles/activerecord_5.0.2.gemfile
- rvm: jruby-9.2.7.0
- rvm: jruby-9.2.11.1
gemfile: gemfiles/activerecord_6.0.0.gemfile
- rvm: jruby-9.2.11.1
gemfile: gemfiles/activerecord_6.1.0.gemfile
- rvm: jruby-9.2.11.1
gemfile: gemfiles/activerecord_master.gemfile
allow_failures:
- rvm: ruby-head
- rvm: jruby-head
Expand Down
34 changes: 34 additions & 0 deletions Appraisals
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,37 @@ appraise 'activerecord_6.0.0' do
gem 'sqlite3', '~> 1.4.0'
end
end

appraise 'activerecord_6.1.0' do
gem 'actionpack', '~> 6.1.0', require: 'action_pack'
gem 'activerecord', '~> 6.1.0', require: 'active_record'
gem 'activesupport', '~> 6.1.0', require: 'active_support/all'

platforms :jruby do
gem 'activerecord-jdbcsqlite3-adapter'
gem 'jdbc-sqlite3'
gem 'jdbc-postgres'
end

platforms :ruby, :mswin, :mingw do
gem 'pg', '~> 1.1.4'
gem 'sqlite3', '~> 1.4.0'
end
end

appraise 'activerecord_master' do
gem 'actionpack', github: 'rails/rails', require: 'action_pack'
gem 'activerecord', github: 'rails/rails', require: 'active_record'
gem 'activesupport', github: 'rails/rails', require: 'active_support/all'

platforms :jruby do
gem 'activerecord-jdbcsqlite3-adapter'
gem 'jdbc-sqlite3'
gem 'jdbc-postgres'
end

platforms :ruby, :mswin, :mingw do
gem 'pg', '~> 1.1.4'
gem 'sqlite3', '~> 1.4.0'
end
end
12 changes: 11 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
## Unreleased
## 3.2.0

* [#649](https://github.com/CanCanCommunity/cancancan/pull/649): Add support for Single Table Inheritance. ([@Liberatys][])
* [#640](https://github.com/CanCanCommunity/cancancan/pull/640): Simplify implementation of new model adapters. ([@ghiculescu][])
* [#650](https://github.com/CanCanCommunity/cancancan/pull/650): Support associations in rules. ([@Liberatys][])
* [#657](https://github.com/CanCanCommunity/cancancan/pull/657): Support for Rails 6.1. ([@ghiculescu][])
* [#655](https://github.com/CanCanCommunity/cancancan/pull/655): Add option for `accessible_by` querying strategy. ([@ghiculescu][])

## 3.1.0

* [#605](https://github.com/CanCanCommunity/cancancan/pull/605): Generate inner queries instead of join+distinct. ([@fsateler][])
* [#608](https://github.com/CanCanCommunity/cancancan/pull/608): Spec for json column regression. ([@aleksejleonov][])
Expand Down Expand Up @@ -665,3 +673,5 @@ Please read the [guide on migrating from CanCanCan 2.x to 3.0](https://github.co
[@aleksejleonov]: https://github.com/aleksejleonov
[@albb0920]: https://github.com/albb0920
[@ayumu838]: https://github.com/ayumu838
[@Liberatys]: https://github.com/Liberatys
[@ghiculescu]: https://github.com/ghiculescu
69 changes: 37 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# CanCanCan

![CanCanCan Logo](/logo/cancancan.jpg)
<img src="./logo/cancancan.png" width="200" />

[![Gem Version](https://badge.fury.io/rb/cancancan.svg)](http://badge.fury.io/rb/cancancan)
[![Travis badge](https://travis-ci.org/CanCanCommunity/cancancan.svg?branch=develop)](https://travis-ci.org/CanCanCommunity/cancancan)
[![Code Climate Badge](https://codeclimate.com/github/CanCanCommunity/cancancan.svg)](https://codeclimate.com/github/CanCanCommunity/cancancan)

[Wiki](https://github.com/CanCanCommunity/cancancan/wiki) |
[Wiki](./docs) |
[RDocs](http://rdoc.info/projects/CanCanCommunity/cancancan) |
[Screencast 1](http://railscasts.com/episodes/192-authorization-with-cancan) |
[Screencast 2](https://www.youtube.com/watch?v=cTYu-OjUgDw)

CanCanCan is an authorization library for Ruby >= 2.2.0 and Ruby on Rails >= 4.2 which restricts what
CanCanCan is an authorization library for Ruby and Ruby on Rails which restricts what
resources a given user is allowed to access.

All permissions can be defined in one or multiple ability files and not duplicated across controllers, views,
Expand All @@ -24,6 +24,22 @@ and provides helpers to check for those permissions.
2. **Rails helpers** to simplify the code in Rails Controllers by performing the loading and checking of permissions
of models automatically and reduce duplicated code.

## Sponsored by

<a href="https://www.renuo.ch" target="_blank">
<img src="./logo/renuo.png" alt="Renuo AG" width="200"/>
</a>
<br/>
<br/>
<a href="https://www.moderntreasury.com" target="_blank" style="display:inline">
<img src="./logo/modern_treasury.svg" alt="Modern Treasury" width="400"/>
</a>
<br/>
<br/>

Do you want to sponsor CanCanCan and show your logo here?
Check our [Sponsors Page](https://github.com/sponsors/coorasse).

## Installation

Add this to your Gemfile:
Expand Down Expand Up @@ -57,7 +73,7 @@ class Ability
end
```

See [Defining Abilities](https://github.com/CanCanCommunity/cancancan/wiki/defining-abilities) for details on how to
See [Defining Abilities](./docs/Defining-Abilities.md) for details on how to
define your rules.


Expand All @@ -71,7 +87,7 @@ The current user's permissions can then be checked using the `can?` and `cannot?
<% end %>
```

See [Checking Abilities](https://github.com/CanCanCommunity/cancancan/wiki/checking-abilities) for more information
See [Checking Abilities](./docs/Checking-Abilities.md) for more information
on how you can use these helpers.

## Fetching records
Expand All @@ -85,13 +101,13 @@ The following:
```

will use your rules to ensure that the user retrieves only a list of posts that can be read.
See [Fetching records](https://github.com/CanCanCommunity/cancancan/wiki/Fetching-Records) for details.
See [Fetching records](./docs/Fetching-Records.md) for details.

## Controller helpers

CanCanCan expects a `current_user` method to exist in the controller.
First, set up some authentication (such as [Devise](https://github.com/plataformatec/devise) or [Authlogic](https://github.com/binarylogic/authlogic)).
See [Changing Defaults](https://github.com/CanCanCommunity/cancancan/wiki/changing-defaults) if you need a different behavior.
See [Changing Defaults](./docs/Changing-Defaults.md) if you need a different behavior.

### 3.1 Authorizations

Expand Down Expand Up @@ -124,7 +140,7 @@ class PostsController < ApplicationController
end
```

See [Authorizing Controller Actions](https://github.com/CanCanCommunity/cancancan/wiki/authorizing-controller-actions)
See [Authorizing Controller Actions](./docs/Authorizing-controller-actions.md)
for more information.


Expand Down Expand Up @@ -188,7 +204,7 @@ Finally, it's possible to associate `param_method` with a Proc object which will

load_and_authorize_resource param_method: Proc.new { |c| c.params.require(:post).permit(:name) }

See [Strong Parameters](https://github.com/CanCanCommunity/cancancan/wiki/Strong-Parameters) for more information.
See [Strong Parameters](./docs/Strong-Parameters.md) for more information.

## Handle Unauthorized Access

Expand All @@ -207,7 +223,7 @@ class ApplicationController < ActionController::Base
end
```

See [Exception Handling](https://github.com/CanCanCommunity/cancancan/wiki/exception-handling) for more information.
See [Exception Handling](./docs/Exception-Handling.md) for more information.


## Lock It Down
Expand All @@ -222,16 +238,16 @@ end

This will raise an exception if authorization is not performed in an action.
If you want to skip this, add `skip_authorization_check` to a controller subclass.
See [Ensure Authorization](https://github.com/CanCanCommunity/cancancan/wiki/Ensure-Authorization) for more information.
See [Ensure Authorization](./docs/Ensure-Authorization.md) for more information.

## Wiki Docs

* [Defining Abilities](https://github.com/CanCanCommunity/cancancan/wiki/Defining-Abilities)
* [Checking Abilities](https://github.com/CanCanCommunity/cancancan/wiki/Checking-Abilities)
* [Authorizing Controller Actions](https://github.com/CanCanCommunity/cancancan/wiki/Authorizing-Controller-Actions)
* [Exception Handling](https://github.com/CanCanCommunity/cancancan/wiki/Exception-Handling)
* [Changing Defaults](https://github.com/CanCanCommunity/cancancan/wiki/Changing-Defaults)
* [See more](https://github.com/CanCanCommunity/cancancan/wiki)
* [Defining Abilities](./docs/Defining-Abilities.md)
* [Checking Abilities](./docs/Checking-Abilities.md)
* [Authorizing Controller Actions](./docs/Authorizing-controller-actions.md)
* [Exception Handling](./docs/Exception-Handling.md)
* [Changing Defaults](./docs/Changing-Defaults.md)
* [See more](./docs)

## Mission

Expand All @@ -245,7 +261,7 @@ Any help is greatly appreciated, feel free to submit pull-requests or open issue
## Questions?

If you have any question or doubt regarding CanCanCan which you cannot find the solution to in the
[documentation](https://github.com/CanCanCommunity/cancancan/wiki) or our
[documentation](./docs) or our
[mailing list](http://groups.google.com/group/cancancan), please
[open a question on Stackoverflow](http://stackoverflow.com/questions/ask?tags=cancancan) with tag
[cancancan](http://stackoverflow.com/questions/tagged/cancancan)
Expand All @@ -254,29 +270,18 @@ If you have any question or doubt regarding CanCanCan which you cannot find the

If you find a bug please add an [issue on GitHub](https://github.com/CanCanCommunity/cancancan/issues) or fork the project and send a pull request.


## Development

CanCanCan uses [appraisals](https://github.com/thoughtbot/appraisal) to test the code base against multiple versions
of Rails, as well as the different model adapters.

When first developing, you need to run `bundle install` and then `appraisal install`, to install the different sets.

You can then run all appraisal files (like CI does), with `appraisal rake` or just run a specific set `appraisal activerecord_5.0 rake`.

See the [CONTRIBUTING](https://github.com/CanCanCommunity/cancancan/blob/develop/CONTRIBUTING.md) for more information.
You can then run all appraisal files (like CI does), with `appraisal rake` or just run a specific set `DB='sqlite' bundle exec appraisal activerecord_5.2.2 rake`.

See the [CONTRIBUTING](./CONTRIBUTING.md) for more information.

## Special Thanks

[![Renuo AG](/logo/renuo.png)](https://www.renuo.ch)

Thanks to [Renuo AG](https://www.renuo.ch) for currently maintaining and supporting the project.

Also many thanks to the [CanCanCan contributors](https://github.com/CanCanCommunity/cancancan/contributors).
Many thanks to the [CanCanCan contributors](https://github.com/CanCanCommunity/cancancan/contributors).
See the [CHANGELOG](https://github.com/CanCanCommunity/cancancan/blob/master/CHANGELOG.md) for the full list.

CanCanCan was inspired by [declarative_authorization](https://github.com/stffn/declarative_authorization/) and
[aegis](https://github.com/makandra/aegis).


0 comments on commit f0fbe69

Please sign in to comment.