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 | 1 | $(function() { |
| 2 | + | |
| 2 | 3 | $("#watchers_toggle").click(function() { |
| 3 | 4 | $("#watchers_div").slideToggle("slow"); |
| 4 | 5 | }); |
| 6 | + | |
| 5 | 7 | $("#repository_toggle").click(function() { |
| 6 | 8 | $("#repository_div").slideToggle("slow"); |
| 7 | 9 | }); |
| 10 | + | |
| 8 | 11 | $("#deploys_toggle").click(function() { |
| 9 | 12 | $("#deploys_div").slideToggle("slow"); |
| 10 | 13 | }); | ... | ... |
app/views/apps/show.html.haml
| ... | ... | @@ -15,8 +15,9 @@ |
| 15 | 15 | = link_to t('.unresolved_errs'), app_path(app), :class => 'button' |
| 16 | 16 | - else |
| 17 | 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 | 21 | %h3#watchers_toggle |
| 21 | 22 | =t('.watchers') |
| 22 | 23 | %span.click_span=t('.show_hide') | ... | ... |
config/locales/en.yml
| ... | ... | @@ -83,6 +83,7 @@ en: |
| 83 | 83 | all_errs: all errs |
| 84 | 84 | all_users_notified: "All users will be notified when something happens." |
| 85 | 85 | api_key: "API Key:" |
| 86 | + are_you_sure: 'Are you sure?' | |
| 86 | 87 | atom_title: "Errbit notices for %{name} at %{host}" |
| 87 | 88 | deploy_count: "Deploy Count:" |
| 88 | 89 | edit: edit | ... | ... |
spec/views/apps/show.html.haml_spec.rb
| ... | ... | @@ -2,17 +2,20 @@ require 'spec_helper' |
| 2 | 2 | |
| 3 | 3 | describe "apps/show.html.haml" do |
| 4 | 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 | 11 | before do |
| 6 | 12 | view.stub(:app).and_return(app) |
| 7 | 13 | view.stub(:all_errs).and_return(false) |
| 8 | 14 | view.stub(:deploys).and_return([]) |
| 9 | - controller.stub(:current_user) { stub_model(User) } | |
| 15 | + controller.stub(:current_user) { user } | |
| 10 | 16 | end |
| 11 | 17 | |
| 12 | 18 | describe "content_for :action_bar" do |
| 13 | - def action_bar | |
| 14 | - view.content_for(:action_bar) | |
| 15 | - end | |
| 16 | 19 | |
| 17 | 20 | it "should confirm the 'cancel' link" do |
| 18 | 21 | render |
| ... | ... | @@ -28,5 +31,26 @@ describe "apps/show.html.haml" do |
| 28 | 31 | rendered.should match(/No errs have been/) |
| 29 | 32 | end |
| 30 | 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 | 55 | end |
| 32 | 56 | ... | ... |