Skip to content

Commit af93a3e

Browse files
authored
Merge pull request #548 from alphagov/add-gathering-support-page
Add gathering support page
2 parents 9f92255 + 8e6c635 commit af93a3e

33 files changed

Lines changed: 106 additions & 59 deletions

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ cache:
55
directories:
66
- /home/travis/.phantomjs
77
rvm:
8-
- 2.2.4
8+
- 2.2.5
99
services:
1010
- memcached
1111
before_install:

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ group :development, :test do
4848
gem 'rspec-rails'
4949
gem 'jasmine-rails'
5050
gem 'pry'
51-
gem 'phantomjs', '~> 1.9.7.0'
51+
gem 'phantomjs', '~> 2.1.1.0'
5252
end
5353

5454
group :test do

Gemfile.lock

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,8 @@ GEM
143143
hashdiff (0.2.3)
144144
i18n (0.7.0)
145145
ipaddress (0.8.2)
146-
jasmine-core (2.3.4)
147-
jasmine-rails (0.12.2)
146+
jasmine-core (2.5.2)
147+
jasmine-rails (0.14.1)
148148
jasmine-core (>= 1.3, < 3.0)
149149
phantomjs (>= 1.9)
150150
railties (>= 3.2.0)
@@ -177,26 +177,24 @@ GEM
177177
mime-types (2.99.2)
178178
mimemagic (0.3.0)
179179
mini_portile2 (2.1.0)
180-
minitest (5.9.0)
180+
minitest (5.9.1)
181181
multi_json (1.11.2)
182182
multi_test (0.1.2)
183183
multipart-post (2.0.0)
184184
net-http-persistent (2.9.4)
185-
nokogiri (1.6.8)
185+
nokogiri (1.6.8.1)
186186
mini_portile2 (~> 2.1.0)
187-
pkg-config (~> 1.1.7)
188187
paperclip (4.3.2)
189188
activemodel (>= 3.2.0)
190189
activesupport (>= 3.2.0)
191190
cocaine (~> 0.5.5)
192191
mime-types
193192
mimemagic (= 0.3.0)
194193
pg (0.18.4)
195-
phantomjs (1.9.7.1)
194+
phantomjs (2.1.1.0)
196195
pickle (0.5.1)
197196
cucumber (>= 0.8)
198197
rake
199-
pkg-config (1.1.7)
200198
poltergeist (1.8.0)
201199
capybara (~> 2.1)
202200
cliver (~> 0.3.1)
@@ -236,7 +234,7 @@ GEM
236234
activesupport (= 4.2.7.1)
237235
rake (>= 0.8.7)
238236
thor (>= 0.18.1, < 2.0)
239-
rake (11.2.2)
237+
rake (11.3.0)
240238
request_store (1.2.1)
241239
responders (2.1.0)
242240
railties (>= 4.2.0, < 5)
@@ -275,7 +273,7 @@ GEM
275273
sprockets (3.7.0)
276274
concurrent-ruby (~> 1.0)
277275
rack (> 1, < 3)
278-
sprockets-rails (3.1.1)
276+
sprockets-rails (3.2.0)
279277
actionpack (>= 4.0)
280278
activesupport (>= 4.0)
281279
sprockets (>= 3.0.0)
@@ -339,7 +337,7 @@ DEPENDENCIES
339337
nokogiri
340338
paperclip
341339
pg
342-
phantomjs (~> 1.9.7.0)
340+
phantomjs (~> 2.1.1.0)
343341
pickle
344342
poltergeist
345343
pry
@@ -359,4 +357,4 @@ DEPENDENCIES
359357
will_paginate
360358

361359
BUNDLED WITH
362-
1.11.2
360+
1.13.5

app/controllers/petitions_controller.rb

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ class PetitionsController < ApplicationController
44
before_action :avoid_unknown_state_filters, only: :index
55
before_action :do_not_cache, except: %i[index show]
66

7-
before_action :retrieve_petition, only: [:show, :count, :moderation_info]
8-
before_action :redirect_to_moderation_info_url, if: :not_moderated?, only: :show
9-
before_action :redirect_to_petition_url, if: :moderated?, only: :moderation_info
7+
before_action :retrieve_petition, only: [:show, :count, :gathering_support, :moderation_info]
8+
before_action :redirect_to_gathering_support_url, if: :collecting_sponsors?, only: [:moderation_info, :show]
9+
before_action :redirect_to_moderation_info_url, if: :in_moderation?, only: [:gathering_support, :show]
10+
before_action :redirect_to_petition_url, if: :moderated?, only: [:gathering_support, :moderation_info]
1011

1112
before_action :set_cors_headers, only: [:index, :show, :count], if: :json_request?
1213

@@ -91,8 +92,16 @@ def avoid_unknown_state_filters
9192
redirect_to url_for(params.merge(state: 'all')) unless public_petition_facets.include? params[:state].to_sym
9293
end
9394

94-
def not_moderated?
95-
!@petition.moderated?
95+
def collecting_sponsors?
96+
@petition.collecting_sponsors?
97+
end
98+
99+
def redirect_to_gathering_support_url
100+
redirect_to gathering_support_petition_url(@petition)
101+
end
102+
103+
def in_moderation?
104+
@petition.in_moderation?
96105
end
97106

98107
def redirect_to_moderation_info_url

app/jobs/application_job.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
class ApplicationJob < ActiveJob::Base
2+
before_perform :reload_site
3+
4+
private
5+
6+
def reload_site
7+
Site.reload
8+
end
9+
end

app/jobs/close_petitions_job.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
class ClosePetitionsJob < ActiveJob::Base
1+
class ClosePetitionsJob < ApplicationJob
22
queue_as :high_priority
33

44
def perform(time)

app/jobs/debated_petitions_job.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
class DebatedPetitionsJob < ActiveJob::Base
1+
class DebatedPetitionsJob < ApplicationJob
22
queue_as :high_priority
33

44
def perform(date)

app/jobs/deliver_debate_outcome_email_job.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
class DeliverDebateOutcomeEmailJob < ActiveJob::Base
1+
class DeliverDebateOutcomeEmailJob < ApplicationJob
22
include EmailDelivery
33

44
def create_email

app/jobs/deliver_debate_scheduled_email_job.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
class DeliverDebateScheduledEmailJob < ActiveJob::Base
1+
class DeliverDebateScheduledEmailJob < ApplicationJob
22
include EmailDelivery
33

44
def create_email

app/jobs/deliver_petition_email_job.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
class DeliverPetitionEmailJob < ActiveJob::Base
1+
class DeliverPetitionEmailJob < ApplicationJob
22
include EmailDelivery
33

44
attr_reader :email

0 commit comments

Comments
 (0)