Repository navigation
Support Active Admin 4 #9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
8ee5178
Support Active Admin 4
senid231 e8349a6
Run the suite on Active Admin 4 too
senid231 89ba83a
Document Active Admin 4 support
senid231 5d3b8c5
Pass Active Admin 4's auth object to Ransack
senid231 16a092e
Document running the suite on Active Admin 4
senid231 ce78c83
Exclude ActiveAdmin 5 prereleases
senid231 99e85bb
Let an arriving alert win over the filter warnings
senid231 63e1d77
Tidy the Active Admin 4 support after review
senid231 e4db531
Remove app names from the spec template comments
senid231 ded92d1
Keep the Active Admin 3 filter warnings unconditional
senid231 5481870
Show Current Filters only when filters apply
senid231 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| require "rails_helper" | ||
|
|
||
| # Active Admin 4 passes its authorization adapter to Ransack, so a model's allowlist can depend | ||
| # on the admin. The gem's own search and its search-key derivation must pass it on as well. | ||
| RSpec.describe "the Ransack auth object", type: :feature do | ||
| it "reaches the model's allowlist from every search the index builds" do | ||
| seen = [] | ||
| allow(Post).to receive(:ransackable_attributes).and_wrap_original do |original, auth_object = nil| | ||
| seen << auth_object | ||
| original.call(auth_object) | ||
| end | ||
|
|
||
| visit "/admin/string_posts" | ||
|
|
||
| expected = ActiveAdminFilterExtensions.aa_v4? ? ActiveAdmin::AuthorizationAdapter : NilClass | ||
| expect(seen).not_to be_empty | ||
| expect(seen).to all(be_a(expected)) | ||
| end | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| require "rails_helper" | ||
|
|
||
| # The sidebar markup moved in Active Admin 4: the Current Filters section has its own id and the | ||
| # filters section renders its title inside the block. | ||
| RSpec.describe "the filters sidebar", type: :feature do | ||
| let(:aa_v4) { ActiveAdminFilterExtensions.aa_v4? } | ||
| let(:current_filters) { aa_v4 ? "#active_search_sidebar_section" : "#search_status_sidebar_section" } | ||
|
|
||
| it "marks the filters form with a data hook" do | ||
| visit "/admin/string_posts" | ||
|
|
||
| expect(page).to have_css("#filters_sidebar_section form[data-filter-extensions-form]") | ||
| end | ||
|
|
||
| it "shows the Current Filters panel when only defaults apply" do | ||
| visit "/admin/string_posts" | ||
|
|
||
| expect(page).to have_css(current_filters, text: "keep") | ||
| end | ||
|
|
||
| it "keeps the Current Filters panel off where the resource turned it off" do | ||
| visit "/admin/quiet_default_posts" | ||
|
|
||
| expect(page).to have_css("#filters_sidebar_section") | ||
| expect(page).to have_no_css(current_filters) | ||
| end | ||
|
|
||
| it "hides the Current Filters panel when nothing is filtered" do | ||
| visit "/admin/no_defaults_posts" | ||
|
|
||
| expect(page).to have_css("#filters_sidebar_section") | ||
| expect(page).to have_no_css(current_filters) | ||
| end | ||
|
|
||
| it "hides the Current Filters panel after a blank filter submit" do | ||
| visit "/admin/string_posts?commit=Filter" | ||
|
|
||
| expect(page).to have_css("#filters_sidebar_section") | ||
| expect(page).to have_no_css(current_filters) | ||
| end | ||
|
|
||
| it "keeps the Current Filters panel for a filter from the request" do | ||
| visit "/admin/no_defaults_posts?q%5Btitle_cont%5D=keep" | ||
|
|
||
| expect(page).to have_css(current_filters, text: "keep") | ||
| end | ||
|
|
||
| it "renders the filters title once" do | ||
| visit "/admin/string_posts" | ||
|
|
||
| if aa_v4 | ||
| expect(page).to have_css("#filters_sidebar_section h3.filters-form-title[data-filter-extensions-title]", | ||
| count: 1, text: "Filters") | ||
| else | ||
| expect(page).to have_no_css("#filters_sidebar_section .filters-form-title") | ||
| expect(page).to have_css("#filters_sidebar_section h3", count: 1, text: "Filters") | ||
| end | ||
| end | ||
| end | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.