summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2012-01-21 14:54:32 +0200
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2012-01-21 14:54:32 +0200
commitf4e3ec29c46752c68b99fa2eb37cfb12463de9f2 (patch)
tree1d87d3f3220c6157322d8c34a95cc9dcbb16c40d /spec
parent3d7b35a37d30365088947de0cf85cc7d4af79162 (diff)
downloadgitlab-ce-f4e3ec29c46752c68b99fa2eb37cfb12463de9f2.tar.gz
fixed commit commenting
Diffstat (limited to 'spec')
-rw-r--r--spec/models/key_spec.rb3
-rw-r--r--spec/models/note_spec.rb54
-rw-r--r--spec/requests/commits_notes_spec.rb5
3 files changed, 58 insertions, 4 deletions
diff --git a/spec/models/key_spec.rb b/spec/models/key_spec.rb
index dec0b9961a3..44963e3cea7 100644
--- a/spec/models/key_spec.rb
+++ b/spec/models/key_spec.rb
@@ -22,11 +22,12 @@ end
# Table name: keys
#
# id :integer not null, primary key
-# user_id :integer not null
+# user_id :integer
# created_at :datetime
# updated_at :datetime
# key :text
# title :string(255)
# identifier :string(255)
+# project_id :integer
#
diff --git a/spec/models/note_spec.rb b/spec/models/note_spec.rb
index ce7488dbb8d..75503fd9a75 100644
--- a/spec/models/note_spec.rb
+++ b/spec/models/note_spec.rb
@@ -1,6 +1,9 @@
require 'spec_helper'
describe Note do
+ let(:project) { Factory :project }
+ let!(:commit) { project.commit }
+
describe "Associations" do
it { should belong_to(:project) }
end
@@ -11,16 +14,60 @@ describe Note do
end
it { Factory.create(:note,
- :project => Factory.create(:project)).should be_valid }
+ :project => project).should be_valid }
describe "Scopes" do
it "should have a today named scope that returns ..." do
Note.today.where_values.should == ["created_at >= '#{Date.today}'"]
end
end
-
+
+ describe "Commit notes" do
+
+ before do
+ @note = Factory :note,
+ :project => project,
+ :noteable_id => commit.id,
+ :noteable_type => "Commit"
+ end
+
+ it "should save a valid note" do
+ @note.noteable_id.should == commit.id
+ @note.target.id.should == commit.id
+ end
+ end
+
+ describe "Pre-line commit notes" do
+ before do
+ @note = Factory :note,
+ :project => project,
+ :noteable_id => commit.id,
+ :noteable_type => "Commit",
+ :line_code => "OLD_1_23"
+ end
+
+ it "should save a valid note" do
+ @note.noteable_id.should == commit.id
+ @note.target.id.should == commit.id
+ end
+
+ it { @note.line_type_id.should == "OLD" }
+ it { @note.line_file_id.should == 1 }
+ it { @note.line_number.should == 23 }
+
+ it { @note.for_line?(1, 23, 34).should be_true }
+ it { @note.for_line?(1, 23, nil).should be_true }
+ it { @note.for_line?(1, 23, 0).should be_true }
+ it { @note.for_line?(1, 23, 23).should be_true }
+
+ it { @note.for_line?(1, nil, 34).should be_false }
+ it { @note.for_line?(1, 24, nil).should be_false }
+ it { @note.for_line?(1, 24, 0).should be_false }
+ it { @note.for_line?(1, 24, 23).should be_false }
+ end
+
describe :authorization do
before do
- @p1 = Factory :project
+ @p1 = project
@p2 = Factory :project, :code => "alien", :path => "legit_1"
@u1 = Factory :user
@u2 = Factory :user
@@ -79,5 +126,6 @@ end
# updated_at :datetime
# project_id :integer
# attachment :string(255)
+# line_code :string(255)
#
diff --git a/spec/requests/commits_notes_spec.rb b/spec/requests/commits_notes_spec.rb
index 69a492e9282..23ca045e267 100644
--- a/spec/requests/commits_notes_spec.rb
+++ b/spec/requests/commits_notes_spec.rb
@@ -19,5 +19,10 @@ describe "Issues" do
it "should conatin new note" do
page.should have_content("I commented this commit")
end
+
+ it "should be displayed when i visit this commit again" do
+ visit project_commit_path(project, commit)
+ page.should have_content("I commented this commit")
+ end
end
end