blob: 131116463b1ea84f9f2ff2b956d6a6b4ea9886b7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
require "rails_helper"
describe FavoritesController do
context "when logged in" do
let(:user) { create(:user) }
let(:cake) { create(:cake) }
before { http_login(user) }
context "when adding a cake to your favorites" do
before :each do
post :create, params: { cake_id: cake.id }
end
it "should add the cake to the logged in users favorites" do
expect(user.reload.favorites.count).to eql(1)
end
it "should redirect to the cake detail page" do
expect(response).to redirect_to(cake_path(cake))
end
it "should include a friendly flash message" do
expect(flash[:notice]).to_not be_nil
end
end
end
end
|