Permalink
Browse files

Fix HEAD /posts with post_types param

  • Loading branch information...
1 parent 899d7bc commit f8018fc210320667f5b0f48e1a481652b5cdd822 Jesse Stuart committed Dec 22, 2012
Showing with 16 additions and 1 deletion.
  1. +5 −1 lib/tentd/model/permissible_post.rb
  2. +11 −0 spec/integration/api/posts_spec.rb
@@ -156,7 +156,7 @@ def fetch_with_permissions(params, current_auth)
end
if params.post_types
- params.post_types = params.post_types.split(',').map { |url| URI.unescape(url) }
+ params.post_types = parse_array_param(params.post_types)
if params.post_types.any?
query << "AND #{table_name}.type_base IN ?"
query_bindings << params.post_types.map { |t| TentType.new(t).base }
@@ -201,6 +201,10 @@ def get_sort_column(params)
end
end
+ def parse_array_param(value)
+ (value.kind_of?(String) ? value.split(',') : value).map { |url| URI.unescape(url) }
+ end
+
def mentions_relationship_foreign_key
all_association_reflections.find { |a| a[:name] == :mentions }[:keys].first
end
@@ -74,6 +74,17 @@ def authorize!(*scopes)
end
end
+ context 'with post_types param' do
+ it 'should return count of posts' do
+ with_constants "TentD::API::PER_PAGE" => 1 do
+ params[:post_types] = ['type-uri-a', 'type-uri-b'].join(',')
+ head '/posts', params, env
+ expect(last_response.status).to eq(200)
+ expect(last_response.headers['Count']).to eql('0')
+ end
+ end
+ end
+
context 'when read_posts scope authorized' do
let(:authorized_post_types) { ['all'] }
before { authorize!(:read_posts) }

0 comments on commit f8018fc

Please sign in to comment.