2011-10-08 23:36:38 +02:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe "Issues" do
|
|
|
|
let(:project) { Factory :project }
|
|
|
|
|
2011-10-26 15:46:25 +02:00
|
|
|
before do
|
2011-10-08 23:36:38 +02:00
|
|
|
login_as :user
|
|
|
|
project.add_access(@user, :read, :write)
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "GET /issues" do
|
2011-10-26 15:46:25 +02:00
|
|
|
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 }
|
|
|
|
|
|
|
|
it { should have_content(@issue.title) }
|
|
|
|
it { should have_content(@issue.project.name) }
|
|
|
|
it { should have_content(@issue.assignee.name) }
|
|
|
|
|
2011-10-26 15:46:25 +02:00
|
|
|
describe "Destroy" do
|
|
|
|
before do
|
2011-10-08 23:36:38 +02:00
|
|
|
# admin access to remove issue
|
|
|
|
@user.users_projects.destroy_all
|
|
|
|
project.add_access(@user, :read, :write, :admin)
|
|
|
|
visit project_issues_path(project)
|
|
|
|
end
|
|
|
|
|
2011-10-26 15:46:25 +02:00
|
|
|
it "should remove entry" do
|
2011-10-08 23:36:38 +02:00
|
|
|
expect {
|
|
|
|
click_link "destroy_issue_#{@issue.id}"
|
|
|
|
}.to change { Issue.count }.by(-1)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2011-10-26 15:46:25 +02:00
|
|
|
describe "statuses", :js => true do
|
|
|
|
before do
|
2011-10-08 23:36:38 +02:00
|
|
|
@closed_issue = Factory :issue,
|
|
|
|
:author => @user,
|
|
|
|
:assignee => @user,
|
|
|
|
:project => project,
|
|
|
|
:closed => true
|
|
|
|
end
|
|
|
|
|
2011-10-26 15:46:25 +02:00
|
|
|
it "should show only open" do
|
2011-10-08 23:36:38 +02:00
|
|
|
should have_content(@issue.title)
|
|
|
|
should have_no_content(@closed_issue.title)
|
|
|
|
end
|
|
|
|
|
2011-10-26 15:46:25 +02:00
|
|
|
it "should show only closed" do
|
2011-10-08 23:36:38 +02:00
|
|
|
choose "closed_issues"
|
|
|
|
should have_no_content(@issue.title)
|
|
|
|
should have_content(@closed_issue.title)
|
|
|
|
end
|
|
|
|
|
2011-10-26 15:46:25 +02:00
|
|
|
it "should show all" do
|
2011-10-08 23:36:38 +02:00
|
|
|
choose "all_issues"
|
|
|
|
should have_content(@issue.title)
|
|
|
|
should have_content(@closed_issue.title)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2011-10-26 15:46:25 +02:00
|
|
|
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
|
|
|
|
|
2011-10-26 15:46:25 +02:00
|
|
|
it "should open new issue popup" do
|
2011-10-08 23:36:38 +02:00
|
|
|
page.should have_content("Add new issue")
|
|
|
|
end
|
|
|
|
|
2011-10-26 15:46:25 +02:00
|
|
|
describe "fill in" do
|
2011-10-08 23:36:38 +02:00
|
|
|
before do
|
|
|
|
fill_in "issue_title", :with => "bug 345"
|
|
|
|
fill_in "issue_content", :with => "app bug 345"
|
|
|
|
click_link "Select user"
|
|
|
|
click_link @user.name
|
|
|
|
end
|
|
|
|
|
|
|
|
it { expect { click_button "Save" }.to change {Issue.count}.by(1) }
|
|
|
|
|
2011-10-26 15:46:25 +02:00
|
|
|
it "should add new issue to table" do
|
2011-10-08 23:36:38 +02:00
|
|
|
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
|
|
|
|
|
2011-10-26 15:46:25 +02:00
|
|
|
it "should call send mail" do
|
2011-10-08 23:36:38 +02:00
|
|
|
Notify.should_receive(:new_issue_email).and_return(stub(:deliver => true))
|
|
|
|
click_button "Save"
|
|
|
|
end
|
|
|
|
|
2011-10-26 15:46:25 +02:00
|
|
|
it "should send valid email to user with email & password" do
|
2011-10-08 23:36:38 +02: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)
|
|
|
|
email.body.should have_content(issue.assignee.name)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2011-10-26 15:46:25 +02:00
|
|
|
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
|
|
|
|
|
2011-10-26 15:46:25 +02:00
|
|
|
it "should open new issue popup" do
|
2011-10-08 23:36:38 +02:00
|
|
|
page.should have_content("Issue ##{@issue.id}")
|
|
|
|
end
|
|
|
|
|
2011-10-26 15:46:25 +02:00
|
|
|
describe "fill in" do
|
2011-10-08 23:36:38 +02:00
|
|
|
before do
|
|
|
|
fill_in "issue_title", :with => "bug 345"
|
|
|
|
fill_in "issue_content", :with => "app bug 345"
|
|
|
|
end
|
|
|
|
|
|
|
|
it { expect { click_button "Save" }.to_not change {Issue.count} }
|
|
|
|
|
2011-10-26 15:46:25 +02:00
|
|
|
it "should update issue fields" do
|
2011-10-08 23:36:38 +02:00
|
|
|
click_button "Save"
|
|
|
|
|
|
|
|
page.should_not have_content("Issue ##{@issue.id}")
|
|
|
|
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,
|
2011-10-26 02:15:11 +02:00
|
|
|
:author => @user,
|
2011-10-22 06:06:38 +02:00
|
|
|
:assignee => @user,
|
2011-10-26 02:15:11 +02:00
|
|
|
:project => project,
|
|
|
|
:title => title
|
2011-10-22 06:06:38 +02:00
|
|
|
@issue.save
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2011-10-26 02:15:11 +02: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)
|
2011-10-26 02:15:11 +02:00
|
|
|
choose 'closed_issues'
|
|
|
|
fill_in 'issue_search', :with => 'foobar'
|
|
|
|
|
|
|
|
page.should have_content 'foobar'
|
|
|
|
page.should_not have_content 'foobar2'
|
|
|
|
page.should_not have_content 'gitlab'
|
|
|
|
end
|
|
|
|
|
|
|
|
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
|
|
|
|
|
2011-10-26 02:15:11 +02:00
|
|
|
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
|