This repository has been archived by the owner on Mar 27, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #384 from SumOfUs/hallway-mods
[Pre-deploy] Modifications from hallway tests
- Loading branch information
Showing
27 changed files
with
207 additions
and
31 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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,33 @@ | ||
module LayoutSelectHelper | ||
|
||
def construct_layout_select_class(liquid_layout, page, field) | ||
hidden = check_hidden(liquid_layout, field) | ||
active = check_active(liquid_layout, page, field) | ||
post_action_layout = liquid_layout.post_action_layout ? 'post-action-layout' : '' | ||
primary_layout = liquid_layout.primary_layout ? 'primary-layout' : '' | ||
"#{hidden} #{active} #{primary_layout} #{post_action_layout}" | ||
end | ||
|
||
def specify_layout_types(field) | ||
(field == :liquid_layout_id) ? 'primary' : 'follow-up' | ||
end | ||
|
||
private | ||
|
||
def check_hidden(liquid_layout, field) | ||
if field == :liquid_layout_id | ||
return 'hidden' unless liquid_layout.primary_layout | ||
elsif field == :follow_up_liquid_layout_id | ||
return 'hidden' unless liquid_layout.post_action_layout | ||
end | ||
'' | ||
end | ||
|
||
def check_active(liquid_layout, page, field) | ||
if field == :follow_up_liquid_layout_id && page.follow_up_plan.to_sym == :with_page | ||
return '' # the redirect option will be the active one in this case | ||
end | ||
# page.send(field) calls either page.liquid_layout_id or page.follow_up_liquid_layout_id | ||
liquid_layout.id == page.send(field) ? 'active' : '' | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class AddDefaultFollowUpLayoutId < ActiveRecord::Migration | ||
def change | ||
add_reference :liquid_layouts, :default_follow_up_layout | ||
end | ||
end |
6 changes: 6 additions & 0 deletions
6
db/migrate/20160218175900_add_primary_and_post_action_columns.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,6 @@ | ||
class AddPrimaryAndPostActionColumns < ActiveRecord::Migration | ||
def change | ||
add_column :liquid_layouts, :primary_layout, :boolean | ||
add_column :liquid_layouts, :post_action_layout, :boolean | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
namespace :champaign do | ||
|
||
desc "Associate liquid layouts known to be petition or donation forms with their default post-action layouts" | ||
task associate_layouts: :environment do | ||
puts "Associating petition and donation layouts with default post action layouts" | ||
|
||
post_petition_share = LiquidLayout.find_by(title: "Post Petition Share") | ||
post_donation_share = LiquidLayout.find_by(title: "Post Donation Share") | ||
|
||
petition_layouts = LiquidLayout.where(title: ["Petition With Large Image", "Petition With Small Image"]) | ||
donation_layouts = LiquidLayout.where(title: ["Fundraiser With Large Image", "Fundraiser With Small Image"]) | ||
|
||
#Associate petition_layouts and donation_layouts with their desired default follow up layouts: | ||
petition_layouts.each do |layout| | ||
layout.update_attributes({ | ||
primary_layout: true, | ||
post_action_layout: false, | ||
default_follow_up_layout: post_petition_share}) | ||
layout.save | ||
end | ||
|
||
donation_layouts.each do |layout| | ||
layout.update_attributes({ | ||
primary_layout: true, | ||
post_action_layout: false, | ||
default_follow_up_layout: post_donation_share}) | ||
layout.save | ||
end | ||
|
||
#For post_petition_share and post_donation_share, update primary_layout and post_action_layout | ||
[post_petition_share, post_donation_share].each do |share_layout| | ||
share_layout.update_attributes({ | ||
primary_layout: false, | ||
post_action_layout: true | ||
}) | ||
end | ||
|
||
puts "Finished default follow-up layout associations." | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
require 'rails_helper' | ||
|
||
describe "pages" do | ||
let(:english) { create :language } | ||
let(:page_params) { { title: 'Away we go!', language_id: english.id } } | ||
|
||
describe 'POST create' do | ||
it 'has the right follow-up url if liquid layout has a default follow-up url' do | ||
follow_up_layout = create :liquid_layout, default_follow_up_layout: nil | ||
liquid_layout = create :liquid_layout, default_follow_up_layout: follow_up_layout | ||
expect { | ||
post pages_path, page: page_params.merge(liquid_layout_id: liquid_layout.id) | ||
}.to change{ Page.count }.by 1 | ||
page = Page.last | ||
expect(PageFollower.new_from_page(page).follow_up_path).to eq "/a/#{page.slug}/follow-up" | ||
end | ||
|
||
it 'has a blank follow-up url if liquid layout has no default follow-up url' do | ||
liquid_layout = create :liquid_layout, default_follow_up_layout: nil | ||
expect { | ||
post pages_path, page: page_params.merge(liquid_layout_id: liquid_layout.id) | ||
}.to change{ Page.count }.by 1 | ||
page = Page.last | ||
expect(PageFollower.new_from_page(page).follow_up_path).to be_nil | ||
end | ||
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