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,11 +56,6 @@ Factory.add(:key, Key) do |obj|
56 obj.key = File.read(File.join(Rails.root, "db", "pkey.example")) 56 obj.key = File.read(File.join(Rails.root, "db", "pkey.example"))
57 end 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 Factory.add(:web_hook, WebHook) do |obj| 59 Factory.add(:web_hook, WebHook) do |obj|
65 obj.url = Faker::Internet.url 60 obj.url = Faker::Internet.url
66 end 61 end
spec/models/deploy_key_spec.rb
@@ -1,29 +0,0 @@ @@ -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,7 +2,7 @@ require 'spec_helper'
2 2
3 describe Key do 3 describe Key do
4 describe "Associations" do 4 describe "Associations" do
5 - it { should belong_to(:user) } 5 + it { should belong_to(:user) or belong_to(:project) }
6 end 6 end
7 7
8 describe "Validation" do 8 describe "Validation" do
spec/monkeypatch.rb
@@ -24,16 +24,6 @@ class Key @@ -24,16 +24,6 @@ class Key
24 end 24 end
25 end 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 class UsersProject 27 class UsersProject
38 def update_repository 28 def update_repository
39 true 29 true
spec/requests/projects_deploy_keys_spec.rb
@@ -10,7 +10,7 @@ describe "Projects", "DeployKeys" do @@ -10,7 +10,7 @@ describe "Projects", "DeployKeys" do
10 10
11 describe "GET /keys" do 11 describe "GET /keys" do
12 before do 12 before do
13 - @key = Factory :deploy_key, :project => project 13 + @key = Factory :key, :project => project
14 visit project_deploy_keys_path(project) 14 visit project_deploy_keys_path(project)
15 end 15 end
16 16
@@ -41,11 +41,11 @@ describe "Projects", "DeployKeys" do @@ -41,11 +41,11 @@ describe "Projects", "DeployKeys" do
41 41
42 describe "fill in" do 42 describe "fill in" do
43 before do 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 end 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 it "should add new key to table" do 50 it "should add new key to table" do
51 click_button "Save" 51 click_button "Save"
@@ -58,7 +58,7 @@ describe "Projects", "DeployKeys" do @@ -58,7 +58,7 @@ describe "Projects", "DeployKeys" do
58 58
59 describe "Show page" do 59 describe "Show page" do
60 before do 60 before do
61 - @key = Factory :deploy_key, :project => project 61 + @key = Factory :key, :project => project
62 visit project_deploy_key_path(project, @key) 62 visit project_deploy_key_path(project, @key)
63 end 63 end
64 64