Move campaigns/index.json to jbuilder
This commit is contained in:
parent
26be1858d3
commit
d81c3e5ec8
4 changed files with 15 additions and 11 deletions
7
app/views/campaigns/index.jbuilder
Normal file
7
app/views/campaigns/index.jbuilder
Normal file
|
@ -0,0 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||
json.data @campaigns do |campaign|
|
||||
json.extract! campaign, :name, :total_raised, :goal_amount, :id
|
||||
json.url campaign_locateable_url(campaign)
|
||||
end
|
|
@ -1,9 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||
object false
|
||||
|
||||
child @campaigns => :data do
|
||||
collection @campaigns, object_root: false
|
||||
attributes :name, :total_raised, :goal_amount, :url, :id
|
||||
end
|
|
@ -230,7 +230,7 @@ Rails.application.routes.draw do
|
|||
|
||||
# Campaigns
|
||||
match 'campaigns' => 'campaigns#index', via: %i[get post]
|
||||
match 'campaigns/:campaign_slug' => 'campaigns#show', via: %i[get post]
|
||||
match 'campaigns/:campaign_slug' => 'campaigns#show', via: %i[get post], as: :campaign_location
|
||||
match 'campaigns/:campaign_slug/supporters' => 'campaigns/supporters#index', via: %i[get post]
|
||||
|
||||
|
||||
|
@ -245,6 +245,12 @@ Rails.application.routes.draw do
|
|||
end
|
||||
end
|
||||
|
||||
direct :campaign_locateable do |model|
|
||||
nonprofit = model.nonprofit
|
||||
{controller: 'campaigns', action: "show", state_code: nonprofit.state_code_slug, city: nonprofit.city_slug, name: nonprofit.slug,
|
||||
campaign_slug: model.slug}
|
||||
end
|
||||
|
||||
# Misc
|
||||
get '/pages/wp-plugin', to: redirect('/help/wordpress-plugin') # temporary, until WP plugin updated
|
||||
|
||||
|
|
|
@ -85,7 +85,7 @@ describe CampaignsController, type: :controller do
|
|||
name: 'simplename',
|
||||
total_raised: 0,
|
||||
goal_amount: 444,
|
||||
url: "/nm/albuquerque/new-mexico-equality/campaigns/slug_#{campaign.id}"
|
||||
url: "http://test.host/nm/albuquerque/new-mexico-equality/campaigns/slug_#{campaign.id}"
|
||||
}]}.with_indifferent_access)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue