cijoe 0.5.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,8 @@
1
1
  class CIJoe
2
2
  module Campfire
3
- def self.activate
3
+ def self.activate(project_path)
4
+ @project_path = project_path
5
+
4
6
  if valid_config?
5
7
  require 'tinder'
6
8
 
@@ -22,12 +24,13 @@ class CIJoe
22
24
  end
23
25
 
24
26
  def self.config
27
+ campfire_config = Config.new('campfire', @project_path)
25
28
  @config ||= {
26
- :subdomain => Config.campfire.subdomain.to_s,
27
- :user => Config.campfire.user.to_s,
28
- :pass => Config.campfire.pass.to_s,
29
- :room => Config.campfire.room.to_s,
30
- :ssl => Config.campfire.ssl.to_s.strip == 'true'
29
+ :subdomain => campfire_config.subdomain.to_s,
30
+ :user => campfire_config.user.to_s,
31
+ :pass => campfire_config.pass.to_s,
32
+ :room => campfire_config.room.to_s,
33
+ :ssl => campfire_config.ssl.to_s.strip == 'true'
31
34
  }
32
35
  end
33
36
 
@@ -47,9 +50,9 @@ class CIJoe
47
50
  def room
48
51
  @room ||= begin
49
52
  config = Campfire.config
50
- campfire = Tinder::Campfire.new(config[:subdomain],
51
- :username => config[:user],
52
- :password => config[:pass],
53
+ campfire = Tinder::Campfire.new(config[:subdomain],
54
+ :username => config[:user],
55
+ :password => config[:pass],
53
56
  :ssl => config[:ssl] || false)
54
57
  campfire.find_room_by_name(config[:room])
55
58
  end
@@ -16,7 +16,7 @@ class CIJoe
16
16
 
17
17
  get '/ping' do
18
18
  if joe.building? || !joe.last_build || !joe.last_build.worked?
19
- halt 412, joe.last_build ? joe.last_build.sha : "building"
19
+ halt 412, (joe.building? || joe.last_build.nil?) ? "building" : joe.last_build.sha
20
20
  end
21
21
 
22
22
  joe.last_build.sha
@@ -61,7 +61,7 @@ class CIJoe
61
61
  check_project
62
62
  @joe = CIJoe.new(options.project_path)
63
63
 
64
- CIJoe::Campfire.activate
64
+ CIJoe::Campfire.activate(options.project_path)
65
65
  end
66
66
 
67
67
  def self.start(host, port, project_path)
@@ -1,3 +1,3 @@
1
1
  class CIJoe
2
- Version = VERSION = "0.5.0"
2
+ Version = VERSION = "0.6.0"
3
3
  end
@@ -33,6 +33,16 @@ class TestCIJoeServer < Test::Unit::TestCase
33
33
  assert_equal "building", last_response.body
34
34
  end
35
35
 
36
+ def test_ping_building_with_a_previous_build
37
+ app.joe.last_build = build :worked
38
+ app.joe.current_build = build :building
39
+ assert app.joe.building?, "buildin' a awsum project"
40
+
41
+ get "/ping"
42
+ assert_equal 412, last_response.status
43
+ assert_equal "building", last_response.body
44
+ end
45
+
36
46
  def test_ping_failed
37
47
  app.joe.last_build = build :failed
38
48
 
@@ -41,10 +51,18 @@ class TestCIJoeServer < Test::Unit::TestCase
41
51
  assert_equal app.joe.last_build.sha, last_response.body
42
52
  end
43
53
 
54
+ def test_ping_should_not_reset_current_build_in_tests
55
+ current_build = build :building
56
+ app.joe.current_build = current_build
57
+ assert app.joe.building?
58
+ get "/ping"
59
+ assert_equal current_build, app.joe.current_build
60
+ end
61
+
44
62
  # Create a new, fake build. All we care about is status.
45
63
 
46
64
  def build status
47
- CIJoe::Build.new "user", "project", Time.now, Time.now,
48
- "deadbeef", status, "output", 1337
65
+ CIJoe::Build.new "path", "user", "project", Time.now, Time.now,
66
+ "deadbeef", status, "output", nil
49
67
  end
50
68
  end
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 5
7
+ - 6
8
8
  - 0
9
- version: 0.5.0
9
+ version: 0.6.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Chris Wanstrath
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-07-24 00:00:00 -07:00
17
+ date: 2010-08-08 00:00:00 -07:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency