ruby_bugzilla 0.5.1 → 0.5.2

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.
@@ -0,0 +1 @@
1
+ spec test fake cookies_file
@@ -1,6 +1,9 @@
1
+ require 'fileutils'
1
2
  require 'linux_admin'
3
+ require 'tempfile'
2
4
  require "xmlrpc/client"
3
5
 
6
+
4
7
  class RubyBugzilla
5
8
  CLONE_FIELDS = [:assigned_to, :cc, :cf_devel_whiteboard, :cf_internal_whiteboard, :component,
6
9
  :groups, :keywords, :op_sys, :platform, :priority, :product, :qa_contact, :severity,
@@ -12,14 +15,6 @@ class RubyBugzilla
12
15
  File.exists?(CMD)
13
16
  end
14
17
 
15
- def self.logged_in?
16
- File.exists?(COOKIES_FILE)
17
- end
18
-
19
- def self.clear_login!
20
- File.delete(COOKIES_FILE) if File.exists?(COOKIES_FILE)
21
- end
22
-
23
18
  attr_accessor :bugzilla_uri, :username, :password, :last_command, :xmlrpc
24
19
  attr_reader :bugzilla_request_uri, :bugzilla_request_hostname
25
20
 
@@ -38,6 +33,8 @@ class RubyBugzilla
38
33
  self.password = password
39
34
  self.xmlrpc = ::XMLRPC::Client.new(bugzilla_request_hostname, '/xmlrpc.cgi', 443, nil,
40
35
  nil, username, password, true, 60)
36
+
37
+ login
41
38
  end
42
39
 
43
40
  def inspect
@@ -48,20 +45,21 @@ class RubyBugzilla
48
45
  self.class.installed?
49
46
  end
50
47
 
51
- def logged_in?
52
- self.class.logged_in?
53
- end
54
-
55
48
  def clear_login!
56
- self.class.clear_login!
57
- end
49
+ cookies_file_entry = "HttpOnly_.#{bugzilla_request_hostname}"
58
50
 
59
- def login
60
- if logged_in?
61
- self.last_command = nil
62
- return "Already Logged In"
51
+ if File.exists?(COOKIES_FILE)
52
+ Tempfile.open('ruby_bugzilla') do |out_file|
53
+ File.read(COOKIES_FILE).each_line do |line|
54
+ out_file.puts(line) unless line.include?(cookies_file_entry)
55
+ end
56
+ out_file.close()
57
+ FileUtils.mv(out_file.path, COOKIES_FILE)
58
+ end
63
59
  end
60
+ end
64
61
 
62
+ def login
65
63
  params = {}
66
64
  params["--debug"] = nil
67
65
  params["login"] = [username, password]
@@ -1,3 +1,3 @@
1
1
  class RubyBugzilla
2
- VERSION = "0.5.1"
2
+ VERSION = "0.5.2"
3
3
  end
@@ -7,18 +7,8 @@ describe RubyBugzilla do
7
7
  # Assume most tests have bugzilla installed and logged in by faking with
8
8
  # valid files
9
9
  stub_const("RubyBugzilla::CMD", "/bin/echo")
10
- stub_const("RubyBugzilla::COOKIES_FILE", "/bin/echo")
11
- end
12
-
13
- context ".logged_in?" do
14
- it "with an existing bugzilla cookie" do
15
- RubyBugzilla.logged_in?.should be_true
16
- end
10
+ stub_const("RubyBugzilla::COOKIES_FILE", File.expand_path("data/cookies_file", File.dirname(__FILE__)))
17
11
 
18
- it "with no bugzilla cookie" do
19
- stub_const("RubyBugzilla::COOKIES_FILE", "/This/file/does/not/exist")
20
- RubyBugzilla.logged_in?.should be_false
21
- end
22
12
  end
23
13
 
24
14
  context "#new" do
@@ -42,16 +32,13 @@ describe RubyBugzilla do
42
32
 
43
33
  context "#login" do
44
34
  it "when already logged in" do
45
- output = bz.login
46
-
47
- bz.last_command.should be_nil
48
- output.should include("Already Logged In")
35
+ bz.login
36
+ bz.last_command.should include("login")
49
37
  end
50
38
 
51
39
  it "when not already logged in" do
52
40
  stub_const("RubyBugzilla::COOKIES_FILE", "/This/file/does/not/exist")
53
41
  bz.login
54
-
55
42
  bz.last_command.should include("login")
56
43
  end
57
44
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_bugzilla
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.5.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2014-01-08 00:00:00.000000000 Z
13
+ date: 2014-01-17 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bundler
@@ -107,6 +107,7 @@ files:
107
107
  - LICENSE.txt
108
108
  - README.md
109
109
  - Rakefile
110
+ - data/cookies_file
110
111
  - lib/ruby_bugzilla.rb
111
112
  - lib/ruby_bugzilla/version.rb
112
113
  - ruby_bugzilla.gemspec
@@ -125,12 +126,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
125
126
  - - ! '>='
126
127
  - !ruby/object:Gem::Version
127
128
  version: '0'
129
+ segments:
130
+ - 0
131
+ hash: 1898081452312934278
128
132
  required_rubygems_version: !ruby/object:Gem::Requirement
129
133
  none: false
130
134
  requirements:
131
135
  - - ! '>='
132
136
  - !ruby/object:Gem::Version
133
137
  version: '0'
138
+ segments:
139
+ - 0
140
+ hash: 1898081452312934278
134
141
  requirements: []
135
142
  rubyforge_project:
136
143
  rubygems_version: 1.8.25