Sha256: 39b4304d57b1b38e27f779151ce8b9cde02861fc174533e1f81cc65b97b51c8e

Contents?: true

Size: 1.46 KB

Versions: 11

Compression:

Stored size: 1.46 KB

Contents

require 'spec_helper'

describe BookmarksController do
  include Devise::TestHelpers
  
  # jquery 1.9 ajax does error callback if 200 returns empty body. so use 204 instead. 
  describe "update" do
    it "has a 204 status code when creating a new one" do
      xhr :put, :update, :id => '2007020969', :format => :js
      expect(response).to be_success
      expect(response.code).to eq "204"
    end
    
    it "has a 500 status code when fails is success" do
      @controller.stub_chain(:current_or_guest_user, :existing_bookmark_for).and_return(false)
      @controller.stub_chain(:current_or_guest_user, :persisted?).and_return(true)
      @controller.stub_chain(:current_or_guest_user, :bookmarks, :create).and_return(false)  
      xhr :put, :update, :id => 'iamabooboo', :format => :js
      expect(response.code).to eq "500"
    end
  end
  
  describe "delete" do
    it "has a 204 status code when delete is success" do
      xhr :delete, :destroy, :id => '2007020969', :format => :js
      expect(response).to be_success
      expect(response.code).to eq "204"
    end

   it "has a 500 status code when delete is not success" do
      bm = double(Bookmark)
      @controller.stub_chain(:current_or_guest_user, :existing_bookmark_for).and_return(bm)
      @controller.stub_chain(:current_or_guest_user, :bookmarks, :delete).and_return(false)
     
      xhr :delete, :destroy, :id => 'pleasekillme', :format => :js

      expect(response.code).to eq "500"
    end
  end
  
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
blacklight-5.3.0 spec/controllers/bookmarks_controller_spec.rb
blacklight-5.0.3 spec/controllers/bookmarks_controller_spec.rb
blacklight-5.1.1 spec/controllers/bookmarks_controller_spec.rb
blacklight-5.2.0 spec/controllers/bookmarks_controller_spec.rb
blacklight-5.1.0 spec/controllers/bookmarks_controller_spec.rb
blacklight-5.0.2 spec/controllers/bookmarks_controller_spec.rb
blacklight-5.0.1 spec/controllers/bookmarks_controller_spec.rb
blacklight-5.0.0 spec/controllers/bookmarks_controller_spec.rb
blacklight-5.0.0.pre4 spec/controllers/bookmarks_controller_spec.rb
blacklight-5.0.0.pre3 spec/controllers/bookmarks_controller_spec.rb
blacklight-5.0.0.pre2 spec/controllers/bookmarks_controller_spec.rb