test(views): add arg for views without json format
This commit is contained in:
parent
fd564be0bc
commit
c21ddbba06
21 changed files with 51 additions and 39 deletions
|
@ -20,7 +20,7 @@ describe BillingSubscriptionsController, type: :controller do
|
|||
end
|
||||
|
||||
describe 'cancellation' do
|
||||
include_context :open_to_np_admin, :get, :cancellation, nonprofit_id: :__our_np
|
||||
include_context :open_to_np_admin, :get, :cancellation, nonprofit_id: :__our_np, without_json_view: true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -9,7 +9,7 @@ describe Campaigns::SupportersController, type: :controller do
|
|||
include_context :shared_user_context
|
||||
describe 'reject unauthorized' do
|
||||
describe 'index' do
|
||||
include_context :open_to_campaign_editor, :get, :index, nonprofit_id: :__our_np, campaign_id: :__our_campaign
|
||||
include_context :open_to_campaign_editor, :get, :index, nonprofit_id: :__our_np, campaign_id: :__our_campaign, without_json_view: true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -30,11 +30,11 @@ describe CampaignsController, type: :controller do
|
|||
end
|
||||
describe 'open to all' do
|
||||
describe 'index' do
|
||||
include_context :open_to_all, :get, :index, nonprofit_id: :__our_np
|
||||
include_context :open_to_all, :get, :index, nonprofit_id: :__our_np, without_json_view: true
|
||||
end
|
||||
|
||||
describe 'show' do
|
||||
include_context :open_to_all, :get, :show, nonprofit_id: :__our_np, id: :__our_campaign
|
||||
include_context :open_to_all, :get, :show, nonprofit_id: :__our_np, id: :__our_campaign, without_json_view: true
|
||||
end
|
||||
|
||||
describe 'activities' do
|
||||
|
@ -54,7 +54,7 @@ describe CampaignsController, type: :controller do
|
|||
end
|
||||
|
||||
describe 'peer_to_peer' do
|
||||
include_context :open_to_all, :get, :peer_to_peer, nonprofit_id: :__our_np
|
||||
include_context :open_to_all, :get, :peer_to_peer, nonprofit_id: :__our_np, without_json_view: true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -20,7 +20,7 @@ describe EventsController, type: :controller do
|
|||
include_context :open_to_event_editor, :delete, :soft_delete, nonprofit_id: :__our_np, event_id: :__our_event
|
||||
end
|
||||
describe 'stats' do
|
||||
include_context :open_to_event_editor, :get, :stats, nonprofit_id: :__our_np, id: :__our_event
|
||||
include_context :open_to_event_editor, :get, :stats, nonprofit_id: :__our_np, id: :__our_event, without_json_view: true
|
||||
end
|
||||
|
||||
describe 'name_and_id' do
|
||||
|
@ -30,7 +30,7 @@ describe EventsController, type: :controller do
|
|||
|
||||
describe 'open to all' do
|
||||
describe 'index' do
|
||||
include_context :open_to_all, :get, :index, nonprofit_id: :__our_np
|
||||
include_context :open_to_all, :get, :index, nonprofit_id: :__our_np, without_json_view: true
|
||||
end
|
||||
|
||||
describe 'listings' do
|
||||
|
@ -38,7 +38,7 @@ describe EventsController, type: :controller do
|
|||
end
|
||||
|
||||
describe 'show' do
|
||||
include_context :open_to_all, :get, :show, nonprofit_id: :__our_np, id: :__our_event
|
||||
include_context :open_to_all, :get, :show, nonprofit_id: :__our_np, id: :__our_event, without_json_view: true
|
||||
end
|
||||
|
||||
describe 'activities' do
|
||||
|
|
|
@ -9,21 +9,21 @@ describe MapsController, type: :controller do
|
|||
include_context :shared_user_context
|
||||
describe 'rejects unauthorized users' do
|
||||
describe 'all_supporters' do
|
||||
include_context :open_to_super_admin, :get, :all_supporters
|
||||
include_context :open_to_super_admin, :get, :all_supporters, without_json_view: true
|
||||
end
|
||||
|
||||
describe 'all_npo_supporters' do
|
||||
include_context :open_to_np_associate, :get, :all_npo_supporters, nonprofit_id: :__our_np
|
||||
include_context :open_to_np_associate, :get, :all_npo_supporters, nonprofit_id: :__our_np, without_json_view: true
|
||||
end
|
||||
|
||||
describe 'specific_npo_supporters' do
|
||||
include_context :open_to_np_associate, :get, :specific_npo_supporters, nonprofit_id: :__our_np
|
||||
include_context :open_to_np_associate, :get, :specific_npo_supporters, nonprofit_id: :__our_np, without_json_view: true
|
||||
end
|
||||
end
|
||||
|
||||
describe 'open_to_all' do
|
||||
describe 'all_npos' do
|
||||
include_context :open_to_all, :get, :all_npos, nonprofit_id: :__our_np
|
||||
include_context :open_to_all, :get, :all_npos, nonprofit_id: :__our_np, without_json_view: true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -12,7 +12,7 @@ describe Nonprofits::BankAccountsController, type: :controller do
|
|||
end
|
||||
|
||||
describe 'confirmation' do
|
||||
include_context :open_to_np_admin, :get, :confirmation, nonprofit_id: :__our_np
|
||||
include_context :open_to_np_admin, :get, :confirmation, nonprofit_id: :__our_np, without_json_view: true
|
||||
end
|
||||
|
||||
describe 'confirm' do
|
||||
|
@ -20,7 +20,7 @@ describe Nonprofits::BankAccountsController, type: :controller do
|
|||
end
|
||||
|
||||
describe 'cancellation' do
|
||||
include_context :open_to_np_admin, :get, :cancellation, nonprofit_id: :__our_np
|
||||
include_context :open_to_np_admin, :get, :cancellation, nonprofit_id: :__our_np, without_json_view: true
|
||||
end
|
||||
|
||||
describe 'cancel' do
|
||||
|
|
|
@ -12,15 +12,15 @@ describe Nonprofits::ButtonController, type: :controller do
|
|||
end
|
||||
|
||||
describe 'basic' do
|
||||
include_context :open_to_registered, :get, :basic, nonprofit_id: :__our_np
|
||||
include_context :open_to_registered, :get, :basic, nonprofit_id: :__our_np, without_json_view: true
|
||||
end
|
||||
|
||||
describe 'guided' do
|
||||
include_context :open_to_registered, :get, :guided, nonprofit_id: :__our_np
|
||||
include_context :open_to_registered, :get, :guided, nonprofit_id: :__our_np, without_json_view: true
|
||||
end
|
||||
|
||||
describe 'advanced' do
|
||||
include_context :open_to_registered, :get, :advanced, nonprofit_id: :__our_np
|
||||
include_context :open_to_registered, :get, :advanced, nonprofit_id: :__our_np, without_json_view: true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -8,7 +8,7 @@ describe Nonprofits::CardsController, type: :controller do
|
|||
include_context :shared_user_context
|
||||
describe 'rejects unauthenticated users' do
|
||||
describe 'show' do
|
||||
include_context :open_to_np_associate, :get, :edit, nonprofit_id: :__our_np
|
||||
include_context :open_to_np_associate, :get, :edit, nonprofit_id: :__our_np, without_json_view: true
|
||||
end
|
||||
|
||||
describe 'create' do
|
||||
|
|
|
@ -8,7 +8,7 @@ describe Nonprofits::CustomFieldMastersController, type: :controller do
|
|||
include_context :shared_user_context
|
||||
describe 'rejects unauthenticated users' do
|
||||
describe 'get payments' do
|
||||
include_context :open_to_np_associate, :get, :index, nonprofit_id: :__our_np
|
||||
include_context :open_to_np_associate, :get, :index, nonprofit_id: :__our_np, without_json_view: true
|
||||
end
|
||||
|
||||
describe 'create' do
|
||||
|
|
|
@ -8,7 +8,7 @@ describe Nonprofits::CustomFieldJoinsController, type: :controller do
|
|||
include_context :shared_user_context
|
||||
describe 'rejects unauthenticated users' do
|
||||
describe 'index' do
|
||||
include_context :open_to_np_associate, :get, :index, nonprofit_id: :__our_np, supporter_id: 1
|
||||
include_context :open_to_np_associate, :get, :index, nonprofit_id: :__our_np, supporter_id: 1, without_json_view: true
|
||||
end
|
||||
|
||||
describe 'modify' do
|
||||
|
|
|
@ -8,7 +8,7 @@ describe Nonprofits::PaymentsController, type: :controller do
|
|||
include_context :shared_user_context
|
||||
describe 'rejects unauthenticated users' do
|
||||
describe 'get payments' do
|
||||
include_context :open_to_np_associate, :get, :index, nonprofit_id: :__our_np
|
||||
include_context :open_to_np_associate, :get, :index, nonprofit_id: :__our_np, without_json_view: true
|
||||
end
|
||||
|
||||
describe 'export payments' do
|
||||
|
@ -16,7 +16,7 @@ describe Nonprofits::PaymentsController, type: :controller do
|
|||
end
|
||||
|
||||
describe 'show payments' do
|
||||
include_context :open_to_np_associate, :get, :show, nonprofit_id: :__our_np, id: '1'
|
||||
include_context :open_to_np_associate, :get, :show, nonprofit_id: :__our_np, id: '1', without_json_view: true
|
||||
end
|
||||
|
||||
describe 'update' do
|
||||
|
|
|
@ -12,7 +12,7 @@ describe Nonprofits::PayoutsController, type: :controller do
|
|||
end
|
||||
|
||||
describe 'index' do
|
||||
include_context :open_to_np_associate, :get, :index, nonprofit_id: :__our_np
|
||||
include_context :open_to_np_associate, :get, :index, nonprofit_id: :__our_np, without_json_view: true
|
||||
end
|
||||
|
||||
describe 'show' do
|
||||
|
|
|
@ -8,7 +8,7 @@ describe Nonprofits::RecurringDonationsController, type: :controller do
|
|||
include_context :shared_user_context
|
||||
describe 'rejects unauthenticated users' do
|
||||
describe 'index' do
|
||||
include_context :open_to_np_associate, :get, :index, nonprofit_id: :__our_np
|
||||
include_context :open_to_np_associate, :get, :index, nonprofit_id: :__our_np, without_json_view: true
|
||||
end
|
||||
|
||||
describe 'export' do
|
||||
|
@ -16,7 +16,7 @@ describe Nonprofits::RecurringDonationsController, type: :controller do
|
|||
end
|
||||
|
||||
describe 'show' do
|
||||
include_context :open_to_np_associate, :get, :show, nonprofit_id: :__our_np, id: '1'
|
||||
include_context :open_to_np_associate, :get, :show, nonprofit_id: :__our_np, id: '1', without_json_view: true
|
||||
end
|
||||
|
||||
describe 'destroy' do
|
||||
|
|
|
@ -8,7 +8,7 @@ describe Nonprofits::SupportersController, type: :controller do
|
|||
include_context :shared_user_context
|
||||
describe 'rejects unauthenticated users' do
|
||||
describe 'index' do
|
||||
include_context :open_to_np_associate, :get, :index, nonprofit_id: :__our_np
|
||||
include_context :open_to_np_associate, :get, :index, nonprofit_id: :__our_np, without_json_view: true
|
||||
end
|
||||
|
||||
describe 'index_metrics' do
|
||||
|
|
|
@ -13,7 +13,7 @@ describe NonprofitsController, type: :controller do
|
|||
end
|
||||
|
||||
describe 'dashboard' do
|
||||
include_context :open_to_np_associate, :get, :dashboard, id: :__our_np
|
||||
include_context :open_to_np_associate, :get, :dashboard, id: :__our_np, without_json_view: true
|
||||
end
|
||||
|
||||
describe 'dashboard_metrics' do
|
||||
|
@ -47,7 +47,7 @@ describe NonprofitsController, type: :controller do
|
|||
|
||||
describe 'open to all' do
|
||||
describe 'show' do
|
||||
include_context :open_to_all, :get, :show, id: :__our_np
|
||||
include_context :open_to_all, :get, :show, id: :__our_np, without_json_view: true
|
||||
end
|
||||
|
||||
describe 'create' do
|
||||
|
@ -55,11 +55,11 @@ describe NonprofitsController, type: :controller do
|
|||
end
|
||||
|
||||
describe 'btn' do
|
||||
include_context :open_to_all, :get, :btn, id: :__our_np
|
||||
include_context :open_to_all, :get, :btn, id: :__our_np, without_json_view: true
|
||||
end
|
||||
|
||||
describe 'supporter_form' do
|
||||
include_context :open_to_all, :get, :supporter_form, id: :__our_np
|
||||
include_context :open_to_all, :get, :supporter_form, id: :__our_np, without_json_view: true
|
||||
end
|
||||
|
||||
describe 'custom_supporter' do
|
||||
|
@ -67,7 +67,7 @@ describe NonprofitsController, type: :controller do
|
|||
end
|
||||
|
||||
describe 'donate' do
|
||||
include_context :open_to_all, :get, :donate, id: :__our_np
|
||||
include_context :open_to_all, :get, :donate, id: :__our_np, without_json_view: true
|
||||
end
|
||||
|
||||
describe 'search' do
|
||||
|
|
|
@ -13,17 +13,17 @@ describe ProfilesController, type: :controller do
|
|||
end
|
||||
|
||||
describe 'fundraisers' do
|
||||
include_context :open_to_profile_owner, :get, :fundraisers, id: :__our_profile
|
||||
include_context :open_to_profile_owner, :get, :fundraisers, id: :__our_profile, without_json_view: true
|
||||
end
|
||||
|
||||
describe 'donations_history' do
|
||||
include_context :open_to_profile_owner, :get, :donations_history, id: :__our_profile
|
||||
include_context :open_to_profile_owner, :get, :donations_history, id: :__our_profile, without_json_view: true
|
||||
end
|
||||
end
|
||||
|
||||
describe 'open to all' do
|
||||
describe 'show' do
|
||||
include_context :open_to_all, :get, :show, id: :__our_np
|
||||
include_context :open_to_all, :get, :show, id: :__our_np, without_json_view: true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -9,7 +9,7 @@ describe RecurringDonationsController, type: :controller do
|
|||
include_context :shared_user_context
|
||||
describe 'open to all (note: edit token is checked inside methods)' do
|
||||
describe 'edit' do
|
||||
include_context :open_to_all, :get, :edit, nonprofit_id: :__our_np, id: '1'
|
||||
include_context :open_to_all, :get, :edit, nonprofit_id: :__our_np, id: '1', without_json_view: true
|
||||
end
|
||||
|
||||
describe 'destroy' do
|
||||
|
|
|
@ -9,7 +9,7 @@ describe SettingsController, type: :controller do
|
|||
include_context :shared_user_context
|
||||
describe 'rejects unauthorized users' do
|
||||
describe 'index' do
|
||||
include_context :open_to_registered, :get, :index, nonprofit_id: :__our_np
|
||||
include_context :open_to_registered, :get, :index, nonprofit_id: :__our_np, without_json_view: true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -21,7 +21,7 @@ describe SuperAdminsController, type: :controller do
|
|||
end
|
||||
|
||||
describe 'index' do
|
||||
include_context :open_to_super_admin, :get, :index
|
||||
include_context :open_to_super_admin, :get, :index, without_json_view: true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -85,7 +85,8 @@ RSpec.shared_context :shared_user_context do
|
|||
end
|
||||
|
||||
def accept(user_to_signin, method, action, *args)
|
||||
without_json_response = %i[cancellation all_npos edit confirmation peer_to_peer advanced guided basic donations_history fundraisers donate supporter_form btn dashboard stats].include?(action)
|
||||
# TODO: Extract into method args verification
|
||||
without_json_response = method_has_json_view?(args)
|
||||
request.accept = 'application/json' unless without_json_response
|
||||
sign_in user_to_signin if user_to_signin
|
||||
# allows us to run the helpers but ignore what the controller action does
|
||||
|
@ -114,6 +115,17 @@ RSpec.shared_context :shared_user_context do
|
|||
{ params: args.reduce({}, :merge) }
|
||||
end
|
||||
|
||||
def method_has_json_view?(*args)
|
||||
args.collect do |items|
|
||||
if items.kind_of?(Array)
|
||||
items.each do |k, v|
|
||||
return k[:without_json_view] if k.kind_of?(Hash) && k[:without_json_view]
|
||||
end
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
def fix_args(*args)
|
||||
replacements = {
|
||||
__our_np: nonprofit.id,
|
||||
|
|
|
@ -9,7 +9,7 @@ describe TicketsController, type: :controller do
|
|||
include_context :shared_user_context
|
||||
describe 'rejects unauthorized users' do
|
||||
describe 'index' do
|
||||
include_context :open_to_event_editor, :get, :index, nonprofit_id: :__our_np, event_id: :__our_event
|
||||
include_context :open_to_event_editor, :get, :index, nonprofit_id: :__our_np, event_id: :__our_event, without_json_view: true
|
||||
end
|
||||
|
||||
describe 'update' do
|
||||
|
|
Loading…
Reference in a new issue