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