Skip to content
This repository has been archived by the owner on Jan 23, 2020. It is now read-only.

Commit

Permalink
Merge pull request #103 from asebastian/0-10-2-api-updates
Browse files Browse the repository at this point in the history
0 10 2 api updates
  • Loading branch information
asebastian committed Aug 30, 2013
2 parents a0b1de9 + f3ac6c9 commit de9594f
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 27 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ gem 'thin', :group => :development

#testing
group :test, :development do
gem "fake_sensu", "0.1.1"
gem "fake_sensu", "0.1.2"
gem "rspec-rails"
gem "factory_girl_rails"
gem "capybara"
Expand Down
4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ GEM
factory_girl_rails (4.2.1)
factory_girl (~> 4.2.0)
railties (>= 3.0.0)
fake_sensu (0.1.1)
fake_sensu (0.1.2)
rest-client
sinatra
thin
Expand Down Expand Up @@ -208,7 +208,7 @@ DEPENDENCIES
coffee-rails (~> 3.2.1)
devise
factory_girl_rails
fake_sensu (= 0.1.1)
fake_sensu (= 0.1.2)
font-awesome-sass-rails
formtastic
haml-rails
Expand Down
10 changes: 5 additions & 5 deletions app/views/events/_actions.html.haml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
%td{:rel => "#{event.client}_popup_info", :title => "Check Silence", 'data-content' => silenced_output(check_silenced, client_silenced)}
%div.btn-group
%button.btn.btn-info.dropdown-toggle{'data-toggle' => 'dropdown'}
%button.btn.btn-info.dropdown-toggle{:id => "dropdown_toggle_#{i}", 'data-toggle' => 'dropdown'}
%div{:style => "width: 25px"}
%div{:style => "float: left;"}
- display_silenced(event, i, client_silenced, check_silenced)
Expand All @@ -9,16 +9,16 @@
%ul.dropdown-menu
- if client_silenced.nil?
%li
%a.silence-client{:index_id => "#{i}", :misc => "#{event.client}_#{event.check}", :href => "#"} Silence Client
%a.silence-client{:id => "silence_client_#{i}", :index_id => "#{i}", :misc => "#{event.client}_#{event.check}", :href => "#"} Silence Client
- else
%li
%a.unsilence-submit-event{:index_id => "#{i}", :misc => "#{event.client}_#{event.check}", :rel => "/events/#{event.client}/unsilence", :href => "#"} UnSilence Client
%a.unsilence-submit-event{:id => "unsilence_client_#{i}", :index_id => "#{i}", :misc => "#{event.client}_#{event.check}", :rel => "/events/#{event.client}/unsilence", :href => "#"} UnSilence Client
- if check_silenced.nil?
%li
%a.silence-check{:index_id => "#{i}", :misc => "#{event.client}_#{event.check}", :href => "#"} Silence Check
%a.silence-check{:id => "silence_check_#{i}", :index_id => "#{i}", :misc => "#{event.client}_#{event.check}", :href => "#"} Silence Check
- else
%li
%a.unsilence-submit-event{:index_id => "#{i}", :misc => "#{event.client}_#{event.check}", :rel => "/events/#{event.client}/#{event.check}/unsilence", :href => "#"} UnSilence Check
%a.unsilence-submit-event{:id => "unsilence_check_#{i}", :index_id => "#{i}", :misc => "#{event.client}_#{event.check}", :rel => "/events/#{event.client}/#{event.check}/unsilence", :href => "#"} UnSilence Check
%li
%a.resolve-event{:misc => "#row-event-#{i}", :index_id => "#{i}", :rel => "/events/#{event.client}/#{event.check}/resolve"} Resolve
%li
Expand Down
2 changes: 1 addition & 1 deletion spec/features/client_features_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
end

it "should show a client time" do
page.should have_content time_ago_in_words(Time.at(1364343737))
page.should have_content time_ago_in_words(Time.at(1377890282))
end

end
23 changes: 18 additions & 5 deletions spec/features/events_features_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,39 @@
end

it "should show multiple events", :js => true do
page.should have_content "standalone"
page.should have_content "tokens"
page.should have_content "test"
end

it "should show the client for an event", :js => true do
page.should have_content "i-424242"
end

it "should show the check for an event", :js => true do
page.should have_content "standalone"
page.should have_content "test"
end

it "should show the output for an event", :js => true do
page.body.should have_content "i-424242 true"
page.body.should have_content "Crit i-424242"
end

it "should show time since issued for an event", :js => true do
page.should have_content time_ago_in_words(Time.at(1364343741))
page.should have_content time_ago_in_words(Time.at(1377890282))
end

it "should allow a check to be silenced", :js => true do
page.find("#dropdown_toggle_0").click
page.find("#silence_check_0").click
reset_fake_sensu!
end

it "should allow a check to be unsilenced", :js => true do
page.find("#dropdown_toggle_0").click
page.find("#silence_check_0").click
visit '/events'
page.find("#dropdown_toggle_0").click
page.find("#silence_check_0").click
reset_fake_sensu!
end
end

end
4 changes: 2 additions & 2 deletions spec/features/stashes_features_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
end

it "should show stashes and correct data" do
page.should have_content "silence/i-424242/tokens"
page.should have_content "tester"
page.should have_content "Never"
page.should have_content time_ago_in_words(Time.at(1364332102))
page.should have_content "43 years ago"
end

it "should have a delete link" do
Expand Down
4 changes: 2 additions & 2 deletions spec/features/stats_features_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@

it "should show events by check" do
within("#events-by-check") do
page.should have_content "tokens"
page.should have_content "test"
end
end

it "should show events by environment" do
within("#events-by-environment") do
page.should have_content "2"
page.should have_content "1"
end
end

Expand Down
2 changes: 1 addition & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

RSpec.configure do |config|
config.before :suite do
FakeSensu.start! "0.9.12"
FakeSensu.start! "0.10.2"
end
end

Expand Down
14 changes: 6 additions & 8 deletions spec/unit/event_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,16 @@

before :each do
load "#{Rails.root}/db/seeds.rb"
# user = FactoryGirl.create(:user)
# user.add_role :admin
# sign_in_user(user)
end

it "should return all checks through cache" do
events = Event.all_with_cache
events.count.should eq 2
events.count.should eq 1
end

it "should resolve an event" do
events = Event.all
events.count.should eq 2
events.count.should eq 1
event = events[rand(events.length)]
event.resolve.should be_true
# TODO: would be nice if fake_sensu would delete, then switch back after one
Expand All @@ -36,9 +33,10 @@
client = event.client
check = event.check
description = "This is a test description, it is long enough"
event.check_silenced.should_not eq nil
# Event.silence_check(client, check, description, User.first, nil, false, nil)
# event.check_silenced.should eq
event.check_silenced.should eq nil
Event.silence_check(client, check, description, User.first, nil, false, nil)
event.check_silenced.should eq nil
reset_fake_sensu!
end

it "should allow manual resolution of an event" do
Expand Down

0 comments on commit de9594f

Please sign in to comment.