Skip to content

Commit

Permalink
Merge pull request #327 from projecthydra/no_render_views
Browse files Browse the repository at this point in the history
Don't use render_views when testing controllers
  • Loading branch information
carolyncole committed Feb 18, 2014
2 parents a1fbb49 + af9d2d7 commit 3f201ea
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 20 deletions.
15 changes: 6 additions & 9 deletions spec/controllers/batch_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 4 additions & 7 deletions spec/controllers/dashboard_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions spec/controllers/generic_files_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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('<span id="notify_number" class="overlay"> 1</span>') # notify should be 1 for failing job
@archivist.mailbox.inbox[0].messages[0].subject.should == "Failing Audit Run"
end
end
Expand Down
2 changes: 0 additions & 2 deletions spec/controllers/static_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -17,7 +16,6 @@
end

describe "#zotero" do
render_views
it "renders page" do
get "zotero"
response.should be_success
Expand Down
13 changes: 13 additions & 0 deletions spec/views/users/_notify_number.html.erb_spec.rb
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 3f201ea

Please sign in to comment.