]> git.openstreetmap.org Git - rails.git/commitdiff
Test that encouragement disappears after verified email signup
authorAnton Khorev <tony29@yandex.ru>
Mon, 13 Jan 2025 11:11:11 +0000 (14:11 +0300)
committerAnton Khorev <tony29@yandex.ru>
Mon, 13 Jan 2025 12:03:58 +0000 (15:03 +0300)
test/system/create_note_test.rb

index b92f7f9b175b52013b8d72bd85b717d417f07705..dd13a286f55e3061be1c51bbba764fcc24628ce5 100644 (file)
@@ -4,9 +4,16 @@ class CreateNoteTest < ApplicationSystemTestCase
   include ActionMailer::TestHelper
 
   def setup
   include ActionMailer::TestHelper
 
   def setup
+    OmniAuth.config.test_mode = true
+
     stub_request(:get, /.*gravatar.com.*d=404/).to_return(:status => 404)
   end
 
     stub_request(:get, /.*gravatar.com.*d=404/).to_return(:status => 404)
   end
 
+  def teardown
+    OmniAuth.config.mock_auth[:google] = nil
+    OmniAuth.config.test_mode = false
+  end
+
   test "can create note" do
     visit new_note_path(:anchor => "map=18/0/0")
 
   test "can create note" do
     visit new_note_path(:anchor => "map=18/0/0")
 
@@ -93,7 +100,7 @@ class CreateNoteTest < ApplicationSystemTestCase
     check_no_encouragement_while_logging_out
   end
 
     check_no_encouragement_while_logging_out
   end
 
-  test "encouragement to contribute appears after 10 created notes and disappears after signup" do
+  test "encouragement to contribute appears after 10 created notes and disappears after email signup" do
     check_encouragement_while_creating_notes(10)
 
     sign_up_with_email
     check_encouragement_while_creating_notes(10)
 
     sign_up_with_email
@@ -101,6 +108,14 @@ class CreateNoteTest < ApplicationSystemTestCase
     check_no_encouragement_while_logging_out
   end
 
     check_no_encouragement_while_logging_out
   end
 
+  test "encouragement to contribute appears after 10 created notes and disappears after google signup" do
+    check_encouragement_while_creating_notes(10)
+
+    sign_up_with_google
+
+    check_no_encouragement_while_logging_out
+  end
+
   private
 
   def check_encouragement_while_creating_notes(encouragement_threshold)
   private
 
   def check_encouragement_while_creating_notes(encouragement_threshold)
@@ -162,4 +177,18 @@ class CreateNoteTest < ApplicationSystemTestCase
 
     assert_content "Welcome!"
   end
 
     assert_content "Welcome!"
   end
+
+  def sign_up_with_google
+    OmniAuth.config.add_mock(:google,
+                             :uid => "123454321",
+                             :extra => { :id_info => { :openid_id => "http://localhost:1123/new.tester" } },
+                             :info => { :email => "google_user_account@example.com", :name => "google_user_account" })
+
+    click_on "Sign Up"
+
+    within_content_body do
+      click_on "Log in with Google"
+      click_on "Sign Up"
+    end
+  end
 end
 end