]> git.openstreetmap.org Git - rails.git/commitdiff
Merge remote-tracking branch 'osmlab/welcome-2'
authorTom Hughes <tom@compton.nu>
Sun, 18 Aug 2013 13:50:36 +0000 (14:50 +0100)
committerTom Hughes <tom@compton.nu>
Sun, 18 Aug 2013 13:50:36 +0000 (14:50 +0100)
1  2 
config/locales/en.yml
test/functional/user_controller_test.rb

diff --combined config/locales/en.yml
index 3722498d009403c88a0df967a64c8bb23f45f3a9,9709b87781ccd27c05ff775237d5db3bc3dffc0f..794d72cbb62e4e93a28cfa1443840a7f0c121eee
@@@ -471,10 -471,6 +471,10 @@@ en
      search_osm_nominatim:
        prefix_format: "%{name}"
        prefix:
 +        aerialway:
 +          chair_lift: "Chair Lift"
 +          drag_lift: "Drag Lift"
 +          station: "Aerialway Station"
          aeroway:
            aerodrome: "Aerodrome"
            apron: "Apron"
            shower: "Shower"
            social_centre: "Social Centre"
            social_club: "Social Club"
 +          social_facility: "Social Facility"
            studio: "Studio"
            supermarket: "Supermarket"
            swimming_pool: "Swimming Pool"
            "yes": "Bridge"
          building:
            "yes": "Building"
 +        emergency:
 +          fire_hydrant: "Fire Hydrant"
 +          phone: "Emergency Phone"
          highway:
            bridleway: "Bridleway"
            bus_guideway: "Guided Bus Lane"
            platform: "Platform"
            primary: "Primary Road"
            primary_link: "Primary Road"
 +          proposed: "Proposed Road"
            raceway: "Raceway"
            residential: "Residential"
            rest_area: "Rest Area"
            services: "Motorway Services"
            speed_camera: "Speed Camera"
            steps: "Steps"
 +          street_lamp: "Street Lamp"
            stile: "Stile"
            tertiary: "Tertiary Road"
            tertiary_link: "Tertiary Road"
            building: "Building"
            castle: "Castle"
            church: "Church"
 +          citywalls: "City Walls"
            fort: "Fort"
            house: "House"
            icon: "Icon"
            locality: "Locality"
            moor: "Moor"
            municipality: "Municipality"
 +          neighbourhood: "Neighbourhood"
            postcode: "Postcode"
            region: "Region"
            sea: "Sea"
            narrow_gauge: "Narrow Gauge Railway"
            platform: "Railway Platform"
            preserved: "Preserved Railway"
 +          proposed: "Proposed Railway"
            spur: "Railway Spur"
            station: "Railway Station"
 +          stop: "Railway Stop"
            subway: "Subway Station"
            subway_entrance: "Subway Entrance"
            switch: "Railway Points"
            beverages: "Beverages Shop"
            bicycle: "Bicycle Shop"
            books: "Book Shop"
 +          boutique: "Boutique"
            butcher: "Butcher"
            car: "Car Shop"
            car_parts: "Car Parts"
 +          car_repair: "Car Repair"
            carpet: "Carpet Shop"
            car_repair: "Car Repair"
            charity: "Charity Shop"
            convenience: "Convenience Store"
            copyshop: "Copy Shop"
            cosmetics: "Cosmetics Shop"
 +          deli: "Deli"
            department_store: "Department Store"
            discount: "Discount Items Shop"
            doityourself: "Do-It-Yourself"
            organic: "Organic Food Shop"
            outdoor: "Outdoor Shop"
            pet: "Pet Shop"
 +          pharmacy: "Pharmacy"
            photo: "Photo Shop"
            salon: "Salon"
 +          second_hand: "Second-hand Shop"
            shoes: "Shoe Shop"
            shopping_centre: "Shopping Centre"
            sports: "Sports Shop"
            stationery: "Stationery Shop"
            supermarket: "Supermarket"
 +          tailor: "Tailor"
            toys: "Toy Shop"
            travel_agency: "Travel Agency"
            video: "Video Shop"
            wine: "Off License"
 +          "yes": "Shop"
          tourism:
            alpine_hut: "Alpine Hut"
            artwork: "Artwork"
            viewpoint: "Viewpoint"
            zoo: "Zoo"
          tunnel:
 +          culvert: "Culvert"
            "yes": "Tunnel"
          waterway:
            artificial: "Artificial Waterway"
          to our <a href="http://www.osmfoundation.org/wiki/License/Takedown_procedure">takedown
          procedure</a> or file directly at our
          <a href="http://dmca.openstreetmap.org/">on-line filing page</a>.
+   welcome_page:
+     title: Welcome!
+     introduction_html: |
+       Welcome to OpenStreetMap, the free and editable map of the world. Now that you're signed
+       up, you're all set to get started mapping. Here's a quick guide with the most important
+       things you need to know.
+     whats_on_the_map:
+       title: What's on the Map
+       on_html: |
+         OpenStreetMap is a place for mapping things that are both <em>real and current</em> -
+         it includes millions of buildings, roads, and other details about places. You can map
+         whatever real-world features are interesting to you.
+       off_html: |
+         What it <em>doesn't</em> include is opinionated data like ratings, historical or
+         hypothetical features, and data from copyrighted sources. Unless you have special
+         permission, don't copy from online or paper maps.
+     basic_terms:
+       title: Basic Terms For Mapping
+       paragraph_1_html: |
+         OpenStreetMap has some of its own lingo. Here are a few key words that'll come in handy.
+       editor_html: |
+         An <strong>editor</strong> is a program or website you can use to edit the map.
+       node_html: |
+         A <strong>node</strong> is a point on the map, like a single restauraunt or a tree.
+       way_html: |
+         A <strong>way</strong> is a line or area, like a road, stream, lake or building.
+       tag_html: |
+         A <strong>tag</strong> is a bit of data about a node or way, like a
+         restaurant's name or a road's speed limit.
+     questions:
+       title: Any questions?
+       paragraph_1_html: |
+         Need help mapping, or not clear on how to use OpenStreetMap? Get your questions answered
+         on <a href='http://help.openstreetmap.org/'>the help website</a>.
+     start_mapping: Start Mapping
+     add_a_note:
+       title: No Time To Edit? Add a Note!
+       paragraph_1_html: |
+         If you just want something small fixed and don't have the time to sign up and learn how to edit, it's
+         easy to add a note.
+       paragraph_2_html: |
+         Just go to <a href='%{map_url}'>the map</a> and click the note icon:
+         <span class='icon note'></span>. This will add a marker to the map, which you can move
+         by dragging. Add your message, then click save, and other mappers will investigate.
    notifier:
      diary_comment_notification:
        subject: "[OpenStreetMap] %{user} commented on your diary entry"
        greeting: "Hi there!"
        created: "Someone (hopefully you) just created an account at %{site_url}."
        confirm: "Before we do anything else, we need to confirm that this request came from you, so if it did then please click the link below to confirm your account:"
-       welcome: "We would like to welcome you and provide you with some additional information to get you started."
-     signup_confirm_plain:
-       introductory_video: "You can watch an introductory video to OpenStreetMap here:"
-       more_videos: "There are more videos here:"
-       the_wiki: "Get reading about OpenStreetMap on the wiki:"
-       the_wiki_url: "http://wiki.openstreetmap.org/wiki/Beginners%27_guide"
-       blog_and_twitter: "Catch up with the latest news via the OpenStreetMap blog or Twitter:"
-       ask_questions: "You can ask any questions you may have about OpenStreetMap at our question and answer site:"
-       wiki_signup: "You may also want to sign up to the OpenStreetMap wiki at:"
-       wiki_signup_url: "http://wiki.openstreetmap.org/index.php?title=Special:Userlogin&type=signup&returnto=Main_Page"
-       user_wiki_page: "It is recommended that you create a user wiki page, which includes category tags noting where you are, such as [[Category:Users_in_London]]."
-       current_user: "A list of current users in categories, based on where in the world they are, is available from:"
-     signup_confirm_html:
-       introductory_video: "You can watch an %{introductory_video_link}."
-       video_to_openstreetmap: "introductory video to OpenStreetMap"
-       more_videos: "There are %{more_videos_link}."
-       more_videos_here: "more videos here"
-       get_reading: Get reading about OpenStreetMap <a href="http://wiki.openstreetmap.org/wiki/Beginners%27_guide">on the wiki</a>, and catch up with the latest news via the <a href="http://blog.openstreetmap.org/">OpenStreetMap blog</a> or <a href="http://twitter.com/openstreetmap">Twitter</a>.
-       ask_questions: You can ask any questions you may have about OpenStreetMap at our <a href="http://help.openstreetmap.org/">question and answer site</a>.
-       wiki_signup: 'You may also want to <a href="http://wiki.openstreetmap.org/index.php?title=Special:Userlogin&type=signup&returnto=Main_Page">sign up to the OpenStreetMap wiki</a>.'
-       user_wiki_page: 'It is recommended that you create a user wiki page, which includes category tags noting where you are, such as <a href="http://wiki.openstreetmap.org/wiki/Category:Users_in_London">[[Category:Users_in_London]]</a>.'
-       current_user: 'A list of current users in categories, based on where in the world they are, is available from <a href="http://wiki.openstreetmap.org/wiki/Category:Users_by_geographical_region">Category:Users_by_geographical_region</a>.'
+       welcome: "After you confirm your account, we'll provide you with some additional information to get you started."
      email_confirm:
        subject: "[OpenStreetMap] Confirm your email address"
      email_confirm_plain:
        flash changed: "Your password has been changed."
        flash token bad: "Did not find that token, check the URL maybe?"
      new:
-       title: "Create account"
-       heading: "Create a User Account"
+       title: "Sign Up"
        no_auto_account_create: "Unfortunately we are not currently able to create an account for you automatically."
        contact_webmaster: 'Please contact the <a href="mailto:webmaster@openstreetmap.org">webmaster</a> to arrange for an account to be created - we will try and deal with the request as quickly as possible.'
-       fill_form: "Fill in the form and we will send you a quick email to activate your account."
+       about:
+         header: Free and editable
+         html: |
+           <p>Unlike other maps, OpenStreetMap is completely created by people like you,
+           and it's free for anyone to fix, update, download and use.</p>
+           <p>Sign up to get started contributing. We'll send an email to confirm your account.</p>
        license_agreement: 'When you confirm your account you will need to agree to the <a href="http://www.osmfoundation.org/wiki/License/Contributor_Terms">contributor terms</a>.'
        email address: "Email Address:"
        confirm email address: "Confirm Email Address:"
              with your OpenID in your user settings.
            </li>
          </ul>
-       continue: Continue
-       flash welcome: "Thanks for signing up. We've sent a welcome message to %{email} with some hints on getting started."
-       flash create success message: "Thanks for signing up. We've sent a confirmation note to %{email} and as soon as you confirm your account you'll be able to get mapping.<br /><br />If you use an antispam system which sends confirmation requests then please make sure you whitelist webmaster@openstreetmap.org as we are unable to reply to any confirmation requests."
+       continue: Sign Up
        terms accepted: "Thanks for accepting the new contributor terms!"
        terms declined: "We are sorry that you have decided to not accept the new Contributor Terms. For more information, please see <a href=\"%{url}\">this wiki page</a>."
        terms declined url: http://wiki.openstreetmap.org/wiki/Contributor_Terms_Declined
      terms:
        title: "Contributor terms"
        heading: "Contributor terms"
-       read and accept: "Please read the agreement below and press the agree button to confirm that you accept the terms of this agreement for your existing and future contributions."
+       read and accept: "Please read the agreement and press the agree button to confirm that you accept the terms of this agreement for your existing and future contributions."
        consider_pd: "In addition to the above agreement, I consider my contributions to be in the Public Domain"
        consider_pd_why: "what's this?"
        consider_pd_why_url: http://www.osmfoundation.org/wiki/License/Why_would_I_want_my_contributions_to_be_public_domain
        declined: "http://wiki.openstreetmap.org/wiki/Contributor_Terms_Declined"
        decline: "Decline"
        you need to accept or decline: "Please read and then either accept or decline the new Contributor Terms to continue."
-       legale_select: "Please select your country of residence:"
+       legale_select: "Country of residence:"
        legale_names:
          france: "France"
          italy: "Italy"
        flash update success confirm needed: "User information updated successfully. Check your email for a note to confirm your new email address."
        flash update success: "User information updated successfully."
      confirm:
-       heading: Confirm a user account
+       heading: Check your email!
+       introduction_1: |
+         We sent you a confirmation email.
+       introduction_2: |
+         Confirm your account by clicking on the link in the email and you'll be able to start mapping.
        press confirm button: "Press the confirm button below to activate your account."
        button: Confirm
-       success: "Confirmed your account, thanks for signing up!"
-       before you start: "We know you're probably in a hurry to start mapping, but before you do you might like to fill in some more information about yourself in the form below."
        already active: "This account has already been confirmed."
-       unknown token: "That token doesn't seem to exist."
-       reconfirm: "If it's been a while since you signed up you might need to <a href=\"%{reconfirm}\">send yourself a new confirmation email</a>."
+       unknown token: "That confirmation code has expired or does not exist."
+       reconfirm_html: "If you need us to resend the confirmation email, <a href=\"%{reconfirm}\">click here</a>."
      confirm_resend:
        success: "We've sent a new confirmation note to %{email} and as soon as you confirm your account you'll be able to get mapping.<br /><br />If you use an antispam system which sends confirmation requests then please make sure you whitelist webmaster@openstreetmap.org as we are unable to reply to any confirmation requests."
        failure: "User %{name} not found."
          reactivate: Reactivate
          comment_and_resolve: Comment & Resolve
          comment: Comment
+     edit_help: Move the map and zoom in on a location you want to edit, then click here.
    redaction:
      edit:
        description: "Description"
index c99ede02d87d4344a5bb605c96f4c50f045c9762,cb40659a7d6bfe80bb268c3a939607753900b733..fce4470e3f9ea0944e8b539059e6767d69cf13bb
@@@ -199,7 -199,7 +199,7 @@@ class UserControllerTest < ActionContro
  
      assert_select "html", :count => 1 do
        assert_select "head", :count => 1 do
-         assert_select "title", :text => /Create account/, :count => 1
+         assert_select "title", :text => /Sign Up/, :count => 1
        end
        assert_select "body", :count => 1 do
          assert_select "div#content", :count => 1 do
              assert_select "input[id=user_display_name]", :count => 1
              assert_select "input[id=user_pass_crypt][type=password]", :count => 1
              assert_select "input[id=user_pass_crypt_confirmation][type=password]", :count => 1
-             assert_select "input[type=submit][value=Continue]", :count => 1
+             assert_select "input[type=submit][value=Sign Up]", :count => 1
            end
          end
        end
      end
    end
-   
+   def new_user
+     user = User.new
+     user.status = "pending"
+     user.display_name = "new_tester"
+     user.email = "newtester@osm.org"
+     user.email_confirmation = "newtester@osm.org"
+     user.pass_crypt = "testtest"
+     user.pass_crypt_confirmation = "testtest"
+     user
+   end
    def test_user_create_success
-     new_email = "newtester@osm.org"
-     display_name = "new_tester"
+     user = new_user
      assert_difference('User.count') do
        assert_difference('ActionMailer::Base.deliveries.size') do
-         session[:new_user] = User.new({
-           :status => "pending", :display_name => display_name,
-           :email => new_email, :email_confirmation => new_email, 
-           :pass_crypt => "testtest", :pass_crypt_confirmation => "testtest"
-         }, :without_protection => true)
-         post :save
+         post :save, {}, {:new_user => user}
        end
      end
-       
      # Check the e-mail
      register_email = ActionMailer::Base.deliveries.first
-   
-     assert_equal register_email.to[0], new_email
+     assert_equal register_email.to[0], user.email
      assert_match /#{@url}/, register_email.body.to_s
  
      # Check the page
-     assert_redirected_to :action => 'login', :referer => nil
-       
+     assert_redirected_to :action => 'confirm', :display_name => user.display_name
      ActionMailer::Base.deliveries.clear
    end
-   
    def test_user_create_submit_duplicate_email
-     email = users(:public_user).email
-     display_name = "new_tester"
-     assert_difference('User.count', 0) do
-       assert_difference('ActionMailer::Base.deliveries.size', 0) do
-         session[:new_user] = User.new({
-           :status => "pending", :display_name => display_name,
-           :email => email, :email_confirmation => email, 
-           :pass_crypt => "testtest", :pass_crypt_confirmation => "testtest"
-         }, :without_protection => true)
-         post :save
+     user = new_user
+     user.email = users(:public_user).email
+     assert_no_difference('User.count') do
+       assert_no_difference('ActionMailer::Base.deliveries.size') do
+         post :save, {}, {:new_user => user}
        end
      end
-     assert_response :success                                                                       
+     assert_response :success
      assert_template 'new'
-     assert_select "div#errorExplanation"
-     assert_select "div#signupForm > fieldset > div.form-row > div.field_with_errors > input#user_email"
+     assert_select "form > fieldset > div.form-row > div.field_with_errors > input#user_email"
    end
-   
    def test_user_create_submit_duplicate_email_uppercase
-     email = users(:public_user).email.upcase
-     display_name = "new_tester"
-     assert_difference('User.count', 0) do
-       assert_difference('ActionMailer::Base.deliveries.size', 0) do
-         session[:new_user] = User.new({
-           :status => "pending", :display_name => display_name,
-           :email => email, :email_confirmation => email, 
-           :pass_crypt => "testtest", :pass_crypt_confirmation => "testtest"
-         }, :without_protection => true)
-         post :save
+     user = new_user
+     user.email = users(:public_user).email.upcase
+     assert_no_difference('User.count') do
+       assert_no_difference('ActionMailer::Base.deliveries.size') do
+         post :save, {}, {:new_user => user}
        end
      end
-     assert_response :success                                                                       
+     assert_response :success
      assert_template 'new'
-     assert_select "div#errorExplanation"
-     assert_select "div#signupForm > fieldset > div.form-row > div.field_with_errors > input#user_email"
+     assert_select "form > fieldset > div.form-row > div.field_with_errors > input#user_email"
    end
      
    def test_user_create_submit_duplicate_name
-     email = "new_tester@example.com"
-     display_name = users(:public_user).display_name
-     assert_difference('User.count', 0) do
-       assert_difference('ActionMailer::Base.deliveries.size', 0) do
-         session[:new_user] = User.new({
-           :status => "pending", :display_name => display_name,
-           :email => email, :email_confirmation => email, 
-           :pass_crypt => "testtest", :pass_crypt_confirmation => "testtest"
-         }, :without_protection => true)
-         post :save
+     user = new_user
+     user.display_name = users(:public_user).display_name
+     assert_no_difference('User.count') do
+       assert_no_difference('ActionMailer::Base.deliveries.size') do
+         post :save, {}, {:new_user => user}
        end
      end
-     assert_response :success                                                                       
+     assert_response :success
      assert_template 'new'
-     assert_select "div#errorExplanation"
-     assert_select "div#signupForm > fieldset > div.form-row > div.field_with_errors > input#user_display_name"
+     assert_select "form > fieldset > div.form-row > div.field_with_errors > input#user_display_name"
    end
    
    def test_user_create_submit_duplicate_name_uppercase
-     email = "new_tester@example.com"
-     display_name = users(:public_user).display_name.upcase
-     assert_difference('User.count', 0) do
-       assert_difference('ActionMailer::Base.deliveries.size', 0) do
-         session[:new_user] = User.new({
-           :status => "pending", :display_name => display_name,
-           :email => email, :email_confirmation => email, 
-           :pass_crypt => "testtest", :pass_crypt_confirmation => "testtest"
-         }, :without_protection => true)
-         post :save
+     user = new_user
+     user.display_name = users(:public_user).display_name.upcase
+     assert_no_difference('User.count') do
+       assert_no_difference('ActionMailer::Base.deliveries.size') do
+         post :save, {}, {:new_user => user}
        end
      end
-     assert_response :success                                                                       
+     assert_response :success
      assert_template 'new'
-     assert_select "div#errorExplanation"
-     assert_select "div#signupForm > fieldset > div.form-row > div.field_with_errors > input#user_display_name"
+     assert_select "form > fieldset > div.form-row > div.field_with_errors > input#user_display_name"
+   end
+   def test_user_save_referer_params
+     user = new_user
+     post :save, {}, {:new_user => user,
+                      :referer => '/edit?editor=id#map=1/2/3'}
+     assert_equal welcome_path(:editor => 'id', :zoom => 1, :lat => 2, :lon => 3),
+                  user.tokens.first.referer
+   end
+   def test_user_confirm_expired_token
+     user = users(:inactive_user)
+     token = user.tokens.new
+     token.expiry = 1.day.ago
+     token.save!
+     @request.cookies["_osm_session"] = user.display_name
+     post :confirm, :confirm_string => token.token
+     assert_redirected_to :action => 'confirm'
+     assert_match /expired/, flash[:error]
+   end
+   def test_user_already_confirmed
+     user = users(:normal_user)
+     token = user.tokens.create
+     @request.cookies["_osm_session"] = user.display_name
+     post :confirm, :confirm_string => token.token
+     assert_redirected_to :action => 'login'
+     assert_match /confirmed/, flash[:error]
    end
  
    def test_user_terms_new_user
      get :api_read, :id => users(:normal_user).id
      assert_response :success
  
 +    # check the data that is returned
 +    assert_select "description", :count => 1, :text => "test"
 +    assert_select "contributor-terms", :count => 1 do
 +      assert_select "[agreed=true]"
 +    end
 +    assert_select "img", :count => 1
 +    assert_select "roles", :count => 1 do
 +      assert_select "role", :count => 0
 +    end
 +    assert_select "changesets", :count => 1 do
 +      assert_select "[count=0]"
 +    end
 +    assert_select "traces", :count => 1 do
 +      assert_select "[count=0]"
 +    end
 +    assert_select "blocks", :count => 1 do
 +      assert_select "received", :count => 1 do
 +        assert_select "[count=0][active=0]"
 +      end
 +      assert_select "issued", :count => 0
 +    end
 +
      # check that we aren't revealing private information
      assert_select "contributor-terms[pd]", false
      assert_select "home", false
      assert_select "languages", false
 +    assert_select "messages", false
  
      # check that a suspended user is not returned
      get :api_read, :id => users(:suspended_user).id
    end
  
    def test_user_api_details
 +    # check that nothing is returned when not logged in
      get :api_details
      assert_response :unauthorized
      
 +    # check that we get a response when logged in
      basic_authorization(users(:normal_user).email, "test")
      get :api_details
      assert_response :success
 +
 +    # check the data that is returned
 +    assert_select "description", :count => 1, :text => "test"
 +    assert_select "contributor-terms", :count => 1 do
 +      assert_select "[agreed=true][pd=false]"
 +    end
 +    assert_select "img", :count => 1
 +    assert_select "roles", :count => 1 do
 +      assert_select "role", :count => 0
 +    end
 +    assert_select "changesets", :count => 1 do
 +      assert_select "[count=0]", :count => 1
 +    end
 +    assert_select "traces", :count => 1 do
 +      assert_select "[count=0]", :count => 1
 +    end
 +    assert_select "blocks", :count => 1 do
 +      assert_select "received", :count => 1 do
 +        assert_select "[count=0][active=0]"
 +      end
 +      assert_select "issued", :count => 0
 +    end
 +    assert_select "home", :count => 1 do
 +      assert_select "[lat=12.1][lon=12.1][zoom=3]"
 +    end
 +    assert_select "languages", :count => 1 do
 +      assert_select "lang", :count => 1, :text => "en"
 +    end
 +    assert_select "messages", :count => 1 do
 +      assert_select "received", :count => 1 do
 +        assert_select "[count=1][unread=0]"
 +      end
 +      assert_select "sent", :count => 1 do
 +        assert_select "[count=1]"
 +      end
 +    end
    end
  
    def test_user_make_friend