|
13 | 13 |
|
14 | 14 | describe "#create" do
|
15 | 15 | it "denies access when password is incorrect" do
|
16 |
| - create(:user) |
17 |
| - post "/login", params: { password: "not-the-password" } |
| 16 | + user = create(:user) |
| 17 | + params = { username: user.username, password: "not-the-password" } |
| 18 | + |
| 19 | + post("/login", params:) |
18 | 20 |
|
19 | 21 | expect(rendered).to have_selector(".error")
|
20 | 22 | end
|
21 | 23 |
|
22 | 24 | it "allows access when password is correct" do
|
23 | 25 | user = default_user
|
| 26 | + params = { username: user.username, password: user.password } |
24 | 27 |
|
25 |
| - post "/login", params: { password: user.password } |
| 28 | + post("/login", params:) |
26 | 29 |
|
27 | 30 | expect(session[:user_id]).to eq(user.id)
|
28 | 31 | end
|
29 | 32 |
|
30 | 33 | it "redirects to the root page" do
|
31 | 34 | user = default_user
|
| 35 | + params = { username: user.username, password: user.password } |
32 | 36 |
|
33 |
| - post "/login", params: { password: user.password } |
| 37 | + post("/login", params:) |
34 | 38 |
|
35 | 39 | expect(URI.parse(response.location).path).to eq("/")
|
36 | 40 | end
|
37 | 41 |
|
38 | 42 | it "redirects to the previous path when present" do
|
39 | 43 | user = default_user
|
40 |
| - |
| 44 | + params = { username: user.username, password: user.password } |
41 | 45 | get("/archive")
|
42 |
| - post("/login", params: { password: user.password }) |
| 46 | + |
| 47 | + post("/login", params:) |
43 | 48 |
|
44 | 49 | expect(URI.parse(response.location).path).to eq("/archive")
|
45 | 50 | end
|
|
0 commit comments