fix feeds response for last entry
This commit is contained in:
parent
f1b75e348f
commit
341a49d3e9
@ -190,7 +190,14 @@ class FeedController < ApplicationController
|
|||||||
elsif params[:format] == 'csv'
|
elsif params[:format] == 'csv'
|
||||||
@csv_headers = Feed.select_options(@channel, params)
|
@csv_headers = Feed.select_options(@channel, params)
|
||||||
elsif (params[:format] == 'txt' || params[:format] == 'text' || params[:format] == 'html' || params[:format].blank?)
|
elsif (params[:format] == 'txt' || params[:format] == 'text' || params[:format] == 'html' || params[:format].blank?)
|
||||||
output = add_prepend_append(@feed["field#{params[:field_id]}"])
|
|
||||||
|
# if no field_id, just return the json feed
|
||||||
|
if params[:field_id].blank?
|
||||||
|
output = @feed.to_json
|
||||||
|
else
|
||||||
|
output = add_prepend_append(@feed["field#{params[:field_id]}"])
|
||||||
|
end
|
||||||
|
|
||||||
else
|
else
|
||||||
output = @feed.to_json
|
output = @feed.to_json
|
||||||
end
|
end
|
||||||
|
@ -13,6 +13,7 @@ describe FeedController do
|
|||||||
@feed = FactoryGirl.create(:feed, :field1 => 5, :channel => @channel, :created_at => now, :entry_id => 6)
|
@feed = FactoryGirl.create(:feed, :field1 => 5, :channel => @channel, :created_at => now, :entry_id => 6)
|
||||||
@feed = FactoryGirl.create(:feed, :field1 => 4, :channel => @channel, :created_at => now, :entry_id => 7)
|
@feed = FactoryGirl.create(:feed, :field1 => 4, :channel => @channel, :created_at => now, :entry_id => 7)
|
||||||
@channel.last_entry_id = @feed.entry_id
|
@channel.last_entry_id = @feed.entry_id
|
||||||
|
@channel.field1 = 'temp'
|
||||||
@channel.save
|
@channel.save
|
||||||
|
|
||||||
@user.channels.push @channel
|
@user.channels.push @channel
|
||||||
@ -26,13 +27,25 @@ describe FeedController do
|
|||||||
it "should get first feed" do
|
it "should get first feed" do
|
||||||
get :show, {id: @feed1.id, channel_id: @channel.id, format: 'json'}
|
get :show, {id: @feed1.id, channel_id: @channel.id, format: 'json'}
|
||||||
response.should be_successful
|
response.should be_successful
|
||||||
response.body.should eq("{\"created_at\":\"2013-01-01T00:00:00+00:00\",\"entry_id\":1}" )
|
response.body.should eq("{\"created_at\":\"2013-01-01T00:00:00+00:00\",\"entry_id\":1,\"field1\":\"10\"}" )
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should get last feed" do
|
it "should get last feed" do
|
||||||
get :show, {id: 'last', channel_id: @channel.id, format: 'json'}
|
get :show, {id: 'last', channel_id: @channel.id, format: 'json'}
|
||||||
response.should be_successful
|
response.should be_successful
|
||||||
response.body.should eq("{\"created_at\":\"2013-01-01T00:00:00+00:00\",\"entry_id\":7}" )
|
response.body.should eq("{\"created_at\":\"2013-01-01T00:00:00+00:00\",\"entry_id\":7,\"field1\":\"4\"}" )
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should get last feed (html)" do
|
||||||
|
get :show, {id: 'last', channel_id: @channel.id, field_id: 1}
|
||||||
|
response.should be_successful
|
||||||
|
response.body.should eq("4" )
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should get last feed (html), no field_id specified" do
|
||||||
|
get :show, {id: 'last', channel_id: @channel.id}
|
||||||
|
response.should be_successful
|
||||||
|
response.body.should eq("{\"created_at\":\"2013-01-01T00:00:00+00:00\",\"entry_id\":7,\"field1\":\"4\"}" )
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should get feed last_average" do
|
it "should get feed last_average" do
|
||||||
|
Loading…
Reference in New Issue
Block a user