Sha256: 84b747652f1911709ef9eb865fa4c5282391565824ec552729e882b96de46bda

Contents?: true

Size: 1.2 KB

Versions: 23

Compression:

Stored size: 1.2 KB

Contents

require "rails_helper"

describe Dorsale::Flyboy::TaskCommentsController, type: :controller do
  routes { Dorsale::Engine.routes }

  let(:user) { create(:user) }

  before(:each) { sign_in(user) }

  let(:task)         { create(:flyboy_task) }
  let(:task_comment) { create(:flyboy_task_comment, task: task) }

  describe "#create" do
    let(:valid_params) { {task_id: task.id, task_comment: task_comment.attributes} }

    it "should create the task_comment" do
      post :create, params: valid_params
      expect(assigns(:task_comment).persisted?).to be true
    end

    it "should redirect to referrer if referrer is task" do
      url = flyboy_task_path(task) + "?sort=xxx"
      request.env["HTTP_REFERER"] = url
      post :create, params: valid_params
      expect(response).to redirect_to url
    end

    it "should redirect to task if referrer is not task" do
      url = "/anywhere"
      request.env["HTTP_REFERER"] = url
      post :create, params: valid_params
      expect(response).to redirect_to flyboy_task_path(task)
    end

    it "should redirect to task if referrer is missing" do
      post :create, params: valid_params
      expect(response).to redirect_to flyboy_task_path(task)
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
dorsale-3.16.0 spec/controllers/dorsale/flyboy/task_comments_controller_spec.rb
dorsale-3.15.0 spec/controllers/dorsale/flyboy/task_comments_controller_spec.rb
dorsale-3.14.11 spec/controllers/dorsale/flyboy/task_comments_controller_spec.rb
dorsale-3.14.10 spec/controllers/dorsale/flyboy/task_comments_controller_spec.rb
dorsale-3.14.9 spec/controllers/dorsale/flyboy/task_comments_controller_spec.rb
dorsale-3.14.8 spec/controllers/dorsale/flyboy/task_comments_controller_spec.rb
dorsale-3.14.7 spec/controllers/dorsale/flyboy/task_comments_controller_spec.rb
dorsale-3.14.6 spec/controllers/dorsale/flyboy/task_comments_controller_spec.rb
dorsale-3.14.5 spec/controllers/dorsale/flyboy/task_comments_controller_spec.rb
dorsale-3.14.3 spec/controllers/dorsale/flyboy/task_comments_controller_spec.rb
dorsale-3.14.2 spec/controllers/dorsale/flyboy/task_comments_controller_spec.rb
dorsale-3.14.1 spec/controllers/dorsale/flyboy/task_comments_controller_spec.rb
dorsale-3.14.0 spec/controllers/dorsale/flyboy/task_comments_controller_spec.rb
dorsale-3.13.0 spec/controllers/dorsale/flyboy/task_comments_controller_spec.rb
dorsale-3.12.0 spec/controllers/dorsale/flyboy/task_comments_controller_spec.rb
dorsale-3.11.0 spec/controllers/dorsale/flyboy/task_comments_controller_spec.rb
dorsale-3.10.3 spec/controllers/dorsale/flyboy/task_comments_controller_spec.rb
dorsale-3.10.2 spec/controllers/dorsale/flyboy/task_comments_controller_spec.rb
dorsale-3.10.1 spec/controllers/dorsale/flyboy/task_comments_controller_spec.rb
dorsale-3.10.0 spec/controllers/dorsale/flyboy/task_comments_controller_spec.rb