snippets_helper_spec.rb 1.66 KB
Newer Older
haseeb's avatar
haseeb committed
1 2 3 4 5 6 7 8 9
require 'spec_helper'

describe SnippetsHelper do
  include IconsHelper

  describe '#embedded_snippet_raw_button' do
    it 'gives view raw button of embedded snippets for project snippets' do
      @snippet = create(:project_snippet, :public)

10
      expect(embedded_snippet_raw_button.to_s).to eq("<a class=\"btn\" target=\"_blank\" rel=\"noopener noreferrer\" title=\"Open raw\" href=\"#{raw_project_snippet_url(@snippet.project, @snippet)}\">#{external_snippet_icon('doc-code')}</a>")
haseeb's avatar
haseeb committed
11 12 13 14 15
    end

    it 'gives view raw button of embedded snippets for personal snippets' do
      @snippet = create(:personal_snippet, :public)

16
      expect(embedded_snippet_raw_button.to_s).to eq("<a class=\"btn\" target=\"_blank\" rel=\"noopener noreferrer\" title=\"Open raw\" href=\"#{raw_snippet_url(@snippet)}\">#{external_snippet_icon('doc-code')}</a>")
haseeb's avatar
haseeb committed
17 18 19 20 21 22 23
    end
  end

  describe '#embedded_snippet_download_button' do
    it 'gives download button of embedded snippets for project snippets' do
      @snippet = create(:project_snippet, :public)

haseeb's avatar
haseeb committed
24
      expect(embedded_snippet_download_button.to_s).to eq("<a class=\"btn\" target=\"_blank\" title=\"Download\" rel=\"noopener noreferrer\" href=\"#{raw_project_snippet_url(@snippet.project, @snippet, inline: false)}\">#{external_snippet_icon('download')}</a>")
haseeb's avatar
haseeb committed
25 26 27 28 29
    end

    it 'gives download button of embedded snippets for personal snippets' do
      @snippet = create(:personal_snippet, :public)

haseeb's avatar
haseeb committed
30
      expect(embedded_snippet_download_button.to_s).to eq("<a class=\"btn\" target=\"_blank\" title=\"Download\" rel=\"noopener noreferrer\" href=\"#{raw_snippet_url(@snippet, inline: false)}\">#{external_snippet_icon('download')}</a>")
haseeb's avatar
haseeb committed
31 32 33
    end
  end
end