File: github_link_spec.rb

package info (click to toggle)
tdiary-contrib 5.0.11-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 2,660 kB
  • sloc: ruby: 17,024; lisp: 546; xml: 451; php: 61; sql: 40; makefile: 18
file content (39 lines) | stat: -rw-r--r-- 1,253 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
$:.unshift(File.dirname(__FILE__))
require 'spec_helper'

describe "github link plugin" do
	let(:plugin) { fake_plugin(:github_link) }
	subject { plugin.gh_link(*args) }

	describe 'repository page' do
		let(:args) { ['tdiary/tdiary-contrib'] }

		it 'should render repository a tag' do
			is_expected.to eq(%(<a href='https://github.com/tdiary/tdiary-contrib'>tdiary-contrib</a>))
		end
	end

	describe 'issues page' do
		let(:args) { ['tdiary/tdiary-contrib#100'] }

		it 'should render issues a tag' do
			is_expected.to eq(%(<a href='https://github.com/tdiary/tdiary-contrib/issues/100'>tdiary-contrib#100</a>))
		end
	end
  context "When given altenative text" do
    let(:text) { 'This project' }
    let(:github_identifier) { 'tdiary/tdiary-contrib' }
    let(:args) { [github_identifier, text] }

		it 'should render repository a tag with the specified text' do
			is_expected.to eq(%(<a href='https://github.com/#{github_identifier}'>#{text}</a>))
		end
    context "but the text is including <script>" do
      let(:text) { '<script>alert("hoge");</script>' }

      it 'should render a link text after sanitizing.' do
        is_expected.not_to eq(%(<a href='https://github.com/#{github_identifier}'>#{text}</a>))
      end
    end
  end
end