diff --git a/app/controllers/channels_controller.rb b/app/controllers/channels_controller.rb index d9efcf5..8aa297a 100644 --- a/app/controllers/channels_controller.rb +++ b/app/controllers/channels_controller.rb @@ -174,7 +174,7 @@ class ChannelsController < ApplicationController session[:errors] = nil end end - format.json { render :json => @channel } + format.json { render :json => @channel.as_json(Channel.public_options) } end end diff --git a/spec/controllers/channels_controller_spec.rb b/spec/controllers/channels_controller_spec.rb index c9ad6a1..2e91abb 100644 --- a/spec/controllers/channels_controller_spec.rb +++ b/spec/controllers/channels_controller_spec.rb @@ -33,6 +33,7 @@ describe ChannelsController do @channel.name.should eq('new name') response.should redirect_to channel_path(@channel.id) end + it "should allow a channel to be deleted " do delete :destroy, :id => @channel.id response.should redirect_to channels_path @@ -134,6 +135,18 @@ describe ChannelsController do end end + describe "show channel" do + it 'shows a channel' do + get :show, id: @channel.id + response.should be_successful + end + it 'returns JSON' do + get :show, id: @channel.id, format: 'json' + JSON.parse(response.body)['name'].should eq(@channel.name) + JSON.parse(response.body)['tags'].should eq([]) + end + end + describe "create channel" do it 'creates a channel' do post :create, {:key => @user.api_key, :name => 'mychannel'}