Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#1682] Extract "just made a request" notice to partial #2078

Merged
merged 2 commits into from
Jan 13, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 3 additions & 14 deletions app/controllers/request_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ def show
@track_thing = TrackThing.create_track_for_request(@info_request)
@feed_autodetect = [ { :url => do_track_url(@track_thing, 'feed'), :title => @track_thing.params[:title_in_rss], :has_json => true } ]


respond_to do |format|
format.html { @has_json = true; render :template => 'request/show'}
format.json { render :json => @info_request.json_for_api(true) }
Expand Down Expand Up @@ -245,13 +244,8 @@ def new_batch
:body => params[:outgoing_message][:body],
:public_bodies => @public_bodies,
:user => authenticated_user)
flash[:notice] = _("<p>Your {{law_used_full}} requests will be <strong>sent</strong> shortly!</p>
<p><strong>We will email you</strong> when they have been sent.
We will also email you when there is a response to any of them, or after {{late_number_of_days}} working days if the authorities still haven't
replied by then.</p>
<p>If you write about these requests (for example in a forum or a blog) please link to this page.</p>",
:law_used_full=>@info_request.law_used_full,
:late_number_of_days => AlaveteliConfiguration::reply_late_after_days)

flash[:batch_sent] = true
redirect_to info_request_batch_path(@info_request_batch)
end

Expand Down Expand Up @@ -379,12 +373,7 @@ def new
)
end

flash[:notice] = _("<p>Your {{law_used_full}} request has been <strong>sent on its way</strong>!</p>
<p><strong>We will email you</strong> when there is a response, or after {{late_number_of_days}} working days if the authority still hasn't
replied by then.</p>
<p>If you write about this request (for example in a forum or a blog) please link to this page, and add an
annotation below telling people about your writing.</p>",:law_used_full=>@info_request.law_used_full,
:late_number_of_days => AlaveteliConfiguration::reply_late_after_days)
flash[:request_sent] = true
redirect_to show_new_request_path(:url_title => @info_request.url_title)
end

Expand Down
18 changes: 18 additions & 0 deletions app/views/info_request_batch/_batch_sent.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<div id="notice">
<p>
<%= _("Your requests will be <strong>sent</strong> shortly!") %>
</p>

<p>
<%= _("<strong>We will email you</strong> when they have been sent. " \
"We will also email you when there is a response to any of them, or " \
"after {{late_number_of_days}} working days if the authorities still" \
"haven't replied by then.",
:late_number_of_days => AlaveteliConfiguration::reply_late_after_days) %>
</p>

<p>
<%= _("If you write about these requests (for example in a forum or a blog) " \
"please link to this page.") %>
</p>
</div>
5 changes: 5 additions & 0 deletions app/views/info_request_batch/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
<% @title = _("{{title}} - a batch request", :title => @info_request_batch.title) %>

<% if flash[:batch_sent] %>
<%= render :partial => 'batch_sent' } %>
<% end %>

<div class="info_request_batch_intro">
<h1><%= @title %></h1>
<% if @info_request_batch.sent_at %>
Expand Down
19 changes: 19 additions & 0 deletions app/views/request/_request_sent.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<div id="notice">
<p>
<%= _("Your {{law_used_full}} request has been <strong>sent on its way</strong>!",
:law_used_full => @info_request.law_used_full) %>
</p>

<p>
<%= _("<strong>We will email you</strong> when there is a response, or after " \
"{{late_number_of_days}} working days if the authority still hasn't " \
"replied by then.",
:late_number_of_days => AlaveteliConfiguration.reply_late_after_days) %>
</p>

<p>
<%= _("If you write about this request (for example in a forum or a blog) " \
"please link to this page, and add an annotation below telling people " \
"about your writing.") %>
</p>
</div>
5 changes: 5 additions & 0 deletions app/views/request/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
:title => h(@info_request.title),
:public_body => (@info_request.public_body.name)) %>

<% if flash[:request_sent] %>
<%= render :partial => 'request_sent',
:locals => { :info_request => @info_request } %>
<% end %>

<% if @info_request.prominence == 'hidden' %>
<p id="hidden_request">
<%= _('This request has prominence \'hidden\'. You can only see it because you are logged
Expand Down
15 changes: 12 additions & 3 deletions spec/controllers/request_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1073,6 +1073,16 @@ def expect_hidden(hidden_template)
response.redirect_url.should =~ /request\/why_is_your_quango_called_gerald\/new$/
end

it "sets the request_sent flash to true if successful" do
session[:user_id] = @user.id
post :new, :info_request => { :public_body_id => @body.id,
:title => "Why is your quango called Geraldine?", :tag_string => "" },
:outgoing_message => { :body => "This is a silly letter. It is too short to be interesting." },
:submitted_new_request => 1, :preview => 0

expect(flash[:request_sent]).to be_true
end

it "should give an error if the same request is submitted twice" do
session[:user_id] = @user.id

Expand Down Expand Up @@ -2554,10 +2564,9 @@ def make_request
assigns[:existing_batch].should_not be_nil
end

it 'should display a success notice' do
it 'sets the batch_sent flash to true' do
make_request
notice_text = "<p>Your Freedom of Information requests will be <strong>sent</strong> shortly!"
flash[:notice].should match notice_text
expect(flash[:batch_sent]).to be_true
end

end
Expand Down