|
3 | 3 | describe BookmarksController do |
4 | 4 | # jquery 1.9 ajax does error callback if 200 returns empty body. so use 204 instead. |
5 | 5 | describe "update" do |
6 | | - it "has a 204 status code when creating a new one" do |
| 6 | + it "has a 200 status code when creating a new one" do |
7 | 7 | xhr :put, :update, :id => '2007020969', :format => :js |
8 | 8 | expect(response).to be_success |
9 | | - expect(response.code).to eq "204" |
| 9 | + expect(response.code).to eq "200" |
| 10 | + expect(JSON.parse(response.body)["bookmarks"]["count"]).to eq 1 |
10 | 11 | end |
11 | 12 |
|
12 | | - it "has a 500 status code when fails is success" do |
| 13 | + it "has a 500 status code when create is not success" do |
13 | 14 | allow(@controller).to receive_message_chain(:current_or_guest_user, :existing_bookmark_for).and_return(false) |
14 | 15 | allow(@controller).to receive_message_chain(:current_or_guest_user, :persisted?).and_return(true) |
15 | 16 | allow(@controller).to receive_message_chain(:current_or_guest_user, :bookmarks, :where, :exists?).and_return(false) |
|
25 | 26 | @controller.send(:current_or_guest_user).bookmarks.create! document_id: '2007020969', document_type: "SolrDocument" |
26 | 27 | end |
27 | 28 |
|
28 | | - it "has a 204 status code when delete is success" do |
| 29 | + it "has a 200 status code when delete is success" do |
29 | 30 | xhr :delete, :destroy, :id => '2007020969', :format => :js |
30 | 31 | expect(response).to be_success |
31 | | - expect(response.code).to eq "204" |
| 32 | + expect(response.code).to eq "200" |
| 33 | + expect(JSON.parse(response.body)["bookmarks"]["count"]).to eq 0 |
32 | 34 | end |
33 | 35 |
|
34 | 36 | it "has a 500 status code when delete is not success" do |
|
0 commit comments