diff options
author | gitlabhq <m@gitlabhq.com> | 2011-10-09 00:36:38 +0300 |
---|---|---|
committer | gitlabhq <m@gitlabhq.com> | 2011-10-09 00:36:38 +0300 |
commit | 9ba1224867665844b117fa037e1465bb706b3685 (patch) | |
tree | 52fbfc1cdb55df21843965479c97be0c91121a9a /spec/requests/admin | |
parent | 93efff945215a4407afcaf0cba15ac601b56df0d (diff) | |
download | gitlab-ce-9ba1224867665844b117fa037e1465bb706b3685.tar.gz |
init commit
Diffstat (limited to 'spec/requests/admin')
-rw-r--r-- | spec/requests/admin/admin_projects_spec.rb | 106 | ||||
-rw-r--r-- | spec/requests/admin/admin_users_spec.rb | 102 | ||||
-rw-r--r-- | spec/requests/admin/security_spec.rb | 27 |
3 files changed, 235 insertions, 0 deletions
diff --git a/spec/requests/admin/admin_projects_spec.rb b/spec/requests/admin/admin_projects_spec.rb new file mode 100644 index 00000000000..8aa311e8442 --- /dev/null +++ b/spec/requests/admin/admin_projects_spec.rb @@ -0,0 +1,106 @@ +require 'spec_helper' + +describe "Admin::Projects" do + before do + @project = Factory :project, + :name => "LeGiT", + :code => "LGT" + 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.code) + page.should have_content(@project.name) + end + end + + describe "GET /admin/projects/:id" do + before do + visit admin_projects_path + click_link "Show" + end + + it "should have project info" do + page.should have_content(@project.code) + 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("Name") + page.should have_content("Code") + end + + describe "Update project" do + before do + fill_in "project_name", :with => "Big Bang" + fill_in "project_code", :with => "BB1" + click_button "Save" + @project.reload + end + + it "should show page with new data" do + page.should have_content("BB1") + page.should have_content("Big Bang") + end + + it "should change project entry" do + @project.name.should == "Big Bang" + @project.code.should == "BB1" + end + end + end + + describe "GET /admin/projects/new" do + before do + visit admin_projects_path + click_link "New Project" + end + + it "should be correct path" do + current_path.should == new_admin_project_path + end + + it "should have labels for new project" do + page.should have_content("Name") + page.should have_content("Path") + page.should have_content("Description") + end + end + + describe "POST /admin/projects" do + before do + visit new_admin_project_path + fill_in 'Name', :with => 'NewProject' + fill_in 'Code', :with => 'NPR' + fill_in 'Path', :with => '/tmp/legit_test/legit' + expect { click_button "Save" }.to change { Project.count }.by(1) + @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) + page.should have_content(@project.description) + end + end +end diff --git a/spec/requests/admin/admin_users_spec.rb b/spec/requests/admin/admin_users_spec.rb new file mode 100644 index 00000000000..8d9cbcae2ac --- /dev/null +++ b/spec/requests/admin/admin_users_spec.rb @@ -0,0 +1,102 @@ +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_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).and_return(stub(:deliver => true)) + click_button "Save" + end + + it "should send valid email to user with email & password" 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 + + describe "GET /admin/users/:id" do + before do + visit admin_users_path + click_link "Show" + end + + it "should have user info" do + page.should have_content(@user.email) + page.should have_content(@user.name) + page.should have_content(@user.is_admin?) + end + end + + describe "GET /admin/users/:id/edit" do + before do + @simple_user = Factory :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 +end diff --git a/spec/requests/admin/security_spec.rb b/spec/requests/admin/security_spec.rb new file mode 100644 index 00000000000..743f9f08cef --- /dev/null +++ b/spec/requests/admin/security_spec.rb @@ -0,0 +1,27 @@ +require 'spec_helper' + +describe "Admin::Projects" do + describe "GET /admin/projects" do + it { admin_projects_path.should be_allowed_for :admin } + it { admin_projects_path.should be_denied_for :user } + it { admin_projects_path.should be_denied_for :visitor } + end + + describe "GET /admin/users" do + it { admin_users_path.should be_allowed_for :admin } + it { admin_users_path.should be_denied_for :user } + it { admin_users_path.should be_denied_for :visitor } + end + + describe "GET /admin/team_members" do + it { admin_team_members_path.should be_allowed_for :admin } + it { admin_team_members_path.should be_denied_for :user } + it { admin_team_members_path.should be_denied_for :visitor } + end + + describe "GET /admin/emails" do + it { admin_emails_path.should be_allowed_for :admin } + it { admin_emails_path.should be_denied_for :user } + it { admin_emails_path.should be_denied_for :visitor } + end +end |