Commit adc71b6a6ae06a96aa82052012ae6e61bd3a9cb1
1 parent
5afb16e4
Exists in
master
and in
4 other branches
Fix test i broke with ssk key validation. Added Key.user_id as attr_protected
Showing
4 changed files
with
10 additions
and
8 deletions
Show diff stats
app/models/key.rb
| @@ -4,13 +4,15 @@ class Key < ActiveRecord::Base | @@ -4,13 +4,15 @@ class Key < ActiveRecord::Base | ||
| 4 | belongs_to :user | 4 | belongs_to :user |
| 5 | belongs_to :project | 5 | belongs_to :project |
| 6 | 6 | ||
| 7 | + attr_protected :user_id | ||
| 8 | + | ||
| 7 | validates :title, | 9 | validates :title, |
| 8 | presence: true, | 10 | presence: true, |
| 9 | length: { within: 0..255 } | 11 | length: { within: 0..255 } |
| 10 | 12 | ||
| 11 | validates :key, | 13 | validates :key, |
| 12 | presence: true, | 14 | presence: true, |
| 13 | - :format => { :with => /ssh-.{3} / }, | 15 | + format: { :with => /ssh-.{3} / }, |
| 14 | length: { within: 0..5000 } | 16 | length: { within: 0..5000 } |
| 15 | 17 | ||
| 16 | before_save :set_identifier | 18 | before_save :set_identifier |
features/profile/ssh_keys.feature
| @@ -3,8 +3,8 @@ Feature: SSH Keys | @@ -3,8 +3,8 @@ Feature: SSH Keys | ||
| 3 | Given I signin as a user | 3 | Given I signin as a user |
| 4 | And I have ssh keys: | 4 | And I have ssh keys: |
| 5 | | title | | 5 | | title | |
| 6 | - | Work | | ||
| 7 | - | Home | | 6 | + | ssh-rsa Work | |
| 7 | + | ssh-rsa Home | | ||
| 8 | And I visit profile keys page | 8 | And I visit profile keys page |
| 9 | 9 | ||
| 10 | Scenario: I should see SSH keys | 10 | Scenario: I should see SSH keys |
features/step_definitions/profile/profile_keys_steps.rb
| @@ -16,7 +16,7 @@ end | @@ -16,7 +16,7 @@ end | ||
| 16 | 16 | ||
| 17 | Given /^I submit new ssh key "(.*?)"$/ do |arg1| | 17 | Given /^I submit new ssh key "(.*?)"$/ do |arg1| |
| 18 | fill_in "key_title", :with => arg1 | 18 | fill_in "key_title", :with => arg1 |
| 19 | - fill_in "key_key", :with => "publickey234=" | 19 | + fill_in "key_key", :with => "ssh-rsa publickey234=" |
| 20 | click_button "Save" | 20 | click_button "Save" |
| 21 | end | 21 | end |
| 22 | 22 |
spec/requests/projects_deploy_keys_spec.rb
| @@ -42,7 +42,7 @@ describe "Projects", "DeployKeys" do | @@ -42,7 +42,7 @@ describe "Projects", "DeployKeys" do | ||
| 42 | describe "fill in" do | 42 | describe "fill in" do |
| 43 | before do | 43 | before do |
| 44 | fill_in "key_title", with: "laptop" | 44 | fill_in "key_title", with: "laptop" |
| 45 | - fill_in "key_key", with: "publickey234=" | 45 | + fill_in "key_key", with: "ssh-rsa publickey234=" |
| 46 | end | 46 | end |
| 47 | 47 | ||
| 48 | it { expect { click_button "Save" }.to change {Key.count}.by(1) } | 48 | it { expect { click_button "Save" }.to change {Key.count}.by(1) } |
| @@ -55,12 +55,12 @@ describe "Projects", "DeployKeys" do | @@ -55,12 +55,12 @@ describe "Projects", "DeployKeys" do | ||
| 55 | end | 55 | end |
| 56 | end | 56 | end |
| 57 | 57 | ||
| 58 | - describe "Show page" do | 58 | + describe "Show page" do |
| 59 | before do | 59 | before do |
| 60 | @key = Factory :key, project: project | 60 | @key = Factory :key, project: project |
| 61 | - visit project_deploy_key_path(project, @key) | 61 | + visit project_deploy_key_path(project, @key) |
| 62 | end | 62 | end |
| 63 | - | 63 | + |
| 64 | it { page.should have_content @key.title } | 64 | it { page.should have_content @key.title } |
| 65 | it { page.should have_content @key.key[0..10] } | 65 | it { page.should have_content @key.key[0..10] } |
| 66 | end | 66 | end |