Commit df583bf12d4aa5bdffed6d43aa985e937e08e883

Authored by miks
1 parent b8b6515f

Specs for deploy_keys updated

spec/factories.rb
... ... @@ -56,11 +56,6 @@ Factory.add(:key, Key) do |obj|
56 56 obj.key = File.read(File.join(Rails.root, "db", "pkey.example"))
57 57 end
58 58  
59   -Factory.add(:deploy_key, DeployKey) do |obj|
60   - obj.title = "Example key"
61   - obj.key = File.read(File.join(Rails.root, "db", "pkey.example"))
62   -end
63   -
64 59 Factory.add(:web_hook, WebHook) do |obj|
65 60 obj.url = Faker::Internet.url
66 61 end
... ...
spec/models/deploy_key_spec.rb
... ... @@ -1,29 +0,0 @@
1   -require 'spec_helper'
2   -
3   -describe DeployKey do
4   - describe "Associations" do
5   - it { should belong_to(:project) }
6   - end
7   -
8   - describe "Validation" do
9   - it { should validate_presence_of(:title) }
10   - it { should validate_presence_of(:key) }
11   - end
12   -
13   - it { Factory.create(:deploy_key,
14   - :project => Factory(:project)).should be_valid }
15   -end
16   -# == Schema Information
17   -#
18   -# Table name: deploy_keys
19   -#
20   -# id :integer not null, primary key
21   -# project_id :integer not null
22   -# created_at :datetime
23   -# updated_at :datetime
24   -# key :text
25   -# title :string(255)
26   -# identifier :string(255)
27   -#
28   -
29   -
spec/models/key_spec.rb
... ... @@ -2,7 +2,7 @@ require 'spec_helper'
2 2  
3 3 describe Key do
4 4 describe "Associations" do
5   - it { should belong_to(:user) }
  5 + it { should belong_to(:user) or belong_to(:project) }
6 6 end
7 7  
8 8 describe "Validation" do
... ...
spec/monkeypatch.rb
... ... @@ -24,16 +24,6 @@ class Key
24 24 end
25 25 end
26 26  
27   -class DeployKey
28   - def update_repository
29   - true
30   - end
31   -
32   - def repository_delete_key
33   - true
34   - end
35   -end
36   -
37 27 class UsersProject
38 28 def update_repository
39 29 true
... ...
spec/requests/projects_deploy_keys_spec.rb
... ... @@ -10,7 +10,7 @@ describe "Projects", "DeployKeys" do
10 10  
11 11 describe "GET /keys" do
12 12 before do
13   - @key = Factory :deploy_key, :project => project
  13 + @key = Factory :key, :project => project
14 14 visit project_deploy_keys_path(project)
15 15 end
16 16  
... ... @@ -41,11 +41,11 @@ describe "Projects", "DeployKeys" do
41 41  
42 42 describe "fill in" do
43 43 before do
44   - fill_in "deploy_key_title", :with => "laptop"
45   - fill_in "deploy_key_key", :with => "publickey234="
  44 + fill_in "key_title", :with => "laptop"
  45 + fill_in "key_key", :with => "publickey234="
46 46 end
47 47  
48   - it { expect { click_button "Save" }.to change {DeployKey.count}.by(1) }
  48 + it { expect { click_button "Save" }.to change {Key.count}.by(1) }
49 49  
50 50 it "should add new key to table" do
51 51 click_button "Save"
... ... @@ -58,7 +58,7 @@ describe "Projects", "DeployKeys" do
58 58  
59 59 describe "Show page" do
60 60 before do
61   - @key = Factory :deploy_key, :project => project
  61 + @key = Factory :key, :project => project
62 62 visit project_deploy_key_path(project, @key)
63 63 end
64 64  
... ...