Sha256: cf818fc2c12d43b6dc8413b9070500fe63215fdecf9b77893964e7c9d0caf124
Contents?: true
Size: 1.9 KB
Versions: 4
Compression:
Stored size: 1.9 KB
Contents
require 'spec_helper' describe BookmarksController do # 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 allow(@controller).to receive_message_chain(:current_or_guest_user, :existing_bookmark_for).and_return(false) allow(@controller).to receive_message_chain(:current_or_guest_user, :persisted?).and_return(true) allow(@controller).to receive_message_chain(:current_or_guest_user, :bookmarks, :where, :exists?).and_return(false) allow(@controller).to receive_message_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 before do @controller.send(:current_or_guest_user).save @controller.send(:current_or_guest_user).bookmarks.create! document_id: '2007020969', document_type: "SolrDocument" end 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) allow(@controller).to receive_message_chain(:current_or_guest_user, :existing_bookmark_for).and_return(bm) allow(@controller).to receive_message_chain(:current_or_guest_user, :bookmarks, :where, :first).and_return(double('bookmark', delete: nil, destroyed?: false)) xhr :delete, :destroy, :id => 'pleasekillme', :format => :js expect(response.code).to eq "500" end end end
Version data entries
4 entries across 4 versions & 1 rubygems