Sha256: db3baf4b6b403f73238da9c2fbd4f5662b45b40c84c44da611246990b90118be

Contents?: true

Size: 1.23 KB

Versions: 45

Compression:

Stored size: 1.23 KB

Contents

require "rails_helper"

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

  let(:user) {create(:user)}
  before :each do
    sign_in user
  end

  let(:valid_attributes){
    commentable = DummyModel.create!(name: "A")

    {
      :commentable_id   => commentable.id,
      :commentable_type => commentable.class.to_s,
      :text             => "Hello"
    }
  }

  describe "create" do
    it "should create comment" do
      post :create, comment: valid_attributes, back_url: "/"
      expect(assigns(:comment)).to be_persisted
    end

    it "should redirect to back_url" do
      post :create, comment: valid_attributes, back_url: "/"
      expect(response).to redirect_to("/")
    end
  end

  describe "update" do
    it "should update comment text" do
      comment = create(:dorsale_comment)
      patch :update, id: comment, comment: {text: "New-comment-text"}, back_url: "/"
      expect(response).to redirect_to("/")
      expect(comment.reload.text).to eq "New-comment-text"
    end
  end

  describe "destroy" do
    it "should destroy comment" do
      comment = create(:dorsale_comment)
      delete :destroy, id: comment, back_url: "/"
      expect(response).to redirect_to("/")
    end
  end
end

Version data entries

45 entries across 45 versions & 1 rubygems

Version Path
dorsale-2.6.1 spec/controllers/dorsale/comments_controller_spec.rb
dorsale-2.6.0 spec/controllers/dorsale/comments_controller_spec.rb
dorsale-2.5.0 spec/controllers/dorsale/comments_controller_spec.rb
dorsale-2.4.3 spec/controllers/dorsale/comments_controller_spec.rb
dorsale-2.4.2 spec/controllers/dorsale/comments_controller_spec.rb
dorsale-2.4.1 spec/controllers/dorsale/comments_controller_spec.rb
dorsale-2.4.0 spec/controllers/dorsale/comments_controller_spec.rb
dorsale-2.3.5 spec/controllers/dorsale/comments_controller_spec.rb
dorsale-2.3.4 spec/controllers/dorsale/comments_controller_spec.rb
dorsale-2.3.3 spec/controllers/dorsale/comments_controller_spec.rb
dorsale-2.3.2 spec/controllers/dorsale/comments_controller_spec.rb
dorsale-2.3.1 spec/controllers/dorsale/comments_controller_spec.rb
dorsale-2.3.0 spec/controllers/dorsale/comments_controller_spec.rb
dorsale-2.2.16 spec/controllers/dorsale/comments_controller_spec.rb
dorsale-2.2.15 spec/controllers/dorsale/comments_controller_spec.rb
dorsale-2.2.14 spec/controllers/dorsale/comments_controller_spec.rb
dorsale-2.2.13 spec/controllers/dorsale/comments_controller_spec.rb
dorsale-2.2.12 spec/controllers/dorsale/comments_controller_spec.rb
dorsale-2.2.11 spec/controllers/dorsale/comments_controller_spec.rb
dorsale-2.2.10 spec/controllers/dorsale/comments_controller_spec.rb