@@ -42,11 +42,17 @@ defmodule CodeCorps.DonationGoalControllerTest do
4242 end
4343
4444 describe "create" do
45- @ tag authenticated: :admin
46- test "creates and renders resource when data is valid" , % { conn: conn } do
47- project = insert ( :project )
45+ @ tag :authenticated
46+ test "creates and renders resource when data is valid" , % { conn: conn , current_user: current_user } do
47+ organization = insert ( :organization )
48+ insert ( :organization_membership , member: current_user , organization: organization , role: "owner" )
49+ project = insert ( :project , organization: organization )
50+
4851 attrs = @ valid_attrs |> Map . merge ( % { project: project } )
4952 assert conn |> request_create ( attrs ) |> json_response ( 201 )
53+
54+ user_id = current_user . id
55+ assert_received { :track , ^ user_id , "Created Donation Goal" , % { } }
5056 end
5157
5258 @ tag authenticated: :admin
@@ -65,11 +71,19 @@ defmodule CodeCorps.DonationGoalControllerTest do
6571 end
6672
6773 describe "update" do
68- @ tag authenticated: :admin
69- test "updates and renders chosen resource when data is valid" , % { conn: conn } do
70- project = insert ( :project )
74+ @ tag :authenticated
75+ test "updates and renders chosen resource when data is valid" , % { conn: conn , current_user: current_user } do
76+ organization = insert ( :organization )
77+ insert ( :organization_membership , member: current_user , organization: organization , role: "owner" )
78+ project = insert ( :project , organization: organization )
79+
80+ donation_goal = insert ( :donation_goal , project: project )
81+
7182 attrs = @ valid_attrs |> Map . merge ( % { project: project } )
72- assert conn |> request_update ( attrs ) |> json_response ( 200 )
83+ assert conn |> request_update ( donation_goal , attrs ) |> json_response ( 200 )
84+
85+ user_id = current_user . id
86+ assert_received { :track , ^ user_id , "Updated Donation Goal" , % { } }
7387 end
7488
7589 @ tag authenticated: :admin
0 commit comments