Commit ad2ef91821a87617053c92da0787164ef75e21d5

Authored by Evandro Junior
2 parents 93529247 d9dfa9d5

Merge branch 'staging' into captcha_serpro_plugin

* staging:
  remove tests used for old captcha system
  limit 200 characters for proposals
  Update dialoga plugin
  api: filter archived articles

Conflicts:
	test/unit/api/helpers_test.rb
lib/noosfero/api/helpers.rb
@@ -5,7 +5,7 @@ require 'grape' @@ -5,7 +5,7 @@ require 'grape'
5 module API 5 module API
6 module APIHelpers 6 module APIHelpers
7 PRIVATE_TOKEN_PARAM = :private_token 7 PRIVATE_TOKEN_PARAM = :private_token
8 - DEFAULT_ALLOWED_PARAMETERS = [:parent_id, :from, :until, :content_type, :author_id] 8 + DEFAULT_ALLOWED_PARAMETERS = [:parent_id, :from, :until, :content_type, :author_id, :archived]
9 9
10 include SanitizeParams 10 include SanitizeParams
11 include Noosfero::Plugin::HotSpot 11 include Noosfero::Plugin::HotSpot
plugins/dialoga
1 -Subproject commit d654ce48f466687dd01ae023b68122b0aaba7d3f 1 +Subproject commit a068a1a80b97e5c47a48b1385d3917cbf855874d
test/unit/api/articles_test.rb
@@ -656,6 +656,16 @@ class ArticlesTest < ActiveSupport::TestCase @@ -656,6 +656,16 @@ class ArticlesTest < ActiveSupport::TestCase
656 assert_equal json['articles'].count, 2 656 assert_equal json['articles'].count, 2
657 end 657 end
658 658
  659 + should 'find archived articles' do
  660 + article1 = fast_create(Article, :profile_id => user.person.id, :name => "Some thing")
  661 + article2 = fast_create(Article, :profile_id => user.person.id, :name => "Some thing", :archived => true)
  662 + params[:archived] = true
  663 + get "/api/v1/articles/?#{params.to_query}"
  664 + json = JSON.parse(last_response.body)
  665 + assert_not_includes json["articles"].map { |a| a["id"] }, article1.id
  666 + assert_includes json["articles"].map { |a| a["id"] }, article2.id
  667 + end
  668 +
659 ARTICLE_ATTRIBUTES = %w(followers_count votes_count comments_count) 669 ARTICLE_ATTRIBUTES = %w(followers_count votes_count comments_count)
660 670
661 ARTICLE_ATTRIBUTES.map do |attribute| 671 ARTICLE_ATTRIBUTES.map do |attribute|
test/unit/api/helpers_test.rb
@@ -139,6 +139,10 @@ class APIHelpersTest < ActiveSupport::TestCase @@ -139,6 +139,10 @@ class APIHelpersTest < ActiveSupport::TestCase
139 assert_not_nil make_conditions_with_parameter('until' => '2010-10-10')[:created_at] 139 assert_not_nil make_conditions_with_parameter('until' => '2010-10-10')[:created_at]
140 end 140 end
141 141
  142 + should 'make_conditions_with_parameter return archived parameter if archived was defined' do
  143 + assert_not_nil make_conditions_with_parameter('archived' => true)[:archived]
  144 + end
  145 +
142 should 'make_conditions_with_parameter return created_at as the first existent date as parameter if only until is defined' do 146 should 'make_conditions_with_parameter return created_at as the first existent date as parameter if only until is defined' do
143 assert_equal Time.at(0).to_datetime, make_conditions_with_parameter(:until => '2010-10-10')[:created_at].min 147 assert_equal Time.at(0).to_datetime, make_conditions_with_parameter(:until => '2010-10-10')[:created_at].min
144 end 148 end
@@ -217,15 +221,15 @@ class APIHelpersTest < ActiveSupport::TestCase @@ -217,15 +221,15 @@ class APIHelpersTest < ActiveSupport::TestCase
217 221
218 ###### Captcha tests ###### 222 ###### Captcha tests ######
219 223
220 -# def plugins  
221 -# environment = Environment.default  
222 -# Noosfero::Plugin::Manager.new(environment, self)  
223 -# end  
224 -#  
225 -# should 'do not test captcha when there is no captcha plugin enabled' do  
226 -# environment = Environment.new  
227 -# assert test_captcha("127.0.0.1", {}, environment)  
228 -# end 224 + def plugins
  225 + environment = Environment.default
  226 + Noosfero::Plugin::Manager.new(environment, self)
  227 + end
  228 +
  229 + should 'do not test captcha when there is no captcha plugin enabled' do
  230 + environment = Environment.new
  231 + assert test_captcha("127.0.0.1", {}, environment)
  232 + end
229 233
230 ###### END Captcha tests ###### 234 ###### END Captcha tests ######
231 235