Sha256: 6947bce77f85b6bae1c83349c47ca7ab19cd6877a6e04ae50ef4d0fae6f7b2de
Contents?: true
Size: 970 Bytes
Versions: 3
Compression:
Stored size: 970 Bytes
Contents
require "test_helper" class Sessions::SudosControllerTest < ActionDispatch::IntegrationTest setup do @<%= singular_table_name %>, @token = sign_in_as(<%= table_name %>(:lazaro_nixon)) @<%= singular_table_name %>.sessions.last.update! sudo_at: 1.day.ago end test "should sudo" do post sessions_sudo_url, params: { password: "Secret1*3*5*" }, headers: { "Authorization" => "Bearer #{@token}" } assert_response :no_content end test "should not sudo with wrong password" do post sessions_sudo_url, params: { password: "SecretWrong1*3" }, headers: { "Authorization" => "Bearer #{@token}" } assert_response :bad_request assert_equal "The password you entered is incorrect", response.parsed_body["error"] end def sign_in_as(<%= singular_table_name %>) post(sign_in_url, params: { email: <%= singular_table_name %>.email, password: "Secret1*3*5*" }); [<%= singular_table_name %>, response.headers["X-Session-Token"]] end end
Version data entries
3 entries across 3 versions & 1 rubygems