diff options
| author | mo khan <mo@mokhan.ca> | 2015-01-27 22:03:46 -0700 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2015-01-27 22:03:46 -0700 |
| commit | 1ee34aa1a47b61d4bba126ad436d16bf1a4cd3da (patch) | |
| tree | 43c62f76d42c8910817d960a2818010549208a4e /spec/controllers | |
| parent | a03ff0d376e2ecc5006bd67a573c19d035b0c3f0 (diff) | |
add specs for updating a cake.
Diffstat (limited to 'spec/controllers')
| -rw-r--r-- | spec/controllers/api/v1/cakes_controller_spec.rb | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/spec/controllers/api/v1/cakes_controller_spec.rb b/spec/controllers/api/v1/cakes_controller_spec.rb index d7282cce..dc1ce514 100644 --- a/spec/controllers/api/v1/cakes_controller_spec.rb +++ b/spec/controllers/api/v1/cakes_controller_spec.rb @@ -7,7 +7,7 @@ describe Api::V1::CakesController do let(:user) { create(:user) } before :each do - request.env['HTTP_AUTHORIZATION'] = ActionController::HttpAuthentication::Token.encode_credentials(user.authentication_token) + request.env["HTTP_AUTHORIZATION"] = ActionController::HttpAuthentication::Token.encode_credentials(user.authentication_token) end describe "#index" do @@ -36,7 +36,7 @@ describe Api::V1::CakesController do xhr :get, :show, id: cake.id end - it 'loads a specific cake' do + it "loads a specific cake" do expect(assigns(:cake)).to eql(cake) end end @@ -44,17 +44,33 @@ describe Api::V1::CakesController do describe "#create" do let(:category) { create(:category) } - it 'creates a new project' do - xhr :post, :create, cake: { name: 'new-cake', category_id: category.id } + it "creates a new project" do + xhr :post, :create, cake: { name: "new-cake", category_id: category.id } expect(Creation.count).to eql(1) - expect(Creation.first.name).to eql('new-cake') + expect(Creation.first.name).to eql("new-cake") expect(Creation.first.category).to eql(category) expect(Creation.first.user).to eql(user) end end - xdescribe "#update" do + describe "#update" do + let(:cake) { create(:cake, user: user) } + + it "tags the cake" do + xhr :patch, :update, id: cake.id, cake: { tags: "cake, cookies, yummy" } + + cake.reload + expect(cake.tags.pluck(:name)).to match_array(["cake", "cookies", "yummy"]) + end + + it "updates the description" do + new_story = "what's the haps on the craps" + xhr :patch, :update, id: cake.id, cake: { story: new_story } + + cake.reload + expect(cake.story).to eql(new_story) + end end @@ -66,7 +82,7 @@ describe Api::V1::CakesController do xhr :delete, :destroy, id: cake.id end - it 'deletes the specified cake' do + it "deletes the specified cake" do expect(Creation.exists?(cake.id)).to be_falsey end end |
