Sha256: 9bd539b158641b7c0de98f60d6d30369e98a19e758c24aed3b3c1c0c4dad6ea8
Contents?: true
Size: 1.68 KB
Versions: 11
Compression:
Stored size: 1.68 KB
Contents
describe Flyboy::GoalsController, type: :controller do routes { Flyboy::Engine.routes } let(:goal){ FactoryGirl.create(:flyboy_goal) } describe '#index' do context 'when applying filter' do before(:each) do Flyboy::Goal.destroy_all @goal1 = FactoryGirl.create(:flyboy_goal, status: "open") @goal2 = FactoryGirl.create(:flyboy_goal, status: "closed") end it 'should display both when not filtered' do get :index assigns(:goals).should eq [@goal2, @goal1] end it 'should filter by status closed' do Flyboy::SmallData::FilterForGoals.new(request.cookies) .store(status: "closed") get :index assigns(:goals).should eq [@goal2] end it 'should filter by status open' do Flyboy::SmallData::FilterForGoals.new(request.cookies) .store(status: "open") get :index assigns(:goals).should eq [@goal1] end end end describe "#close" do before(:each) do @goal = FactoryGirl.create(:flyboy_goal, status: "open") end it "should close goal" do patch :close, id: @goal expect(@goal.reload.status).to eq "closed" end it "should redirect to goals path" do patch :close, id: @goal expect(response).to redirect_to goals_path end end describe "#open" do before(:each) do @goal = FactoryGirl.create(:flyboy_goal, status: "closed") end it "should open goal" do patch :open, id: @goal expect(@goal.reload.status).to eq "open" end it "should redirect to goal path" do patch :open, id: @goal expect(response).to redirect_to goal_path(@goal) end end end
Version data entries
11 entries across 11 versions & 1 rubygems