aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/controllers/info_request_batch_controller.rb4
-rw-r--r--app/controllers/request_controller.rb2
-rw-r--r--app/views/info_request_batch/show.html.erb10
-rw-r--r--spec/controllers/info_request_batch_controller_spec.rb32
4 files changed, 46 insertions, 2 deletions
diff --git a/app/controllers/info_request_batch_controller.rb b/app/controllers/info_request_batch_controller.rb
index 1e1030b53..f76f7abc2 100644
--- a/app/controllers/info_request_batch_controller.rb
+++ b/app/controllers/info_request_batch_controller.rb
@@ -2,6 +2,10 @@ class InfoRequestBatchController < ApplicationController
def show
@info_request_batch = InfoRequestBatch.find(params[:id])
+ @per_page = 25
+ @page = get_search_page_from_params
+ @info_requests = @info_request_batch.info_requests.all(:offset => (@page - 1) * @per_page,
+ :limit => @per_page)
end
end
diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb
index b9be333c8..e516501d4 100644
--- a/app/controllers/request_controller.rb
+++ b/app/controllers/request_controller.rb
@@ -226,8 +226,6 @@ class RequestController < ApplicationController
return render_new_preview
end
- # TODO: give messages about bodies
- # that are no longer requestable
@info_request_batch = InfoRequestBatch.create!(:title => params[:info_request][:title],
:body => params[:outgoing_message][:body],
:user => authenticated_user)
diff --git a/app/views/info_request_batch/show.html.erb b/app/views/info_request_batch/show.html.erb
new file mode 100644
index 000000000..02583a9b5
--- /dev/null
+++ b/app/views/info_request_batch/show.html.erb
@@ -0,0 +1,10 @@
+<% @title = _("Batch request") %>
+<h1><%= @title %></h1>
+<div class="results_section">
+ <div class="results_block">
+ <% @info_requests.each do |info_request| %>
+ <%= render :partial => 'request/request_listing_via_event', :locals => { :event => info_request.last_event_forming_initial_request, :info_request => info_request } %>
+ <% end %>
+ </div>
+ <%= will_paginate WillPaginate::Collection.new(@page, @per_page, @info_request_batch.info_requests.count) %>
+</div>
diff --git a/spec/controllers/info_request_batch_controller_spec.rb b/spec/controllers/info_request_batch_controller_spec.rb
new file mode 100644
index 000000000..b5075c4e0
--- /dev/null
+++ b/spec/controllers/info_request_batch_controller_spec.rb
@@ -0,0 +1,32 @@
+# coding: utf-8
+require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
+
+describe InfoRequestBatchController, "when showing a request" do
+
+ before do
+ @info_request_batch = FactoryGirl.create(:info_request_batch, :title => 'Matched title',
+ :body => 'Matched body')
+ @first_request = FactoryGirl.create(:info_request, :info_request_batch => @info_request_batch)
+ @second_request = FactoryGirl.create(:info_request, :info_request_batch => @info_request_batch)
+ @default_params = {:id => @info_request_batch.id}
+ end
+
+ def make_request(params=@default_params)
+ get :show, params
+ end
+
+ it 'should be successful' do
+ make_request
+ response.should be_success
+ end
+
+ it 'should assign info_requests to the view' do
+ make_request
+ assigns[:info_requests].should == [@first_request, @second_request]
+ end
+
+ it 'should assign an info_request_batch to the view' do
+ make_request
+ assigns[:info_request_batch].should == @info_request_batch
+ end
+end