From af9d2d78b979f9ddbede26a90a829579154ba426 Mon Sep 17 00:00:00 2001 From: Justin Coyne Date: Tue, 18 Feb 2014 11:14:28 -0600 Subject: [PATCH] Don't use render_views when testing controllers --- spec/controllers/batch_controller_spec.rb | 15 ++++++--------- spec/controllers/dashboard_controller_spec.rb | 11 ++++------- spec/controllers/generic_files_controller_spec.rb | 2 -- spec/controllers/static_controller_spec.rb | 2 -- spec/views/users/_notify_number.html.erb_spec.rb | 13 +++++++++++++ 5 files changed, 23 insertions(+), 20 deletions(-) create mode 100644 spec/views/users/_notify_number.html.erb_spec.rb diff --git a/spec/controllers/batch_controller_spec.rb b/spec/controllers/batch_controller_spec.rb index ff60dcb586..7986992f92 100644 --- a/spec/controllers/batch_controller_spec.rb +++ b/spec/controllers/batch_controller_spec.rb @@ -39,15 +39,12 @@ Sufia.queue.should_receive(:push).with(s1).once post :update, :id=>@batch.pid, "generic_file"=>{"read_groups_string"=>"", "read_users_string"=>"archivist1, archivist2", "tag"=>[""]} end - describe "when views are shown" do - render_views - it "should show flash messages" do - post :update, :id=>@batch.pid, "generic_file"=>{"read_groups_string"=>"","read_users_string"=>"archivist1, archivist2", "tag"=>[""]} - response.should redirect_to @routes.url_helpers.dashboard_index_path - flash[:notice].should_not be_nil - flash[:notice].should_not be_empty - flash[:notice].should include("Your files are being processed") - end + it "should show flash messages" do + post :update, :id=>@batch.pid, "generic_file"=>{"read_groups_string"=>"","read_users_string"=>"archivist1, archivist2", "tag"=>[""]} + response.should redirect_to @routes.url_helpers.dashboard_index_path + flash[:notice].should_not be_nil + flash[:notice].should_not be_empty + flash[:notice].should include("Your files are being processed") end describe "when user has edit permissions on a file" do diff --git a/spec/controllers/dashboard_controller_spec.rb b/spec/controllers/dashboard_controller_spec.rb index d32e3c277d..cd7b980626 100644 --- a/spec/controllers/dashboard_controller_spec.rb +++ b/spec/controllers/dashboard_controller_spec.rb @@ -70,13 +70,10 @@ assigns(:result_set_size).should eql(editable_docs_response["response"]["numFound"]) assigns(:document_list).each {|doc| doc.should be_kind_of SolrDocument} end - context "with render views" do - render_views - it "should paginate" do - xhr :get, :index, per_page: 2 - response.should be_success - response.should render_template('dashboard/index') - end + it "should paginate" do + xhr :get, :index, per_page: 2 + response.should be_success + response.should render_template('dashboard/index') end end end diff --git a/spec/controllers/generic_files_controller_spec.rb b/spec/controllers/generic_files_controller_spec.rb index 5b53e50d38..61009cc57f 100644 --- a/spec/controllers/generic_files_controller_spec.rb +++ b/spec/controllers/generic_files_controller_spec.rb @@ -438,7 +438,6 @@ flash[:alert].should be_nil end describe "failing audit" do - render_views before do ActiveFedora::RelsExtDatastream.any_instance.stub(:dsChecksumValid).and_return(false) @archivist = FactoryGirl.find_or_create(:archivist) @@ -449,7 +448,6 @@ AuditJob.new(@file.pid, @ds[0], @ds[1].versionID).run get :show, id:"test5" assigns[:notify_number].should == 1 - response.body.should include(' 1') # notify should be 1 for failing job @archivist.mailbox.inbox[0].messages[0].subject.should == "Failing Audit Run" end end diff --git a/spec/controllers/static_controller_spec.rb b/spec/controllers/static_controller_spec.rb index 29d5ef3be3..fdb6b2917b 100644 --- a/spec/controllers/static_controller_spec.rb +++ b/spec/controllers/static_controller_spec.rb @@ -3,7 +3,6 @@ describe StaticController do routes { Sufia::Engine.routes } describe "#mendeley" do - render_views it "renders page" do get "mendeley" response.should be_success @@ -17,7 +16,6 @@ end describe "#zotero" do - render_views it "renders page" do get "zotero" response.should be_success diff --git a/spec/views/users/_notify_number.html.erb_spec.rb b/spec/views/users/_notify_number.html.erb_spec.rb new file mode 100644 index 0000000000..f6d8a0a9d3 --- /dev/null +++ b/spec/views/users/_notify_number.html.erb_spec.rb @@ -0,0 +1,13 @@ +require 'spec_helper' + +describe 'users/_notify_number.html.erb' do + + it "should draw user list" do + assign :notify_number, 8 + render + page = Capybara::Node::Simple.new(rendered) + expect(page).to have_selector("span#notify_number.overlay", text: ' 8') + end + +end +