require 'spec_helper' describe WindowsController do before :each do @user = FactoryGirl.create(:user) controller.stub(:current_user).and_return(@user) controller.stub(:current_user_session).and_return(true) @channel = FactoryGirl.create(:channel, :user => @user) @window = FactoryGirl.create(:window) @channel.windows << @window end describe "PUT 'hide' for window" do it "should update the show_flag on that window" do put 'hide', :channel_id => @channel.id, :id => @window.id response.should be_successful end end describe "POST 'update'" do it "should allow an update" do post 'update', :channel_id => @channel.id, :page => "{\"col\":0,\"positions\":[#{@window.id}]}" response.should be_success end end describe "POST 'update' with invalid position" do it "should fail" do post 'update', :channel_id => @channel.id, :page => "{\"col\":0,\"positions\":[999]}" response.should be_success end end describe "When getting " do it "should render private_windows json" do get 'private_windows', :channel_id => @channel.id, :format => :json response.should be_successful end it "should render show_flag = false" do @channel.windows[0].show_flag = false @channel.save get 'hidden_windows', {:channel_id => @channel.id, :visibility_flag => "private" }, :format => :json response.status.should == 200 end end end describe WindowsController do render_views before :each do @channel = FactoryGirl.create(:channel) @window = FactoryGirl.create(:window, html: "