]> git.openstreetmap.org Git - rails.git/commitdiff
Merge remote-tracking branch 'upstream/pull/5312'
authorTom Hughes <tom@compton.nu>
Wed, 13 Nov 2024 16:55:44 +0000 (16:55 +0000)
committerTom Hughes <tom@compton.nu>
Wed, 13 Nov 2024 16:55:44 +0000 (16:55 +0000)
.github/workflows/danger.yml
Gemfile
Gemfile.lock
app/controllers/sessions_controller.rb
app/views/sessions/new.html.erb
test/controllers/sessions_controller_test.rb

index 8999fca5b5af7b8f9603e1cebf6aae4cbe8ec210..67a676d87c11eea4b1879c2a715443237ea250ee 100644 (file)
@@ -22,6 +22,12 @@ jobs:
           ruby-version: 3.1
           rubygems: 3.4.10
           bundler-cache: true
+      - name: Create base branch
+        run: |
+          git fetch ${{ github.event.pull_request.base.repo.clone_url }} ${{ github.event.pull_request.base.ref }}:danger_base
+      - name: Create head branch
+        run: |
+          git fetch ${{ github.event.pull_request.head.repo.clone_url }} ${{ github.event.pull_request.head.ref }}:danger_head
       - name: Danger
         env:
           DANGER_GITHUB_BEARER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
diff --git a/Gemfile b/Gemfile
index b83011542a24d216995f7c60f154d537182e8609..277346b8388df908c3e110cff5b9bbb55a18cf84 100644 (file)
--- a/Gemfile
+++ b/Gemfile
@@ -148,7 +148,7 @@ gem "zeitwerk", "< 2.7"
 group :development do
   gem "better_errors"
   gem "binding_of_caller"
-  gem "danger", :github => "tomhughes/danger", :ref => "pull-request-target"
+  gem "danger"
   gem "danger-auto_label"
   gem "debug_inspector"
   gem "i18n-tasks"
index 86a69b9f5831c9ea4db1c408bcf7ef2236b120f2..5d15e550c55d1dd8bcfdf3bec73091af8ae130bf 100644 (file)
@@ -1,23 +1,3 @@
-GIT
-  remote: https://github.com/tomhughes/danger.git
-  revision: a265cf74d2f464a25796b48d95697f5eed553454
-  ref: pull-request-target
-  specs:
-    danger (9.5.1)
-      base64 (~> 0.2)
-      claide (~> 1.0)
-      claide-plugins (>= 0.9.2)
-      colored2 (~> 3.1)
-      cork (~> 0.1)
-      faraday (>= 0.9.0, < 3.0)
-      faraday-http-cache (~> 2.0)
-      git (~> 1.13)
-      kramdown (~> 2.3)
-      kramdown-parser-gfm (~> 1.0)
-      octokit (>= 4.0)
-      pstore (~> 0.1)
-      terminal-table (>= 1, < 4)
-
 GEM
   remote: https://rubygems.org/
   specs:
@@ -190,6 +170,20 @@ GEM
       rexml
     crass (1.0.6)
     dalli (3.2.8)
+    danger (9.5.1)
+      base64 (~> 0.2)
+      claide (~> 1.0)
+      claide-plugins (>= 0.9.2)
+      colored2 (~> 3.1)
+      cork (~> 0.1)
+      faraday (>= 0.9.0, < 3.0)
+      faraday-http-cache (~> 2.0)
+      git (~> 1.13)
+      kramdown (~> 2.3)
+      kramdown-parser-gfm (~> 1.0)
+      octokit (>= 4.0)
+      pstore (~> 0.1)
+      terminal-table (>= 1, < 4)
     danger-auto_label (1.3.1)
       danger-plugin-api (~> 1.0)
     danger-plugin-api (1.0.0)
@@ -690,7 +684,7 @@ DEPENDENCIES
   config
   connection_pool
   dalli
-  danger!
+  danger
   danger-auto_label
   dartsass-sprockets
   debug
index a3e6f42f03db4b172607bc26285d6c79c3b0ee8b..abbaf5e921e45aedf89e60d7057023b9a0374143 100644 (file)
@@ -20,7 +20,7 @@ class SessionsController < ApplicationController
   end
 
   def create
-    session[:remember_me] ||= params[:remember_me]
+    session[:remember_me] = params[:remember_me] == "yes"
 
     referer = safe_referer(params[:referer]) if params[:referer]
 
index 9d05d4af80d44b7bf956824ee163dc66d4db225f..c2d96b63cc37ae2b9def6ba868cf8742927c3212 100644 (file)
@@ -40,7 +40,7 @@
   <%= f.password_field :password, :autocomplete => "on", :tabindex => 2, :value => "", :skip_label => true %>
 
   <%= f.form_group do %>
-    <%= f.check_box :remember_me, { :label => t(".remember"), :tabindex => 3, :checked => (params[:remember_me] == "yes") }, "yes" %>
+    <%= f.check_box :remember_me, { :label => t(".remember"), :tabindex => 3, :checked => (params[:remember_me] == "true") }, "yes" %>
   <% end %>
 
   <div class="mb-3">
index 914a4ab5608d32ce7fe343a2d6d5556ba47d3f31..f490b748c4a6c763699d2759909ba06f52944e69 100644 (file)
@@ -54,6 +54,24 @@ class SessionsControllerTest < ActionDispatch::IntegrationTest
     assert_redirected_to root_path
   end
 
+  def test_login_remembered
+    user = create(:user)
+
+    post login_path, :params => { :username => user.display_name, :password => "test", :remember_me => "yes" }
+    assert_redirected_to root_path
+
+    assert_equal 28 * 86400, session[:_remember_for]
+  end
+
+  def test_login_not_remembered
+    user = create(:user)
+
+    post login_path, :params => { :username => user.display_name, :password => "test", :remember_me => "0" }
+    assert_redirected_to root_path
+
+    assert_nil session[:_remember_for]
+  end
+
   def test_logout_without_referer
     post logout_path
     assert_redirected_to root_path