show.html.haml_spec.rb
1.26 KB
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
describe "apps/show.html.haml", type: 'view' do
let(:app) { stub_model(App) }
let(:user) { stub_model(User) }
let(:action_bar) do
view.content_for(:action_bar)
end
before do
allow(view).to receive(:app).and_return(app)
allow(view).to receive(:all_errs).and_return(false)
allow(view).to receive(:deploys).and_return([])
allow(controller).to receive(:current_user).and_return(user)
end
describe "content_for :action_bar" do
it "should confirm the 'cancel' link" do
render
expect(action_bar).to have_selector('a.button', :text => 'all errors')
end
end
context "without errs" do
it 'see no errs' do
render
expect(rendered).to match(/No errors have been/)
end
end
context "with user watch application" do
before do
allow(app).to receive(:watched_by?).with(user).and_return(true)
end
it 'see the unwatch button' do
render
expect(action_bar).to include(I18n.t('apps.show.unwatch'))
end
end
context "with user not watch application" do
before do
allow(app).to receive(:watched_by?).with(user).and_return(false)
end
it 'not see the unwatch button' do
render
expect(action_bar).to_not include(I18n.t('apps.show.unwatch'))
end
end
end