move capybara scenarios to spec/features

This commit is contained in:
Dmitriy Zaporozhets 2013-02-21 10:41:37 +02:00
parent 9f722427e5
commit 03f6a28ec0
18 changed files with 3 additions and 1 deletions

View file

@ -0,0 +1,51 @@
require 'spec_helper'
describe "Admin::Hooks" do
before do
@project = create(:project)
login_as :admin
@system_hook = create(:system_hook)
end
describe "GET /admin/hooks" do
it "should be ok" do
visit admin_root_path
within ".main_menu" do
click_on "Hooks"
end
current_path.should == admin_hooks_path
end
it "should have hooks list" do
visit admin_hooks_path
page.should have_content(@system_hook.url)
end
end
describe "New Hook" do
before do
@url = Faker::Internet.uri("http")
visit admin_hooks_path
fill_in "hook_url", with: @url
expect { click_button "Add System Hook" }.to change(SystemHook, :count).by(1)
end
it "should open new hook popup" do
page.current_path.should == admin_hooks_path
page.should have_content(@url)
end
end
describe "Test" do
before do
WebMock.stub_request(:post, @system_hook.url)
visit admin_hooks_path
click_link "Test Hook"
end
it { page.current_path.should == admin_hooks_path }
end
end

View file

@ -0,0 +1,76 @@
require 'spec_helper'
describe "Admin::Projects" do
before do
@project = create(:project)
login_as :admin
end
describe "GET /admin/projects" do
before do
visit admin_projects_path
end
it "should be ok" do
current_path.should == admin_projects_path
end
it "should have projects list" do
page.should have_content(@project.name)
end
end
describe "GET /admin/projects/:id" do
before do
visit admin_projects_path
click_link "#{@project.name}"
end
it "should have project info" do
page.should have_content(@project.path)
page.should have_content(@project.name)
end
end
describe "GET /admin/projects/:id/edit" do
before do
visit admin_projects_path
click_link "edit_project_#{@project.id}"
end
it "should have project edit page" do
page.should have_content("Edit project")
page.should have_button("Save Project")
end
describe "Update project" do
before do
fill_in "project_name", with: "Big Bang"
click_button "Save Project"
@project.reload
end
it "should show page with new data" do
page.should have_content("Big Bang")
end
it "should change project entry" do
@project.name.should == "Big Bang"
end
end
end
describe "Add new team member" do
before do
@new_user = create(:user)
visit admin_project_path(@project)
end
it "should create new user" do
select @new_user.name, from: "user_ids"
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
end

View file

@ -0,0 +1,135 @@
require 'spec_helper'
describe "Admin::Users" do
before { login_as :admin }
describe "GET /admin/users" do
before do
visit admin_users_path
end
it "should be ok" do
current_path.should == admin_users_path
end
it "should have users list" do
page.should have_content(@user.email)
page.should have_content(@user.name)
end
end
describe "GET /admin/users/new" do
before do
@password = "123ABC"
visit new_admin_user_path
fill_in "user_name", with: "Big Bang"
fill_in "user_username", with: "bang"
fill_in "user_email", with: "bigbang@mail.com"
fill_in "user_password", with: @password
fill_in "user_password_confirmation", with: @password
end
it "should create new user" do
expect { click_button "Save" }.to change {User.count}.by(1)
end
it "should create user with valid data" do
click_button "Save"
user = User.last
user.name.should == "Big Bang"
user.email.should == "bigbang@mail.com"
end
it "should call send mail" do
Notify.should_receive(:new_user_email)
User.observers.enable :user_observer do
click_button "Save"
end
end
it "should send valid email to user with email & password" do
Gitlab.config.gitlab.stub(:signup_enabled).and_return(false)
User.observers.enable :user_observer do
click_button "Save"
user = User.last
email = ActionMailer::Base.deliveries.last
email.subject.should have_content("Account was created")
email.body.should have_content(user.email)
email.body.should have_content(@password)
end
end
it "should send valid email to user with email without password when signup is enabled" do
Gitlab.config.gitlab.stub(:signup_enabled).and_return(true)
User.observers.enable :user_observer do
click_button "Save"
user = User.last
email = ActionMailer::Base.deliveries.last
email.subject.should have_content("Account was created")
email.body.should have_content(user.email)
email.body.should_not have_content(@password)
end
end
end
describe "GET /admin/users/:id" do
before do
visit admin_users_path
click_link "#{@user.name}"
end
it "should have user info" do
page.should have_content(@user.email)
page.should have_content(@user.name)
page.should have_content(@user.projects_limit)
end
end
describe "GET /admin/users/:id/edit" do
before do
@simple_user = create(:user)
visit admin_users_path
click_link "edit_user_#{@simple_user.id}"
end
it "should have user edit page" do
page.should have_content("Name")
page.should have_content("Password")
end
describe "Update user" do
before do
fill_in "user_name", with: "Big Bang"
fill_in "user_email", with: "bigbang@mail.com"
check "user_admin"
click_button "Save"
end
it "should show page with new data" do
page.should have_content("bigbang@mail.com")
page.should have_content("Big Bang")
end
it "should change user entry" do
@simple_user.reload
@simple_user.name.should == "Big Bang"
@simple_user.is_admin?.should be_true
end
end
end
describe "Add new project" do
before do
@new_project = create(:project)
visit admin_user_path(@user)
end
it "should create new user" do
select @new_project.name, from: "project_ids"
expect { click_button "Add" }.to change { UsersProject.count }.by(1)
page.should have_content @new_project.name
current_path.should == admin_user_path(@user)
end
end
end

View file

@ -0,0 +1,27 @@
require 'spec_helper'
describe "Admin::Projects" do
describe "GET /admin/projects" do
subject { admin_projects_path }
it { should be_allowed_for :admin }
it { should be_denied_for :user }
it { should be_denied_for :visitor }
end
describe "GET /admin/users" do
subject { admin_users_path }
it { should be_allowed_for :admin }
it { should be_denied_for :user }
it { should be_denied_for :visitor }
end
describe "GET /admin/hooks" do
subject { admin_hooks_path }
it { should be_allowed_for :admin }
it { should be_denied_for :user }
it { should be_denied_for :visitor }
end
end