diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2012-01-14 23:26:35 +0400 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2012-01-14 23:26:35 +0400 |
commit | cbd78922ee43c0124458e2867071f752cae712f4 (patch) | |
tree | 5367dd4e0370f11bc5733de364016f2572a3323f /spec | |
parent | 09b877ef29a0c641457eb986c5b228d003c51c16 (diff) | |
parent | dda6b0ab63eb8080e34b4273cfb6aadb7a29c028 (diff) |
Merge branch 'deploy_keys'
Conflicts:
app/views/layouts/project.html.haml
db/schema.rb
Diffstat (limited to 'spec')
-rw-r--r-- | spec/models/key_spec.rb | 2 | ||||
-rw-r--r-- | spec/requests/projects_deploy_keys_spec.rb | 68 | ||||
-rw-r--r-- | spec/requests/projects_security_spec.rb | 9 |
3 files changed, 78 insertions, 1 deletions
diff --git a/spec/models/key_spec.rb b/spec/models/key_spec.rb index 6522b825e14..dec0b9961a3 100644 --- a/spec/models/key_spec.rb +++ b/spec/models/key_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' describe Key do describe "Associations" do - it { should belong_to(:user) } + it { should belong_to(:user) or belong_to(:project) } end describe "Validation" do diff --git a/spec/requests/projects_deploy_keys_spec.rb b/spec/requests/projects_deploy_keys_spec.rb new file mode 100644 index 00000000000..8258f2609a1 --- /dev/null +++ b/spec/requests/projects_deploy_keys_spec.rb @@ -0,0 +1,68 @@ +require 'spec_helper' + +describe "Projects", "DeployKeys" do + let(:project) { Factory :project } + + before do + login_as :user + project.add_access(@user, :read, :write, :admin) + end + + describe "GET /keys" do + before do + @key = Factory :key, :project => project + visit project_deploy_keys_path(project) + end + + subject { page } + + it { should have_content(@key.title) } + + describe "Destroy" do + before { visit project_deploy_key_path(project, @key) } + + it "should remove entry" do + expect { + click_link "Remove" + }.to change { project.deploy_keys.count }.by(-1) + end + end + end + + describe "New key", :js => true do + before do + visit project_deploy_keys_path(project) + click_link "New Deploy Key" + end + + it "should open new key popup" do + page.should have_content("Add new public key") + end + + describe "fill in" do + before do + fill_in "key_title", :with => "laptop" + fill_in "key_key", :with => "publickey234=" + end + + it { expect { click_button "Save" }.to change {Key.count}.by(1) } + + it "should add new key to table" do + click_button "Save" + + page.should_not have_content("Add new public key") + page.should have_content "laptop" + end + end + end + + describe "Show page" do + before do + @key = Factory :key, :project => project + visit project_deploy_key_path(project, @key) + end + + it { page.should have_content @key.title } + it { page.should have_content @key.key[0..10] } + end +end diff --git a/spec/requests/projects_security_spec.rb b/spec/requests/projects_security_spec.rb index 2ddeb6e181c..fb9f3d8cc60 100644 --- a/spec/requests/projects_security_spec.rb +++ b/spec/requests/projects_security_spec.rb @@ -105,6 +105,15 @@ describe "Projects" do it { edit_project_path(@project).should be_denied_for :visitor } end + describe "GET /project_code/deploy_keys" do + it { project_deploy_keys_path(@project).should be_allowed_for @u1 } + it { project_deploy_keys_path(@project).should be_denied_for @u3 } + it { project_deploy_keys_path(@project).should be_denied_for :admin } + it { project_deploy_keys_path(@project).should be_denied_for @u2 } + it { project_deploy_keys_path(@project).should be_denied_for :user } + it { project_deploy_keys_path(@project).should be_denied_for :visitor } + end + describe "GET /project_code/issues" do it { project_issues_path(@project).should be_allowed_for @u1 } it { project_issues_path(@project).should be_allowed_for @u3 } |