Commit bf8726a273b86886c9f3ae449785c1e9a4cd93e2
1 parent
b6f670c8
Exists in
master
and in
1 other branch
If the user not watch app. Not see the unwatch button
Showing
4 changed files
with
34 additions
and
5 deletions
Show diff stats
app/assets/javascripts/apps.show.js
1 | $(function() { | 1 | $(function() { |
2 | + | ||
2 | $("#watchers_toggle").click(function() { | 3 | $("#watchers_toggle").click(function() { |
3 | $("#watchers_div").slideToggle("slow"); | 4 | $("#watchers_div").slideToggle("slow"); |
4 | }); | 5 | }); |
6 | + | ||
5 | $("#repository_toggle").click(function() { | 7 | $("#repository_toggle").click(function() { |
6 | $("#repository_div").slideToggle("slow"); | 8 | $("#repository_div").slideToggle("slow"); |
7 | }); | 9 | }); |
10 | + | ||
8 | $("#deploys_toggle").click(function() { | 11 | $("#deploys_toggle").click(function() { |
9 | $("#deploys_div").slideToggle("slow"); | 12 | $("#deploys_div").slideToggle("slow"); |
10 | }); | 13 | }); |
app/views/apps/show.html.haml
@@ -15,8 +15,9 @@ | @@ -15,8 +15,9 @@ | ||
15 | = link_to t('.unresolved_errs'), app_path(app), :class => 'button' | 15 | = link_to t('.unresolved_errs'), app_path(app), :class => 'button' |
16 | - else | 16 | - else |
17 | = link_to t('.all_errs'), app_path(app, :all_errs => true), :class => 'button' | 17 | = link_to t('.all_errs'), app_path(app, :all_errs => true), :class => 'button' |
18 | - = link_to t('.unwatch'), app_watcher_path({:app_id => app, :id => current_user.id}), :method => :delete, :class => 'button', :confirm => 'Are you sure?' | ||
19 | 18 | ||
19 | + - if current_user.watching?(app) | ||
20 | + = link_to t('.unwatch'), app_watcher_path({:app_id => app, :id => current_user.id}), :method => :delete, :class => 'button', :confirm => t('.are_you_sure') | ||
20 | %h3#watchers_toggle | 21 | %h3#watchers_toggle |
21 | =t('.watchers') | 22 | =t('.watchers') |
22 | %span.click_span=t('.show_hide') | 23 | %span.click_span=t('.show_hide') |
config/locales/en.yml
@@ -83,6 +83,7 @@ en: | @@ -83,6 +83,7 @@ en: | ||
83 | all_errs: all errs | 83 | all_errs: all errs |
84 | all_users_notified: "All users will be notified when something happens." | 84 | all_users_notified: "All users will be notified when something happens." |
85 | api_key: "API Key:" | 85 | api_key: "API Key:" |
86 | + are_you_sure: 'Are you sure?' | ||
86 | atom_title: "Errbit notices for %{name} at %{host}" | 87 | atom_title: "Errbit notices for %{name} at %{host}" |
87 | deploy_count: "Deploy Count:" | 88 | deploy_count: "Deploy Count:" |
88 | edit: edit | 89 | edit: edit |
spec/views/apps/show.html.haml_spec.rb
@@ -2,17 +2,20 @@ require 'spec_helper' | @@ -2,17 +2,20 @@ require 'spec_helper' | ||
2 | 2 | ||
3 | describe "apps/show.html.haml" do | 3 | describe "apps/show.html.haml" do |
4 | let(:app) { stub_model(App) } | 4 | let(:app) { stub_model(App) } |
5 | + let(:user) { stub_model(User) } | ||
6 | + | ||
7 | + let(:action_bar) do | ||
8 | + view.content_for(:action_bar) | ||
9 | + end | ||
10 | + | ||
5 | before do | 11 | before do |
6 | view.stub(:app).and_return(app) | 12 | view.stub(:app).and_return(app) |
7 | view.stub(:all_errs).and_return(false) | 13 | view.stub(:all_errs).and_return(false) |
8 | view.stub(:deploys).and_return([]) | 14 | view.stub(:deploys).and_return([]) |
9 | - controller.stub(:current_user) { stub_model(User) } | 15 | + controller.stub(:current_user) { user } |
10 | end | 16 | end |
11 | 17 | ||
12 | describe "content_for :action_bar" do | 18 | describe "content_for :action_bar" do |
13 | - def action_bar | ||
14 | - view.content_for(:action_bar) | ||
15 | - end | ||
16 | 19 | ||
17 | it "should confirm the 'cancel' link" do | 20 | it "should confirm the 'cancel' link" do |
18 | render | 21 | render |
@@ -28,5 +31,26 @@ describe "apps/show.html.haml" do | @@ -28,5 +31,26 @@ describe "apps/show.html.haml" do | ||
28 | rendered.should match(/No errs have been/) | 31 | rendered.should match(/No errs have been/) |
29 | end | 32 | end |
30 | end | 33 | end |
34 | + | ||
35 | + context "with user watch application" do | ||
36 | + before do | ||
37 | + user.stub(:watching?).with(app).and_return(true) | ||
38 | + end | ||
39 | + it 'see the unwatch button' do | ||
40 | + render | ||
41 | + expect(action_bar).to include(I18n.t('apps.show.unwatch')) | ||
42 | + end | ||
43 | + end | ||
44 | + | ||
45 | + context "with user not watch application" do | ||
46 | + before do | ||
47 | + user.stub(:watching?).with(app).and_return(false) | ||
48 | + end | ||
49 | + it 'not see the unwatch button' do | ||
50 | + render | ||
51 | + expect(action_bar).to_not include(I18n.t('apps.show.unwatch')) | ||
52 | + end | ||
53 | + end | ||
54 | + | ||
31 | end | 55 | end |
32 | 56 |