2011-10-08 17:36:38 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe "Admin::Projects" do
|
2011-10-26 09:46:25 -04:00
|
|
|
before do
|
2011-10-08 17:36:38 -04:00
|
|
|
@project = Factory :project,
|
2012-08-10 18:07:50 -04:00
|
|
|
name: "LeGiT",
|
|
|
|
code: "LGT"
|
2011-10-08 17:36:38 -04:00
|
|
|
login_as :admin
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "GET /admin/projects" do
|
2011-10-26 09:46:25 -04:00
|
|
|
before do
|
2011-10-08 17:36:38 -04:00
|
|
|
visit admin_projects_path
|
|
|
|
end
|
|
|
|
|
|
|
|
it "should be ok" do
|
|
|
|
current_path.should == admin_projects_path
|
|
|
|
end
|
|
|
|
|
2011-10-26 09:46:25 -04:00
|
|
|
it "should have projects list" do
|
2011-10-08 17:36:38 -04:00
|
|
|
page.should have_content(@project.name)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2011-10-26 09:46:25 -04:00
|
|
|
describe "GET /admin/projects/:id" do
|
|
|
|
before do
|
2011-10-08 17:36:38 -04:00
|
|
|
visit admin_projects_path
|
2011-11-22 02:55:01 -05:00
|
|
|
click_link "#{@project.name}"
|
2011-10-08 17:36:38 -04:00
|
|
|
end
|
|
|
|
|
2011-10-26 09:46:25 -04:00
|
|
|
it "should have project info" do
|
2011-10-08 17:36:38 -04:00
|
|
|
page.should have_content(@project.code)
|
|
|
|
page.should have_content(@project.name)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2011-10-26 09:46:25 -04:00
|
|
|
describe "GET /admin/projects/:id/edit" do
|
|
|
|
before do
|
2011-10-08 17:36:38 -04:00
|
|
|
visit admin_projects_path
|
|
|
|
click_link "edit_project_#{@project.id}"
|
|
|
|
end
|
|
|
|
|
2011-10-26 09:46:25 -04:00
|
|
|
it "should have project edit page" do
|
2012-07-27 17:42:44 -04:00
|
|
|
page.should have_content("Project name")
|
|
|
|
page.should have_content("URL")
|
2011-10-08 17:36:38 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
describe "Update project" do
|
2011-10-26 09:46:25 -04:00
|
|
|
before do
|
2012-08-10 18:07:50 -04:00
|
|
|
fill_in "project_name", with: "Big Bang"
|
|
|
|
fill_in "project_code", with: "BB1"
|
2012-07-27 17:42:44 -04:00
|
|
|
click_button "Save Project"
|
2011-10-08 17:36:38 -04:00
|
|
|
@project.reload
|
|
|
|
end
|
|
|
|
|
2011-10-26 09:46:25 -04:00
|
|
|
it "should show page with new data" do
|
2011-10-08 17:36:38 -04:00
|
|
|
page.should have_content("BB1")
|
|
|
|
page.should have_content("Big Bang")
|
|
|
|
end
|
|
|
|
|
2011-10-26 09:46:25 -04:00
|
|
|
it "should change project entry" do
|
2011-10-08 17:36:38 -04:00
|
|
|
@project.name.should == "Big Bang"
|
|
|
|
@project.code.should == "BB1"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "GET /admin/projects/new" do
|
2011-10-26 09:46:25 -04:00
|
|
|
before do
|
2011-10-08 17:36:38 -04:00
|
|
|
visit admin_projects_path
|
|
|
|
click_link "New Project"
|
|
|
|
end
|
|
|
|
|
|
|
|
it "should be correct path" do
|
2011-10-26 09:46:25 -04:00
|
|
|
current_path.should == new_admin_project_path
|
2011-10-08 17:36:38 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it "should have labels for new project" do
|
2012-07-27 17:42:44 -04:00
|
|
|
page.should have_content("Project name is")
|
|
|
|
page.should have_content("Git Clone")
|
|
|
|
page.should have_content("URL")
|
2011-10-08 17:36:38 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "POST /admin/projects" do
|
2011-10-26 09:46:25 -04:00
|
|
|
before do
|
2011-10-08 17:36:38 -04:00
|
|
|
visit new_admin_project_path
|
2012-08-10 18:07:50 -04:00
|
|
|
fill_in 'project_name', with: 'NewProject'
|
|
|
|
fill_in 'project_code', with: 'NPR'
|
2012-08-28 21:13:22 -04:00
|
|
|
fill_in 'project_path', with: 'newproject'
|
2012-07-27 17:42:44 -04:00
|
|
|
expect { click_button "Create project" }.to change { Project.count }.by(1)
|
2011-10-08 17:36:38 -04:00
|
|
|
@project = Project.last
|
|
|
|
end
|
|
|
|
|
|
|
|
it "should be correct path" do
|
|
|
|
current_path.should == admin_project_path(@project)
|
|
|
|
end
|
|
|
|
|
|
|
|
it "should show project" do
|
|
|
|
page.should have_content(@project.name)
|
|
|
|
page.should have_content(@project.path)
|
|
|
|
end
|
|
|
|
end
|
2012-02-11 12:56:18 -05:00
|
|
|
|
|
|
|
describe "Add new team member" do
|
|
|
|
before do
|
|
|
|
@new_user = Factory :user
|
|
|
|
visit admin_project_path(@project)
|
|
|
|
end
|
|
|
|
|
|
|
|
it "should create new user" do
|
2012-08-10 18:07:50 -04:00
|
|
|
select @new_user.name, from: "user_ids"
|
2012-02-11 12:56:18 -05:00
|
|
|
expect { click_button "Add" }.to change { UsersProject.count }.by(1)
|
|
|
|
page.should have_content @new_user.name
|
|
|
|
current_path.should == admin_project_path(@project)
|
|
|
|
end
|
|
|
|
end
|
2011-10-08 17:36:38 -04:00
|
|
|
end
|