@@ -70,34 +70,6 @@ def test_display_form_with_errors_if_invalid_post(self):
70
70
self .assertIsInstance (form , SponsorshiptBenefitsForm )
71
71
self .assertTrue (form .errors )
72
72
73
- def test_login_required (self ):
74
- redirect_url = f"{ settings .LOGIN_URL } ?next={ self .url } "
75
- self .client .logout ()
76
-
77
- r = self .client .get (self .url )
78
-
79
- self .assertRedirects (r , redirect_url )
80
-
81
- def test_not_staff_no_group_not_allowed (self ):
82
- redirect_url = f"{ settings .LOGIN_URL } ?next={ self .url } "
83
- self .user .is_staff = False
84
- self .user .save ()
85
- self .client .force_login (self .user )
86
-
87
- r = self .client .get (self .url )
88
-
89
- self .assertRedirects (r , redirect_url , fetch_redirect_response = False )
90
-
91
- def test_group_allowed (self ):
92
- redirect_url = f"{ settings .LOGIN_URL } ?next={ self .url } "
93
- self .user .groups .add (self .group )
94
- self .user .save ()
95
- self .client .force_login (self .user )
96
-
97
- r = self .client .get (self .url )
98
-
99
- self .assertEqual (r .status_code , 200 , "user in group should have access" )
100
-
101
73
def test_valid_post_redirect_user_to_next_form_step_and_save_info_in_cookies (self ):
102
74
package = baker .make ("sponsors.SponsorshipPackage" )
103
75
for benefit in self .program_1_benefits :
@@ -141,6 +113,24 @@ def test_capacity_flag_when_needed(self):
141
113
r = self .client .get (self .url )
142
114
self .assertEqual (True , r .context ["capacities_met" ])
143
115
116
+ def test_redirect_to_login (self ):
117
+ redirect_url = (
118
+ f"{ settings .LOGIN_URL } ?next={ reverse ('new_sponsorship_application' )} "
119
+ )
120
+ package = baker .make ("sponsors.SponsorshipPackage" )
121
+ for benefit in self .program_1_benefits :
122
+ benefit .packages .add (package )
123
+
124
+ data = {
125
+ "benefits_psf" : [b .id for b in self .program_1_benefits ],
126
+ "benefits_working_group" : [b .id for b in self .program_2_benefits ],
127
+ "package" : package .id ,
128
+ }
129
+ self .client .logout ()
130
+ response = self .client .post (self .url , data = data )
131
+
132
+ self .assertRedirects (response , redirect_url , fetch_redirect_response = False )
133
+
144
134
145
135
class NewSponsorshipApplicationViewTests (TestCase ):
146
136
url = reverse_lazy ("new_sponsorship_application" )
0 commit comments