Skip to content

Commit

Permalink
Import bugs via pkgwat and show only open ones
Browse files Browse the repository at this point in the history
  • Loading branch information
axilleas committed Jul 5, 2014
1 parent 75ea1b2 commit d27f9f4
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 47 deletions.
1 change: 0 additions & 1 deletion app/models/bug.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
# created_at :datetime
# updated_at :datetime
# last_updated :string(255)
# is_open :boolean
#

# Find bugs assigned to each packaged gem
Expand Down
18 changes: 7 additions & 11 deletions app/models/fedora_rpm.rb
Original file line number Diff line number Diff line change
Expand Up @@ -224,17 +224,13 @@ def retrieve_bugs
puts "Importing rpm #{name} bugs"
bugs.clear

Bicho.client = Bicho::Client.new('https://bugzilla.redhat.com')
Bicho.client.instance_variable_get(:@client)
.http_header_extra = { 'accept-encoding' => 'identity' }
Bicho::Bug.where(summary: name, product: 'fedora').each do |bug|
arb = Bug.new
arb.name = bug['summary']
arb.bz_id = bug['id']
arb.last_updated = bug['last_change_time'].to_time
arb.is_review = true if arb.name =~ /^Review Request.*#{name}\s.*$/
arb.is_open = bug['is_open']
bugs << arb
Pkgwat.get_bugs(name).each do |b|
bug = Bug.new
bug.name = b['description']
bug.bz_id = b['id']
bug.last_updated = b['last_modified']
bug.is_review = true if b['name'] =~ /^Review Request.*#{name}\s.*$/
bugs << bug
end
end

Expand Down
34 changes: 15 additions & 19 deletions app/views/fedorarpms/show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -99,27 +99,23 @@
%td= d.ruby_gem.version
%div.row
%div.col-md-6
%h2
= _('Bugs:')
%table.table.table-striped.table-condensed.table-bordered
%thead
%tr
%th= _('ID')
%th= _('Title')
%th= _('Review?')
%tbody
- @rpm.bugs.each do |b|
- if @rpm.bugs.blank?
%h4 No bugs found!
- else
%h2
= _('Bugs:')
%table.table.table-striped.table-condensed.table-bordered
%thead
%tr
%td
- if b.is_open
%th= _('ID')
%th= _('Title')
%tbody
- @rpm.bugs.each do |b|
%tr
%td
= link_to b.bz_id, b.url
- else
%strike= link_to b.bz_id, b.url
%td
= b.name.truncate(30)
%td
- if b.is_review
%span.glyphicon.glyphicon-ok
%td
= b.name.truncate(60)

%div.col-md-6
%h2
Expand Down
13 changes: 5 additions & 8 deletions spec/factories/bugs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,12 @@
# created_at :datetime
# updated_at :datetime
# last_updated :string(255)
# is_open :boolean
#

# Read about factories at https://github.com/thoughtbot/factory_girl

FactoryGirl.define do
factory :bug do |b|
b.bz_id '12345'
b.is_review true
b.is_open true
factory :bug do
name 'Review Request: rubygem-foo - Short summary'
bz_id '12345'
is_review true
last_updated '6 days and 3 hours'
end
end
12 changes: 4 additions & 8 deletions spec/models/bug_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
require 'rails_helper'

describe Bug do

it 'has valid factory' do
expect(create(:bug)).to be_valid
end
Expand All @@ -33,13 +34,8 @@
expect(@bug.is_review).to eq true
end

it 'bug is open' do
expect(@bug.is_open).to eq true
end

it 'bug is closed' do
@bug.is_open = false
expect(@bug.is_open).to eq false
it 'bug is not a Review Request' do
@bug.is_review = false
expect(@bug.is_review).to_not eq true
end

end

0 comments on commit d27f9f4

Please sign in to comment.