Sha256: b16ff3be84d57ef3c3e72eba82bf7a12c4741a244edee629c94595b5a2149233

Contents?: true

Size: 1.23 KB

Versions: 5

Compression:

Stored size: 1.23 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 show" 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 = flyboy_task_path(task) + "/some-action"
      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

5 entries across 5 versions & 1 rubygems

Version Path
dorsale-3.20.0 spec/controllers/dorsale/flyboy/task_comments_controller_spec.rb
dorsale-3.19.1 spec/controllers/dorsale/flyboy/task_comments_controller_spec.rb
dorsale-3.19.0 spec/controllers/dorsale/flyboy/task_comments_controller_spec.rb
dorsale-3.18.0 spec/controllers/dorsale/flyboy/task_comments_controller_spec.rb
dorsale-3.17.0 spec/controllers/dorsale/flyboy/task_comments_controller_spec.rb