[Git][noosfero/noosfero][master] 2 commits: export host and activation_code

Rodrigo Souto gitlab at mg.gitlab.com
Mon Oct 29 18:19:16 BRST 2018


Rodrigo Souto pushed to branch master at Noosfero / noosfero


Commits:
3a1fd3d0 by Leandro Nunes dos Santos at 2018-10-23T16:29:13Z
export host and activation_code

- - - - -
d59b8e1b by Rodrigo Souto at 2018-10-29T20:19:13Z
Merge branch 'expose_host_and_activation_code' into 'master'

export host and activation_code

See merge request noosfero/noosfero!1632
- - - - -


3 changed files:

- app/api/entities.rb
- app/api/v1/session.rb
- test/api/environment_test.rb


Changes:

=====================================
app/api/entities.rb
=====================================
@@ -286,6 +286,7 @@ module Api
 
     class UserLogin < User
       expose :private_token, documentation: {type: 'String', desc: 'A valid authentication code for post/delete api actions'}, if: lambda {|object, options| object.activated? }
+      expose :activation_code
     end
 
     class Task < Entity
@@ -321,7 +322,7 @@ module Api
       expose :captcha_signup_enable do |environment, options|
         environment.require_captcha?(:signup, nil, environment)
       end
-      expose :top_url, as: :host, :if => lambda {|instance, options| Entities.expose_optional_field?(:host, options)}
+      expose :top_url, as: :host
       expose :type do |environment, options|
         "Environment"
       end


=====================================
app/api/v1/session.rb
=====================================
@@ -109,16 +109,17 @@ module Api
               user.generate_private_token!
               present user, :with => Entities::UserLogin, :current_person => current_person
             else
-              # Waiting for admin moderate user registration
               status 202
-              body({ message: 'Waiting for admin moderate user registration' })
+              output = {:success => true}
+	            output[:message] = _('Waiting for admin moderate user registration')
+              output[:code] = Api::Status::Http::OK
+              present output, :with => Entities::Response
             end
           else
-            render_api_error!(_('Token is invalid'), 412)
+            render_api_error!(_('Activation code is invalid'), 412)
           end
         else
-          # Token not found in database
-          render_api_error!(_('Token is invalid'), 412)
+          render_api_error!(_('Activation token is invalid'), 412)
         end
       end
 
@@ -137,7 +138,7 @@ module Api
         end
 
         output = {:success => true}
-	output[:message] = _('All change password requests were sent.')
+	      output[:message] = _('All change password requests were sent.')
         output[:code] = Api::Status::Http::OK
         present output, :with => Entities::Response
       end


=====================================
test/api/environment_test.rb
=====================================
@@ -6,7 +6,7 @@ class EnvironmentTest < ActiveSupport::TestCase
     create_and_activate_user
   end
 
-  ENVIRONMENT_ATTRIBUTES = %w(name id description layout_template signup_intro terms_of_use captcha_site_key captcha_signup_enable)
+  ENVIRONMENT_ATTRIBUTES = %w(name id description layout_template signup_intro terms_of_use captcha_site_key captcha_signup_enable host)
   ENVIRONMENT_ATTRIBUTES.map do |attribute|
     define_method "test_should_expose_#{attribute}_attribute_in_environment_enpoint" do
       login_api
@@ -17,28 +17,6 @@ class EnvironmentTest < ActiveSupport::TestCase
     end
   end
 
-
-  should 'display host if optional_fields is passed as parameter' do
-    environment = Environment.default
-
-    params[:optional_fields] = ['host']
-    get "/api/v1/environments/default?#{params.to_query}"
-    json = JSON.parse(last_response.body)
-    assert_equal environment.id, json['id']
-
-    assert_not_nil json['host']
-  end
-
-  should 'not display host if optional_fields is not passed as parameter' do
-    environment = Environment.default
-
-    get "/api/v1/environments/default?#{params.to_query}"
-    json = JSON.parse(last_response.body)
-    assert_equal environment.id, json['id']
-
-    assert_nil json['host']
-  end
-
   should "test_should_return_the_environments_default_environment" do
     environment = Environment.default
     get "/api/v1/environments/default"



View it on GitLab: https://gitlab.com/noosfero/noosfero/compare/e83be0272b01eac1abcf5de75540bcb3710d06bc...d59b8e1bed2aaac45882543b7d69de53642c1b54

-- 
View it on GitLab: https://gitlab.com/noosfero/noosfero/compare/e83be0272b01eac1abcf5de75540bcb3710d06bc...d59b8e1bed2aaac45882543b7d69de53642c1b54
You're receiving this email because of your account on gitlab.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listas.softwarelivre.org/pipermail/noosfero-dev/attachments/20181029/00aff1c9/attachment-0001.html>


More information about the Noosfero-dev mailing list