This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Fix GET /posts/:id/versions

  • Loading branch information...
Jesse Stuart
Jesse Stuart committed Dec 23, 2012
1 parent dc8b998 commit 2f407679bde00f21a30bff033b5042f991cdcc4b
Showing with 6 additions and 1 deletion.
  1. +4 −1 lib/tentd/model/permissible_post_version.rb
  2. +2 −0 spec/integration/api/posts_spec.rb
@@ -26,7 +26,7 @@ def fetch_with_permissions(params, current_auth)
def slice_params(params)
params = Hashie::Mash.new(params) unless params.kind_of?(Hashie::Mash)
- params.slice(:before_version, :since_version, :until_version, :limit, :return_count, :order)
+ params.slice(:post_id, :before_version, :since_version, :until_version, :limit, :return_count, :order)
end
private
@@ -36,6 +36,9 @@ def sort_reversed?(params)
end
def build_common_fetch_post_versions_query(params, query, query_conditions, query_bindings)
+ query_conditions << "#{table_name}.post_id = ?"
+ query_bindings << params.post_id
+
if params.since_version
query_conditions << "#{table_name}.version > ?"
query_bindings << params.since_version
@@ -552,6 +552,8 @@ def authorize!(*scopes)
it 'should order by version' do
version_12 = Fabricate(:post_version, :post_id => post.id, :public_id => post.public_id, :version => 12)
+ other_post = Fabricate(:post)
+ other_post_version = Fabricate(:post_version, :post_id => other_post.id, :public_id => other_post.public_id, :version => 10)
version_8 = Fabricate(:post_version, :post_id => post.id, :public_id => post.public_id, :version => 8)
get "/posts/#{post.public_id}/versions", params, env

0 comments on commit 2f40767

Please sign in to comment.