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 5 module API
6 6 module APIHelpers
7 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 10 include SanitizeParams
11 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 656 assert_equal json['articles'].count, 2
657 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 669 ARTICLE_ATTRIBUTES = %w(followers_count votes_count comments_count)
660 670  
661 671 ARTICLE_ATTRIBUTES.map do |attribute|
... ...
test/unit/api/helpers_test.rb
... ... @@ -139,6 +139,10 @@ class APIHelpersTest < ActiveSupport::TestCase
139 139 assert_not_nil make_conditions_with_parameter('until' => '2010-10-10')[:created_at]
140 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 146 should 'make_conditions_with_parameter return created_at as the first existent date as parameter if only until is defined' do
143 147 assert_equal Time.at(0).to_datetime, make_conditions_with_parameter(:until => '2010-10-10')[:created_at].min
144 148 end
... ... @@ -217,15 +221,15 @@ class APIHelpersTest < ActiveSupport::TestCase
217 221  
218 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 234 ###### END Captcha tests ######
231 235  
... ...