Commit 9b4cb0ca9c1b0a296280bf742bed01a1ac197845

Authored by Luciano Prestes
1 parent 69d3de30

Add tests for API timestamp

Signed-off-by: Luciano Prestes Cavalcanti <lucianopcbr@gmail.com>
test/unit/api/articles_test.rb
... ... @@ -104,6 +104,21 @@ class ArticlesTest &lt; ActiveSupport::TestCase
104 104 assert_not_includes json_page_two["articles"].map { |a| a["id"] }, article_two.id
105 105 end
106 106  
  107 + should 'list articles with timestamp' do
  108 + article_one = fast_create(Article, :profile_id => user.person.id, :name => "Another thing")
  109 + article_two = fast_create(Article, :profile_id => user.person.id, :name => "Some thing")
  110 +
  111 + article_one.updated_at = Time.now + 3.hours
  112 + article_one.save!
  113 +
  114 + params[:timestamp] = Time.now + 1.hours
  115 + get "/api/v1/articles/?#{params.to_query}"
  116 + json = JSON.parse(last_response.body)
  117 +
  118 + assert_includes json["articles"].map { |a| a["id"] }, article_one.id
  119 + assert_not_includes json["articles"].map { |a| a["id"] }, article_two.id
  120 + end
  121 +
107 122 #############################
108 123 # Profile Articles #
109 124 #############################
... ...
test/unit/api/communities_test.rb
... ... @@ -141,4 +141,19 @@ class CommunitiesTest &lt; ActiveSupport::TestCase
141 141 assert_includes json_page_two["communities"].map { |a| a["id"] }, community2.id
142 142 assert_not_includes json_page_two["communities"].map { |a| a["id"] }, community1.id
143 143 end
  144 +
  145 + should 'list communities with timestamp' do
  146 + community1 = fast_create(Community, :public_profile => true)
  147 + community2 = fast_create(Community)
  148 +
  149 + community1.updated_at = Time.now + 3.hours
  150 + community1.save!
  151 +
  152 + params[:timestamp] = Time.now + 1.hours
  153 + get "/api/v1/communities/?#{params.to_query}"
  154 + json = JSON.parse(last_response.body)
  155 +
  156 + assert_includes json["communities"].map { |a| a["id"] }, community1.id
  157 + assert_not_includes json["communities"].map { |a| a["id"] }, community2.id
  158 + end
144 159 end
... ...