gitlabhq/spec/requests/issues_spec.rb

241 lines
6.7 KiB
Ruby
Raw Normal View History

2011-10-08 23:36:38 +02:00
require 'spec_helper'
describe "Issues" do
let(:project) { Factory :project }
before do
2011-10-08 23:36:38 +02:00
login_as :user
2011-11-01 21:51:20 +01:00
@user2 = Factory :user
2011-10-08 23:36:38 +02:00
project.add_access(@user, :read, :write)
2011-11-01 21:51:20 +01:00
project.add_access(@user2, :read, :write)
2011-10-08 23:36:38 +02:00
end
describe "GET /issues" do
before do
2011-10-08 23:36:38 +02:00
@issue = Factory :issue,
:author => @user,
:assignee => @user,
:project => project
visit project_issues_path(project)
end
subject { page }
2011-12-08 21:17:53 +01:00
it { should have_content(@issue.title[0..20]) }
2011-10-08 23:36:38 +02:00
it { should have_content(@issue.project.name) }
it { should have_content(@issue.assignee.name) }
2011-11-11 10:29:58 +01:00
it "should render atom feed" do
visit project_issues_path(project, :atom)
page.response_headers['Content-Type'].should have_content("application/atom+xml")
page.body.should have_selector("title", :text => "#{project.name} issues")
page.body.should have_selector("author email", :text => @issue.author_email)
2011-11-15 08:25:26 +01:00
page.body.should have_selector("entry summary", :text => @issue.title)
end
it "should render atom feed via private token" do
logout
visit project_issues_path(project, :atom, :private_token => @user.private_token)
page.response_headers['Content-Type'].should have_content("application/atom+xml")
page.body.should have_selector("title", :text => "#{project.name} issues")
page.body.should have_selector("author email", :text => @issue.author_email)
2011-11-11 10:29:58 +01:00
page.body.should have_selector("entry summary", :text => @issue.title)
end
describe "statuses" do
before do
2011-10-08 23:36:38 +02:00
@closed_issue = Factory :issue,
:author => @user,
:assignee => @user,
:project => project,
:closed => true
end
it "should show only open" do
2011-11-01 21:51:20 +01:00
should have_content(@issue.title[0..25])
2011-10-08 23:36:38 +02:00
should have_no_content(@closed_issue.title)
end
it "should show only closed" do
click_link "Closed"
2011-10-08 23:36:38 +02:00
should have_no_content(@issue.title)
2011-11-01 21:51:20 +01:00
should have_content(@closed_issue.title[0..25])
2011-10-08 23:36:38 +02:00
end
it "should show all" do
click_link "All"
2011-11-01 21:51:20 +01:00
should have_content(@issue.title[0..25])
should have_content(@closed_issue.title[0..25])
2011-10-08 23:36:38 +02:00
end
end
end
describe "New issue", :js => true do
before do
2011-10-08 23:36:38 +02:00
visit project_issues_path(project)
click_link "New Issue"
end
it "should open new issue form" do
2011-12-14 07:58:35 +01:00
page.should have_content("New Issue")
2011-10-08 23:36:38 +02:00
end
describe "fill in" do
2011-11-11 10:29:58 +01:00
describe 'assign to me' do
2011-11-01 21:51:20 +01:00
before do
fill_in "issue_title", :with => "bug 345"
page.execute_script("$('#issue_assignee_id').show();")
select @user.name, :from => "issue_assignee_id"
2011-11-01 21:51:20 +01:00
end
it { expect { click_button "Save" }.to change {Issue.count}.by(1) }
it "should add new issue to table" do
click_button "Save"
page.should_not have_content("Add new issue")
page.should have_content @user.name
page.should have_content "bug 345"
page.should have_content project.name
end
it "should call send mail" do
Notify.should_not_receive(:new_issue_email)
click_button "Save"
end
2011-10-08 23:36:38 +02:00
end
2011-11-11 10:29:58 +01:00
describe 'assign to other' do
2011-11-01 21:51:20 +01:00
before do
fill_in "issue_title", :with => "bug 345"
page.execute_script("$('#issue_assignee_id').show();")
select @user2.name, :from => "issue_assignee_id"
2011-11-01 21:51:20 +01:00
end
it { expect { click_button "Save" }.to change {Issue.count}.by(1) }
it "should add new issue to table" do
click_button "Save"
page.should_not have_content("Add new issue")
page.should have_content @user2.name
page.should have_content "bug 345"
page.should have_content project.name
end
it "should call send mail" do
Notify.should_receive(:new_issue_email).and_return(stub(:deliver => true))
click_button "Save"
end
2011-12-18 17:55:32 +01:00
it "should send valid email to user" do
2011-11-01 21:51:20 +01:00
click_button "Save"
issue = Issue.last
email = ActionMailer::Base.deliveries.last
email.subject.should have_content("New Issue was created")
email.body.should have_content(issue.title)
end
2011-10-08 23:36:38 +02:00
end
end
end
2011-11-11 10:29:58 +01:00
describe "Show issue" do
2011-10-28 11:22:09 +02:00
before do
@issue = Factory :issue,
:author => @user,
:assignee => @user,
:project => project
visit project_issue_path(project, @issue)
end
it "should have valid show page for issue" do
page.should have_content @issue.title
page.should have_content @user.name
end
end
describe "Edit issue", :js => true do
before do
2011-10-08 23:36:38 +02:00
@issue = Factory :issue,
:author => @user,
:assignee => @user,
:project => project
visit project_issues_path(project)
click_link "Edit"
end
it "should open new issue popup" do
2011-10-08 23:36:38 +02:00
page.should have_content("Issue ##{@issue.id}")
end
describe "fill in" do
2011-10-08 23:36:38 +02:00
before do
fill_in "issue_title", :with => "bug 345"
end
it { expect { click_button "Save" }.to_not change {Issue.count} }
it "should update issue fields" do
2011-10-08 23:36:38 +02:00
click_button "Save"
page.should have_content @user.name
page.should have_content "bug 345"
page.should have_content project.name
end
end
end
2011-10-22 06:06:38 +02:00
describe "Search issue", :js => true do
before do
['foobar', 'foobar2', 'gitlab'].each do |title|
@issue = Factory :issue,
:author => @user,
2011-10-22 06:06:38 +02:00
:assignee => @user,
:project => project,
:title => title
2011-10-22 06:06:38 +02:00
@issue.save
end
end
2011-11-11 10:29:58 +01:00
it "should be able to search on different statuses" do
@issue = Issue.first
@issue.closed = true
@issue.save
2011-10-22 06:06:38 +02:00
visit project_issues_path(project)
click_link 'Closed'
fill_in 'issue_search', :with => 'foobar'
2011-11-11 10:29:58 +01:00
page.should have_content 'foobar'
page.should_not have_content 'foobar2'
page.should_not have_content 'gitlab'
end
2011-11-11 10:29:58 +01:00
it "should search for term and return the correct results" do
visit project_issues_path(project)
fill_in 'issue_search', :with => 'foobar'
2011-10-22 06:06:38 +02:00
page.should have_content 'foobar'
page.should have_content 'foobar2'
page.should_not have_content 'gitlab'
end
it "should return all results if term has been cleared" do
visit project_issues_path(project)
fill_in "issue_search", :with => "foobar"
# Because fill_in, :with => "" triggers nothing we need to trigger a keyup event
page.execute_script("$('.issue_search').val('').keyup();");
page.should have_content 'foobar'
page.should have_content 'foobar2'
page.should have_content 'gitlab'
end
end
2011-10-08 23:36:38 +02:00
end