Commit 1ee34aa1
Changed files (1)
spec
controllers
api
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