[Git][noosfero/noosfero][master] 3 commits: expose box id on blocks

Leandro Nunes gitlab at mg.gitlab.com
Thu Jun 21 16:25:51 BRT 2018


Leandro Nunes pushed to branch master at Noosfero / noosfero


Commits:
5fff901a by Leandro Nunes dos Santos at 2018-06-21T16:58:40Z
expose box id on blocks

- - - - -
18a4c843 by Leandro Nunes dos Santos at 2018-06-21T17:08:44Z
adding tests to check if block fields are returning in api

- - - - -
0f075e2c by Leandro Nunes at 2018-06-21T19:25:45Z
Merge branch 'expose-box-id' into 'master'

Expose box_id on blocks

See merge request noosfero/noosfero!1549
- - - - -


3 changed files:

- app/api/entities.rb
- test/api/articles_test.rb
- test/api/blocks_test.rb


Changes:

=====================================
app/api/entities.rb
=====================================
@@ -91,7 +91,7 @@ module Api
     end
 
     class Block < Entity
-      expose :id, :type, :settings, :position, :enabled
+      expose :id, :type, :settings, :position, :enabled, :box_id
       expose :mirror, :mirror_block_id, :title
       expose :api_content, if: lambda { |object, options| options[:display_api_content] || object.display_api_content_by_default? } do |block, options|
         block.api_content({:current_person => options[:current_person]}.merge(options[:api_content_params] || {}))


=====================================
test/api/articles_test.rb
=====================================
@@ -7,6 +7,18 @@ class ArticlesTest < ActiveSupport::TestCase
     login_api
   end
 
+  expose_attributes = %w(id body abstract created_at title author profile categories image votes_for votes_against setting position hits start_date end_date tag_list parent children children_count url)
+
+  expose_attributes.each do |attr|
+    should "expose article #{attr} attribute by default" do
+      article = fast_create(Article, :profile_id => user.person.id, :name => "Some thing")
+      get "/api/v1/articles/?#{params.to_query}"
+      json = JSON.parse(last_response.body)
+      assert json.last.has_key?(attr)
+    end
+  end
+
+
   should 'remove article return 200 http status' do
     article = fast_create(Article, :profile_id => user.person.id, :name => "Some thing")
     delete "/api/v1/articles/#{article.id}?#{params.to_query}"
@@ -215,17 +227,6 @@ class ArticlesTest < ActiveSupport::TestCase
     assert_equal true, json['success']
   end
 
-  expose_attributes = %w(id body abstract created_at title author profile categories image votes_for votes_against setting position hits start_date end_date tag_list parent children children_count url)
-
-  expose_attributes.each do |attr|
-    should "expose article #{attr} attribute by default" do
-      article = fast_create(Article, :profile_id => user.person.id, :name => "Some thing")
-      get "/api/v1/articles/?#{params.to_query}"
-      json = JSON.parse(last_response.body)
-      assert json.last.has_key?(attr)
-    end
-  end
-
   should 'not perform a vote twice in same article' do
     article = fast_create(Article, :profile_id => @person.id, :name => "Some thing")
     @params[:value] = 1


=====================================
test/api/blocks_test.rb
=====================================
@@ -10,6 +10,16 @@ class BlocksTest < ActiveSupport::TestCase
   end
 
   attr_accessor :environment, :profile
+  expose_attributes = %w(id type settings position enabled box_id)
+
+  expose_attributes.each do |attr|
+    should "expose block #{attr} attribute by default" do
+      block = fast_create(Block, :box_id => user.person.boxes.first.id)
+      get "/api/v1/blocks/#{block.id}?#{params.to_query}"
+      json = JSON.parse(last_response.body)
+      assert json.has_key?(attr)
+    end
+  end
 
   should 'get an environment block' do
     box = fast_create(Box, :owner_id => environment.id, :owner_type => Environment.name)



View it on GitLab: https://gitlab.com/noosfero/noosfero/compare/4362874854bbec53ee2d65189e19565b474c745d...0f075e2c336092b531430c0f613782690134e903

-- 
View it on GitLab: https://gitlab.com/noosfero/noosfero/compare/4362874854bbec53ee2d65189e19565b474c745d...0f075e2c336092b531430c0f613782690134e903
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/20180621/e26260ab/attachment-0001.html>


More information about the Noosfero-dev mailing list