-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This allows to limit route actions such as :index and :show in routes.rb and only display these routes in views.
- Loading branch information
1 parent
969a062
commit 4ac1521
Showing
20 changed files
with
168 additions
and
42 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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 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 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
4 changes: 4 additions & 0 deletions
4
spec/example_app/app/controllers/admin/payments_controller.rb
This file contains 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,4 @@ | ||
module Admin | ||
class PaymentsController < Admin::ApplicationController | ||
end | ||
end |
This file contains 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,16 @@ | ||
require "administrate/base_dashboard" | ||
|
||
class PaymentDashboard < Administrate::BaseDashboard | ||
ATTRIBUTE_TYPES = { | ||
id: Field::Number, | ||
created_at: Field::DateTime, | ||
updated_at: Field::DateTime, | ||
order: Field::BelongsTo, | ||
} | ||
|
||
COLLECTION_ATTRIBUTES = [ | ||
:id, | ||
] | ||
|
||
SHOW_PAGE_ATTRIBUTES = ATTRIBUTE_TYPES.keys | ||
end |
This file contains 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,3 @@ | ||
class Payment < ActiveRecord::Base | ||
belongs_to :order | ||
end |
This file contains 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
8 changes: 8 additions & 0 deletions
8
spec/example_app/db/migrate/20160815100728_create_payments.rb
This file contains 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,8 @@ | ||
class CreatePayments < ActiveRecord::Migration | ||
def change | ||
create_table :payments do |t| | ||
t.references :order, index: true | ||
end | ||
add_foreign_key :payments, :orders | ||
end | ||
end |
This file contains 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 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 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 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 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,40 @@ | ||
require "rails_helper" | ||
|
||
feature "payment index page" do | ||
scenario "user views payment attributes" do | ||
payment = create(:payment) | ||
|
||
visit admin_payments_path | ||
|
||
expect(page).to have_header("Payments") | ||
expect(page).to have_content(payment.id) | ||
end | ||
|
||
scenario "user clicks through to the payment show page", :js do | ||
payment = create(:payment) | ||
|
||
visit admin_payments_path | ||
click_row_for(payment) | ||
|
||
expect(page).to have_header(displayed(payment)) | ||
end | ||
|
||
scenario "user cannot click through to the edit page" do | ||
create(:payment) | ||
|
||
visit admin_payments_path | ||
expect(page).not_to have_button t("administrate.actions.edit") | ||
end | ||
|
||
scenario "user cannot click through to the new page" do | ||
visit admin_payments_path | ||
expect(page).not_to have_button "New payment" | ||
end | ||
|
||
scenario "user cannot delete record" do | ||
create(:payment) | ||
|
||
visit admin_payments_path | ||
expect(page).not_to have_button t("administrate.actions.destroy") | ||
end | ||
end |
This file contains 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,17 @@ | ||
require "rails_helper" | ||
|
||
feature "payment show page" do | ||
scenario "user cannot click through to the edit page" do | ||
payment = create(:payment) | ||
|
||
visit admin_payment_path(payment) | ||
expect(page).not_to have_button t("administrate.actions.edit") | ||
end | ||
|
||
scenario "user cannot delete record" do | ||
payment = create(:payment) | ||
|
||
visit admin_payment_path(payment) | ||
expect(page).not_to have_button t("administrate.actions.destroy") | ||
end | ||
end |