spec/controllers/flyboy/tasks_controller_spec.rb in flyboy-1.0.7 vs spec/controllers/flyboy/tasks_controller_spec.rb in flyboy-1.1.0

- old
+ new

@@ -6,15 +6,15 @@ let!(:task) { FactoryGirl.create(:flyboy_task, done: false) } let!(:task2) { - FactoryGirl.create(:flyboy_task, goal: task.goal, done: true) + FactoryGirl.create(:flyboy_task, taskable: task.taskable, done: true) } let(:valid_attributes) { - { title: "New Task" , goal_id: task.goal.id, reminder: Date.today, term: Date.today} + { name: "New Task" , taskable_id: task.taskable.id, taskable_type: task.taskable.class, reminder: Date.today, term: Date.today} } describe "#complete" do before(:each) do request.env["HTTP_REFERER"] = "where_i_came_from" @@ -76,36 +76,36 @@ context "when sorting" do before do Flyboy::Goal.destroy_all Flyboy::Task.destroy_all - @goal1 = FactoryGirl.create(:flyboy_goal, title: "Abc") - @goal2 = FactoryGirl.create(:flyboy_goal, title: "dEF") - @goal3 = FactoryGirl.create(:flyboy_goal, title: "xyz") + @goal1 = FactoryGirl.create(:flyboy_goal, name: "Abc") + @goal2 = FactoryGirl.create(:flyboy_goal, name: "dEF") + @goal3 = FactoryGirl.create(:flyboy_goal, name: "xyz") - @task1 = FactoryGirl.create(:flyboy_task, goal: @goal1, title: "Abc", progress: 100, term: "21/12/2012", reminder: "21/12/2012") - @task2 = FactoryGirl.create(:flyboy_task, goal: @goal2, title: "dEF", progress: 0, term: "23/12/2012", reminder: "23/12/2012") - @task3 = FactoryGirl.create(:flyboy_task, goal: @goal3, title: "xyz", progress: 35, term: "22/12/2012", reminder: "22/12/2012") + @task1 = FactoryGirl.create(:flyboy_task, taskable: @goal1, name: "Abc", progress: 100, term: "21/12/2012", reminder: "21/12/2012") + @task2 = FactoryGirl.create(:flyboy_task, taskable: @goal2, name: "dEF", progress: 0, term: "23/12/2012", reminder: "23/12/2012") + @task3 = FactoryGirl.create(:flyboy_task, taskable: @goal3, name: "xyz", progress: 35, term: "22/12/2012", reminder: "22/12/2012") end - it "sorting by goal asc" do - get :index, sort: "goal" + it "sorting by taskable asc" do + get :index, sort: "taskable" expect(assigns(:tasks).to_a).to eq [@task1, @task2, @task3] end - it "sorting by goal desc" do - get :index, sort: "-goal" + it "sorting by taskable desc" do + get :index, sort: "-taskable" expect(assigns(:tasks).to_a).to eq [@task3, @task2, @task1] end - it "sorting by title asc" do - get :index, sort: "title" + it "sorting by name asc" do + get :index, sort: "name" expect(assigns(:tasks).to_a).to eq [@task1, @task2, @task3] end - it "sorting by title desc" do - get :index, sort: "-title" + it "sorting by name desc" do + get :index, sort: "-name" expect(assigns(:tasks).to_a).to eq [@task3, @task2, @task1] end it "sorting by progress asc" do get :index, sort: "progress" @@ -136,11 +136,11 @@ end end describe "GET new" do it "assigns a new task as @task" do - get :new, {:goal_id => task.goal.id} + get :new, {:goal_id => task.taskable.id} assigns(:task).should be_a_new(Flyboy::Task) end end describe "GET edit" do @@ -170,11 +170,11 @@ end end describe "with invalid params" do it "assigns a newly created but unsaved task as @task" do - post :create, task: {title: nil, goal_id: task.goal.id} + post :create, task: {name: nil, taskable_id: task.taskable.id, taskable_type: task.taskable.class} assigns(:task).should be_a_new(Flyboy::Task) end end end @@ -198,10 +198,10 @@ it "assigns the task as @task" do task = Flyboy::Task.create! valid_attributes patch :update, { :id => task.to_param, - :task => {:title => nil} + :task => {:name => nil} } assigns(:task).should eq(task) end end