diff options
Diffstat (limited to 'spec/controllers')
-rw-r--r-- | spec/controllers/admin_request_controller_spec.rb | 40 | ||||
-rw-r--r-- | spec/controllers/admin_user_controller_spec.rb | 21 | ||||
-rw-r--r-- | spec/controllers/help_controller_spec.rb | 30 |
3 files changed, 91 insertions, 0 deletions
diff --git a/spec/controllers/admin_request_controller_spec.rb b/spec/controllers/admin_request_controller_spec.rb new file mode 100644 index 000000000..1e05465de --- /dev/null +++ b/spec/controllers/admin_request_controller_spec.rb @@ -0,0 +1,40 @@ +require File.dirname(__FILE__) + '/../spec_helper' + +describe AdminRequestController, "when administering requests" do + integrate_views + fixtures :info_requests, :outgoing_messages + + it "shows the index/list page" do + get :index + end + + it "shows a public body" do + get :show, :id => info_requests(:fancy_dog_request) + end + + it "edits a public body" do + get :edit, :id => info_requests(:fancy_dog_request) + end + + it "saves edits to a request" do + info_requests(:fancy_dog_request).title.should == "Why do you have such a fancy dog?" + post :update, { :id => info_requests(:fancy_dog_request), :info_request => { :title => "Renamed", :prominence => "normal", :described_state => "waiting_response", :awaiting_description => false } } + response.flash[:notice].should include('successful') + ir = InfoRequest.find(info_requests(:fancy_dog_request).id) + ir.title.should == "Renamed" + end + + it "edits an outgoing message" do + get :edit_outgoing, :id => outgoing_messages(:useless_outgoing_message) + end + + it "saves edits to an outgoing_message" do + outgoing_messages(:useless_outgoing_message).body.should include("fancy dog") + post :update_outgoing, { :id => outgoing_messages(:useless_outgoing_message), :outgoing_message => { :body => "Why do you have such a delicious cat?" } } + response.flash[:notice].should include('successful') + ir = OutgoingMessage.find(outgoing_messages(:useless_outgoing_message).id) + ir.body.should include("delicious cat") + end + +end + diff --git a/spec/controllers/admin_user_controller_spec.rb b/spec/controllers/admin_user_controller_spec.rb new file mode 100644 index 000000000..b3258b929 --- /dev/null +++ b/spec/controllers/admin_user_controller_spec.rb @@ -0,0 +1,21 @@ +require File.dirname(__FILE__) + '/../spec_helper' + +describe AdminUserController, "when administering users" do + integrate_views + fixtures :users + + it "shows the index/list page" do + get :index + end + + it "searches for 'bob'" do + get :list, :query => "bob" + assigns[:admin_users].should == [ users(:bob_smith_user) ] + end + + it "shows a user" do + get :show, :id => users(:bob_smith_user) + end + +end + diff --git a/spec/controllers/help_controller_spec.rb b/spec/controllers/help_controller_spec.rb new file mode 100644 index 000000000..2743c9c77 --- /dev/null +++ b/spec/controllers/help_controller_spec.rb @@ -0,0 +1,30 @@ +require File.dirname(__FILE__) + '/../spec_helper' + +describe HelpController, "when using help" do + integrate_views + + it "shows the about page" do + get :about + end + + it "shows contact form" do + get :contact + end + + it "sends a contact message" do + post :contact, { :contact => { + :name => "Vinny Vanilli", + :email => "vinny@localhost", + :subject => "Why do I have such an ace name?", + :message => "You really should know!!!\n\nVinny", + }, :submitted_contact_form => 1 + } + response.should redirect_to(:controller => 'general', :action => 'frontpage') + + deliveries = ActionMailer::Base.deliveries + deliveries.size.should == 1 + deliveries[0].body.should include("really should know") + end + +end + |