Skip to content

Commit cbcf8b1

Browse files
committed
Merge branch 'develop'
2 parents a1e9a08 + 993d231 commit cbcf8b1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+2153
-156
lines changed

.github/workflows/test.yml

+22-25
Original file line numberDiff line numberDiff line change
@@ -14,41 +14,38 @@ jobs:
1414
strategy:
1515
fail-fast: false
1616
matrix:
17-
ruby: ['2.6', '2.7', '3.0', 'jruby', 'truffleruby']
18-
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_main.gemfile']
17+
ruby: ['2.7', '3.0', '3.1', '3.2', '3.3']
18+
gemfile: ['gemfiles/activerecord_5.2.2.gemfile', 'gemfiles/activerecord_6.0.0.gemfile', 'gemfiles/activerecord_6.1.0.gemfile', 'gemfiles/activerecord_7.0.0.gemfile', 'gemfiles/activerecord_7.1.0.gemfile', 'gemfiles/activerecord_main.gemfile']
1919
include:
20+
- gemfile: 'gemfiles/activerecord_7.1.0.gemfile'
21+
ruby: '3.3'
22+
- gemfile: 'gemfiles/activerecord_7.1.0.gemfile'
23+
ruby: '3.0'
2024
- gemfile: 'gemfiles/activerecord_7.0.0.gemfile'
21-
ruby: '3.1'
25+
ruby: '3.3'
2226
- gemfile: 'gemfiles/activerecord_7.0.0.gemfile'
2327
ruby: '3.0'
2428
- gemfile: 'gemfiles/activerecord_6.1.0.gemfile'
25-
ruby: '3.1'
29+
ruby: '3.3'
2630
- gemfile: 'gemfiles/activerecord_6.1.0.gemfile'
2731
ruby: '3.0'
2832
exclude:
2933
- gemfile: 'gemfiles/activerecord_5.2.2.gemfile'
30-
ruby: '3.0' # rails 5.2 can't run on ruby 3.0
31-
- gemfile: 'gemfiles/activerecord_5.1.0.gemfile'
32-
ruby: '3.0' # rails 5.1 can't run on ruby 3.0
33-
- gemfile: 'gemfiles/activerecord_5.0.2.gemfile'
34-
ruby: '3.0' # rails 5.0 can't run on ruby 3.0
35-
- gemfile: 'gemfiles/activerecord_5.0.2.gemfile'
36-
ruby: '3.0' # rails 5.0 can't run on ruby 3.0
37-
- gemfile: 'gemfiles/activerecord_5.0.2.gemfile'
38-
ruby: 'truffleruby' # TruffleRuby 21.0 targets Ruby 2.7, same as above
39-
- gemfile: 'gemfiles/activerecord_5.1.0.gemfile'
40-
ruby: 'truffleruby' # TruffleRuby 21.0 targets Ruby 2.7, same as above
34+
ruby: '3.0'
35+
- gemfile: 'gemfiles/activerecord_5.2.2.gemfile'
36+
ruby: '3.1'
4137
- gemfile: 'gemfiles/activerecord_5.2.2.gemfile'
42-
ruby: 'truffleruby' # TruffleRuby 21.0 targets Ruby 2.7, same as above
38+
ruby: '3.2'
39+
- gemfile: 'gemfiles/activerecord_5.2.2.gemfile'
40+
ruby: '3.3'
41+
- gemfile: 'gemfiles/activerecord_7.0.0.gemfile'
42+
ruby: '2.7'
43+
- gemfile: 'gemfiles/activerecord_7.1.0.gemfile'
44+
ruby: '2.7'
4345
- gemfile: 'gemfiles/activerecord_main.gemfile'
44-
ruby: '2.6' # rails 7+ requires ruby 3.0+
45-
- gemfile: 'gemfiles/activerecord_5.0.2.gemfile'
46-
ruby: 'jruby' # this *should* work - there's a test failure; it's not incompatible like the other excludes. could be an issue in Rails 5.0.2?
47-
- gemfile: 'gemfiles/activerecord_6.1.0.gemfile'
48-
ruby: 'jruby' # this *should* work. it seems like there's an issue with rails 6 on jruby.
46+
ruby: '2.7'
4947
- gemfile: 'gemfiles/activerecord_main.gemfile'
50-
ruby: 'jruby' # this *should* work. it seems like there's an issue with rails 6 on jruby.
51-
48+
ruby: '3.0'
5249
env:
5350
BUNDLE_GEMFILE: ${{ matrix.gemfile }}
5451

@@ -84,10 +81,10 @@ jobs:
8481
bundler-cache: true
8582

8683
- name: Run tests on sqlite
87-
run: DB=sqlite bundle exec rake
84+
run: DB=sqlite bundle exec rspec
8885

8986
- name: Run tests on postgres
90-
run: DB=postgres bundle exec rake
87+
run: DB=postgres bundle exec rspec
9188

9289
lint:
9390
name: Lint

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,6 @@ Gemfile.lock
1313
.ruby-version
1414
.ruby-gemset
1515
/tmp
16+
.vitepress/cache
17+
node_modules
18+
.vitepress/dist

.rubocop.yml

+1
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,4 @@ AllCops:
5050
- 'gemfiles/**/*'
5151
- 'vendor/**/*'
5252
- 'Appraisals'
53+
- 'node_modules/**/*'

.rubocop_todo.yml

+3
Original file line numberDiff line numberDiff line change
@@ -214,3 +214,6 @@ Style/StringChars:
214214
Style/StringConcatenation:
215215
Exclude:
216216
- 'lib/cancan/rule.rb'
217+
218+
Lint/SafeNavigationChain:
219+
Enabled: false

Appraisals

+23-40
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,3 @@
1-
appraise 'activerecord_5.0.2' do
2-
gem 'activerecord', '~> 5.0.2', require: 'active_record'
3-
gem 'activesupport', '~> 5.0.2', require: 'active_support/all'
4-
gem 'actionpack', '~> 5.0.2', require: 'action_pack'
5-
6-
gemfile.platforms :jruby do
7-
gem 'activerecord-jdbcsqlite3-adapter'
8-
gem 'jdbc-sqlite3'
9-
gem 'jdbc-postgres'
10-
end
11-
12-
gemfile.platforms :ruby, :mswin, :mingw do
13-
gem 'pg', '~> 1.3.4'
14-
gem 'sqlite3', '~> 1.3.0'
15-
end
16-
end
17-
18-
appraise 'activerecord_5.1.0' do
19-
gem 'activerecord', '~> 5.1.0', require: 'active_record'
20-
gem 'activesupport', '~> 5.1.0', require: 'active_support/all'
21-
gem 'actionpack', '~> 5.1.0', require: 'action_pack'
22-
23-
gemfile.platforms :jruby do
24-
gem 'activerecord-jdbcsqlite3-adapter'
25-
gem 'jdbc-sqlite3'
26-
gem 'jdbc-postgres'
27-
end
28-
29-
gemfile.platforms :ruby, :mswin, :mingw do
30-
gem 'pg', '~> 1.3.4'
31-
gem 'sqlite3', '~> 1.4.2'
32-
end
33-
end
34-
351
appraise 'activerecord_5.2.2' do
362
gem 'activerecord', '~> 5.2.2', require: 'active_record'
373
gem 'activesupport', '~> 5.2.2', require: 'active_support/all'
@@ -45,7 +11,7 @@ appraise 'activerecord_5.2.2' do
4511

4612
gemfile.platforms :ruby, :mswin, :mingw do
4713
gem 'pg', '~> 1.3.4'
48-
gem 'sqlite3', '~> 1.4.2'
14+
gem 'sqlite3', '~> 1.7.3'
4915
end
5016
end
5117

@@ -62,7 +28,7 @@ appraise 'activerecord_6.0.0' do
6228

6329
platforms :ruby, :mswin, :mingw do
6430
gem 'pg', '~> 1.3.4'
65-
gem 'sqlite3', '~> 1.4.2'
31+
gem 'sqlite3', '~> 1.7.3'
6632
end
6733
end
6834

@@ -79,7 +45,7 @@ appraise 'activerecord_6.1.0' do
7945

8046
platforms :ruby, :mswin, :mingw do
8147
gem 'pg', '~> 1.3.4'
82-
gem 'sqlite3', '~> 1.4.2'
48+
gem 'sqlite3', '~> 1.7.3'
8349
end
8450
end
8551

@@ -96,7 +62,24 @@ appraise 'activerecord_7.0.0' do
9662

9763
platforms :ruby, :mswin, :mingw do
9864
gem 'pg', '~> 1.3.4'
99-
gem 'sqlite3', '~> 1.4.2'
65+
gem 'sqlite3', '~> 1.7.3'
66+
end
67+
end
68+
69+
appraise 'activerecord_7.1.0' do
70+
gem 'actionpack', '~> 7.1.0', require: 'action_pack'
71+
gem 'activerecord', '~> 7.1.0', require: 'active_record'
72+
gem 'activesupport', '~> 7.1.0', require: 'active_support/all'
73+
74+
platforms :jruby do
75+
gem 'activerecord-jdbcsqlite3-adapter'
76+
gem 'jdbc-sqlite3'
77+
gem 'jdbc-postgres'
78+
end
79+
80+
platforms :ruby, :mswin, :mingw do
81+
gem 'pg', '~> 1.5.6'
82+
gem 'sqlite3', '~> 1.7.3'
10083
end
10184
end
10285

@@ -114,7 +97,7 @@ appraise 'activerecord_main' do
11497
end
11598

11699
platforms :ruby, :mswin, :mingw do
117-
gem 'pg', '~> 1.3.4'
118-
gem 'sqlite3', '~> 1.4.2'
100+
gem 'pg', '~> 1.5.6'
101+
gem 'sqlite3', '~> 1.7.3'
119102
end
120103
end

CHANGELOG.md

+9
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## 3.6.0
2+
3+
* [#849](https://github.com/CanCanCommunity/cancancan/pull/849): Update tests matrix. ([@coorasse][])
4+
* [#843](https://github.com/CanCanCommunity/cancancan/pull/843): Compress duplicate rules. ([@MrChoclate][])
5+
* [#841](https://github.com/CanCanCommunity/cancancan/pull/841): New https://cancancan.dev website. ([@pandermatt][])
6+
* [#839](https://github.com/CanCanCommunity/cancancan/pull/839): switch from database column detection to Rails attributes detection. ([@kalsan][])
17
## 3.5.0
28

39
* [#653](https://github.com/CanCanCommunity/cancancan/pull/653): Add support for using an nil relation as a condition. ([@ghiculescu][])
@@ -707,3 +713,6 @@ Please read the [guide on migrating from CanCanCan 2.x to 3.0](https://github.co
707713
[@Juleffel]: https://github.com/Juleffel
708714
[@honigc]: https://github.com/honigc
709715
[@WriterZephos]: https://github.com/WriterZephos
716+
[@MrChoclate]: https://github.com/MrChoclate
717+
[@pandermatt]: https://github.com/pandermatt
718+
[@kalsan]: https://github.com/kalsan

CONTRIBUTING.md

+16
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,19 @@ Please make sure you have test coverage for anything you add or fix!
2525
Please add a CHANGELOG entry with any relevant tags for issues, pull-requests, and authors.
2626

2727
Thanks for you contribution!
28+
29+
### Modify the Documentation
30+
31+
The documentation is written in Markdown and is located in the `docs` directory. The documentation is built using [VitePress](https://vitepress.dev).
32+
VitePress supports all markdown features but also adds a few enhancements, which are documented in the [Markdown Extensions](https://vitepress.dev/guide/markdown).
33+
34+
```bash
35+
npm install
36+
npm run dev
37+
38+
# build for production, resulting in a static site in docs/.vitepress/dist
39+
npm run build
40+
```
41+
42+
Before submitting a pull request, please make sure the documentation builds correctly using `npm run build`.
43+
Most likely the build will fail if there are any syntax errors in the markdown files or dead links.

README.md

+9-27
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,14 @@ of models automatically and reduce duplicated code.
2626

2727
## Our sponsors
2828
<br/>
29-
<a href="https://www.renuo.ch" target="_blank">
30-
<img src="./logo/renuo.png" alt="Renuo AG" height="50"/>
29+
<a href="https://www.pennylane.com/" target="_blank">
30+
<img src="./logo/pennylane.svg" alt="Pennylane" height="50"/>
3131
</a>
32-
<br/>
33-
<br/>
34-
<br/>
35-
<a href="https://www.moderntreasury.com" target="_blank" style="display:inline">
36-
<img src="./logo/modern_treasury.svg" alt="Modern Treasury" height="40"/>
37-
</a>
38-
<br/>
39-
<br/>
40-
<br/>
41-
<a href="https://bullettrain.co" target="_blank">
42-
<img src="./logo/bullet_train.png" alt="Bullet Train" height="50"/>
32+
<br />
33+
<br />
34+
<br />
35+
<a href="https://www.honeybadger.io/" target="_blank">
36+
<img src="./logo/honeybadger.svg" alt="Honeybadger" height="45"/>
4337
</a>
4438
<br/>
4539
<br/>
@@ -50,20 +44,8 @@ of models automatically and reduce duplicated code.
5044
<br />
5145
<br />
5246
<br />
53-
<a href="https://newrelic.com/" target="_blank">
54-
<img src="./logo/new_relic.png" alt="NewRelic" height="45"/>
55-
</a>
56-
<br />
57-
<br />
58-
<br />
59-
<a href="https://www.ontra.ai" target="_blank">
60-
<img src="./logo/ontra.png" alt="Ontra" height="70"/>
61-
</a>
62-
<br />
63-
<br />
64-
<br />
65-
<a href="https://www.honeybadger.io/" target="_blank">
66-
<img src="./logo/honeybadger.svg" alt="Honeybadger" height="45"/>
47+
<a href="https://www.renuo.ch" target="_blank">
48+
<img src="./logo/renuo.png" alt="Renuo AG" height="50"/>
6749
</a>
6850
<br />
6951
<br />

docs/.vitepress/config.mts

+97
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
import { defineConfig } from 'vitepress'
2+
3+
// https://vitepress.dev/reference/site-config
4+
export default defineConfig({
5+
title: "CanCanCan",
6+
description: "The authorization Gem for Ruby on Rails.",
7+
head: [
8+
['link', { rel: "apple-touch-icon", sizes: "180x180", href: "/apple-touch-icon.png" }],
9+
['link', { rel: "icon", type: "image/png", sizes: "32x32", href: "/favicon-32x32.png" }],
10+
['link', { rel: "icon", type: "image/png", sizes: "16x16", href: "/favicon-16x16.png" }],
11+
['link', { rel: "mask-icon", href: "./safari-pinned-tab.svg", color: "#3c3ebf" }],
12+
13+
['link', { rel: "icon", href: "/favicon.ico", type: "image/x-icon" }],
14+
['link', { rel: "shortcut icon", href: "/favicon.ico", type: "image/x-icon" }],
15+
],
16+
sitemap: {
17+
hostname: 'https://cancancan.dev'
18+
},
19+
cleanUrls: true,
20+
themeConfig: {
21+
// https://vitepress.dev/reference/default-theme-config
22+
nav: [
23+
{ text: 'Docs', link: '/README' },
24+
{ text: 'Changelog', link: 'https://github.com/CanCanCommunity/cancancan/blob/main/CHANGELOG.md' },
25+
{
26+
text: 'Screencasts',
27+
items: [
28+
{ text: 'Screencast 1', link: 'http://railscasts.com/episodes/192-authorization-with-cancan' },
29+
{ text: 'Screencast 2', link: 'https://www.youtube.com/watch?v=cTYu-OjUgDw' }
30+
]
31+
},
32+
],
33+
34+
footer: {
35+
message: 'Made with ❤️ by the <a href="https://github.com/CanCanCommunity/cancancan/graphs/contributors" target="_blank">CanCanCan community</a>',
36+
copyright: `${new Date().getFullYear()} CanCanCan`
37+
},
38+
externalLinkIcon: true,
39+
40+
lastUpdated: {
41+
formatOptions: {
42+
dateStyle: 'medium',
43+
}
44+
},
45+
editLink: {
46+
pattern: 'https://github.com/CanCanCommunity/cancancan/edit/main/docs/:path'
47+
},
48+
search: {
49+
provider: 'local'
50+
},
51+
52+
logo: '/cancancan.png',
53+
54+
sidebar: [
55+
{
56+
text: 'Guide',
57+
items: [
58+
{ text: 'Introduction', link: '/introduction' },
59+
{ text: 'Installation', link: '/installation' },
60+
{ text: 'Define and check abilities', link: '/define_check_abilities' },
61+
{ text: 'Controller helpers', link: '/controller_helpers' },
62+
{ text: 'Fetching records', link: '/fetching_records' },
63+
{ text: 'Cannot', link: '/cannot' },
64+
{ text: 'Hash of conditions', link: '/hash_of_conditions' },
65+
{ text: 'Combine Abilities', link: '/combine_abilities' },
66+
{ text: 'Check abilities - avoid mistakes', link: '/check_abilities_mistakes' },
67+
{ text: 'Handling CanCan::AccessDenied', link: '/handling_access_denied' },
68+
{ text: 'Customize controller helpers', link: '/changing_defaults' },
69+
{ text: 'Accessing request data', link: '/accessing_request_data' },
70+
{ text: 'SQL strategies', link: '/sql_strategies' },
71+
{ text: 'Accessible attributes', link: '/accessible_attributes' },
72+
{ text: 'Testing', link: '/testing' },
73+
{ text: 'Internationalization', link: '/internationalization' }
74+
]
75+
},
76+
{
77+
text: 'Further topics',
78+
items: [
79+
{ text: 'Migrating', link: '/migrating' },
80+
{ text: 'Debugging Abilities', link: '/debugging' },
81+
{ text: 'Split your ability file', link: '/split_ability' },
82+
{ text: 'Define Abilities - best practices', link: '/define_abilities_best_practices' },
83+
{ text: 'Abilities in database', link: '/abilities_in_database' },
84+
{ text: 'Role-based Authorization', link: '/role_based_authorization' },
85+
{ text: 'Model Adapter', link: '/model_adapter' },
86+
{ text: 'Rules compression', link: '/rules_compression' },
87+
{ text: 'Inherited Resources', link: '/inherited_resources' },
88+
{ text: 'Devise', link: '/devise' },
89+
{ text: 'FriendlyId', link: '/friendly_id' }
90+
]
91+
}
92+
],
93+
socialLinks: [
94+
{ icon: 'github', link: 'https://github.com/CanCanCommunity/cancancan' }
95+
]
96+
}
97+
})

docs/.vitepress/theme/index.ts

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// https://vitepress.dev/guide/custom-theme
2+
import { h } from 'vue'
3+
import type { Theme } from 'vitepress'
4+
import DefaultTheme from 'vitepress/theme'
5+
import './style.css'
6+
7+
export default {
8+
extends: DefaultTheme,
9+
Layout: () => {
10+
return h(DefaultTheme.Layout, null, {
11+
// https://vitepress.dev/guide/extending-default-theme#layout-slots
12+
})
13+
},
14+
enhanceApp({ app, router, siteData }) {
15+
}
16+
} satisfies Theme

0 commit comments

Comments
 (0)