diff options
| author | mo khan <mo@mokhan.ca> | 2015-01-25 01:03:33 -0700 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2015-01-25 01:03:33 -0700 |
| commit | fb0d7c8cb573e7ed9ee9004d0b7819740d64c1ca (patch) | |
| tree | e4da8452fadd893b45f152982dd5f98646efeca4 /spec | |
| parent | ebaeabcfacbf5bf595e72833959090249baa5d77 (diff) | |
add some missing api tests for v1.
Diffstat (limited to 'spec')
| -rw-r--r-- | spec/controllers/api/v1/cakes_controller_spec.rb | 58 |
1 files changed, 50 insertions, 8 deletions
diff --git a/spec/controllers/api/v1/cakes_controller_spec.rb b/spec/controllers/api/v1/cakes_controller_spec.rb index 00002975..3985676d 100644 --- a/spec/controllers/api/v1/cakes_controller_spec.rb +++ b/spec/controllers/api/v1/cakes_controller_spec.rb @@ -1,23 +1,65 @@ require "rails_helper" describe Api::V1::CakesController do + render_views + context "when signed in" do let(:user) { create(:user) } - let!(:my_cake) { create(:creation) } - let!(:other_cake) { create(:creation) } before :each do request.env['HTTP_AUTHORIZATION'] = ActionController::HttpAuthentication::Token.encode_credentials(user.authentication_token) - user.creations << my_cake - get :index, :format => :json end - it "should return all of my cakes" do - expect(assigns(:cakes)).to match_array([my_cake]) + describe "#index" do + let!(:my_cake) { create(:creation) } + let!(:other_cake) { create(:creation) } + + before :each do + user.creations << my_cake + xhr :get, :index + end + + it "returns all of my cakes" do + expect(assigns(:cakes)).to match_array([my_cake]) + end + + it "does not return any other cakes" do + expect(assigns(:cakes)).to_not include(other_cake) + end + end + + describe "#show" do + let!(:cake) { create(:creation) } + + before :each do + user.creations << cake + xhr :get, :show, id: cake.id + end + + it 'loads a specific cake' do + expect(assigns(:cake)).to eql(cake) + end + end + + xdescribe "#create" do + + end + + xdescribe "#update" do + end - it "should not return any other cakes" do - expect(assigns(:cakes)).to_not include(other_cake) + describe "#destroy" do + let!(:cake) { create(:creation) } + + before :each do + user.creations << cake + xhr :delete, :destroy, id: cake.id + end + + it 'deletes the specified cake' do + expect(Creation.exists?(cake.id)).to be_falsey + end end end end |
