forked from publify/publify
-
Notifications
You must be signed in to change notification settings - Fork 0
/
author_helper_spec.rb
59 lines (47 loc) · 1.96 KB
/
author_helper_spec.rb
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
require 'spec_helper'
describe AuthorsHelper do
describe :display_profile_item do
it 'should display the item as a list item if show_item is true' do
item = display_profile_item('my@jabber.org', 'Jabber:')
item.should have_selector('li', content: 'Jabber: my@jabber.org')
end
it 'should NOT display the item empty' do
item = display_profile_item('', 'Jabber:')
item.should be_nil
end
it 'should display a link if the item is an url' do
item = display_profile_item('http://twitter.com/mytwitter', 'Twitter:')
item.should have_selector('li') do
have_selector('a', content: 'http://twitter.com/mytwitter')
end
end
end
describe :author_link do
context "with an article" do
let(:article) { build(:article, user: author) }
context "with an author with a name to this article" do
let(:author) { build(:user, name: "Henri") }
context "with a link_to_author set in blog" do
let!(:blog) { create(:blog, link_to_author: true) }
it { expect(author_link(article)).to have_selector('a', href: "mailto:#{author.email}", content: author.name) }
end
context "with a no link_to_author set in blog" do
let!(:blog) { create(:blog, link_to_author: false) }
it { expect(author_link(article)).to eq(author.name) }
end
end
context "with an author without a name to this article" do
let(:author) { build(:user, name: "") }
let(:article) { build(:article, user: author, author: "Emile") }
context "with a link_to_author set in blog" do
let!(:blog) { create(:blog, link_to_author: true) }
it { expect(author_link(article)).to eq(article.author) }
end
context "with a no link_to_author set in blog" do
let!(:blog) { create(:blog, link_to_author: false) }
it { expect(author_link(article)).to eq(article.author) }
end
end
end
end
end