Commit f4e3ec29c46752c68b99fa2eb37cfb12463de9f2
1 parent
3d7b35a3
Exists in
master
and in
4 other branches
fixed commit commenting
Showing
7 changed files
with
84 additions
and
7 deletions
Show diff stats
app/models/key.rb
@@ -55,11 +55,12 @@ end | @@ -55,11 +55,12 @@ end | ||
55 | # Table name: keys | 55 | # Table name: keys |
56 | # | 56 | # |
57 | # id :integer not null, primary key | 57 | # id :integer not null, primary key |
58 | -# user_id :integer not null | 58 | +# user_id :integer |
59 | # created_at :datetime | 59 | # created_at :datetime |
60 | # updated_at :datetime | 60 | # updated_at :datetime |
61 | # key :text | 61 | # key :text |
62 | # title :string(255) | 62 | # title :string(255) |
63 | # identifier :string(255) | 63 | # identifier :string(255) |
64 | +# project_id :integer | ||
64 | # | 65 | # |
65 | 66 |
app/models/note.rb
db/schema.rb
@@ -11,7 +11,19 @@ | @@ -11,7 +11,19 @@ | ||
11 | # | 11 | # |
12 | # It's strongly recommended to check this file into your version control system. | 12 | # It's strongly recommended to check this file into your version control system. |
13 | 13 | ||
14 | -ActiveRecord::Schema.define(:version => 20120119203233) do | 14 | +ActiveRecord::Schema.define(:version => 20120121122616) do |
15 | + | ||
16 | + create_table "features", :force => true do |t| | ||
17 | + t.string "name" | ||
18 | + t.string "branch_name" | ||
19 | + t.integer "assignee_id" | ||
20 | + t.integer "author_id" | ||
21 | + t.integer "project_id" | ||
22 | + t.datetime "created_at" | ||
23 | + t.datetime "updated_at" | ||
24 | + t.string "version" | ||
25 | + t.integer "status", :default => 0, :null => false | ||
26 | + end | ||
15 | 27 | ||
16 | create_table "issues", :force => true do |t| | 28 | create_table "issues", :force => true do |t| |
17 | t.string "title" | 29 | t.string "title" |
@@ -54,7 +66,7 @@ ActiveRecord::Schema.define(:version => 20120119203233) do | @@ -54,7 +66,7 @@ ActiveRecord::Schema.define(:version => 20120119203233) do | ||
54 | 66 | ||
55 | create_table "notes", :force => true do |t| | 67 | create_table "notes", :force => true do |t| |
56 | t.text "note" | 68 | t.text "note" |
57 | - t.integer "noteable_id", :limit => 255 | 69 | + t.string "noteable_id" |
58 | t.string "noteable_type" | 70 | t.string "noteable_type" |
59 | t.integer "author_id" | 71 | t.integer "author_id" |
60 | t.datetime "created_at" | 72 | t.datetime "created_at" |
spec/models/key_spec.rb
@@ -22,11 +22,12 @@ end | @@ -22,11 +22,12 @@ end | ||
22 | # Table name: keys | 22 | # Table name: keys |
23 | # | 23 | # |
24 | # id :integer not null, primary key | 24 | # id :integer not null, primary key |
25 | -# user_id :integer not null | 25 | +# user_id :integer |
26 | # created_at :datetime | 26 | # created_at :datetime |
27 | # updated_at :datetime | 27 | # updated_at :datetime |
28 | # key :text | 28 | # key :text |
29 | # title :string(255) | 29 | # title :string(255) |
30 | # identifier :string(255) | 30 | # identifier :string(255) |
31 | +# project_id :integer | ||
31 | # | 32 | # |
32 | 33 |
spec/models/note_spec.rb
1 | require 'spec_helper' | 1 | require 'spec_helper' |
2 | 2 | ||
3 | describe Note do | 3 | describe Note do |
4 | + let(:project) { Factory :project } | ||
5 | + let!(:commit) { project.commit } | ||
6 | + | ||
4 | describe "Associations" do | 7 | describe "Associations" do |
5 | it { should belong_to(:project) } | 8 | it { should belong_to(:project) } |
6 | end | 9 | end |
@@ -11,16 +14,60 @@ describe Note do | @@ -11,16 +14,60 @@ describe Note do | ||
11 | end | 14 | end |
12 | 15 | ||
13 | it { Factory.create(:note, | 16 | it { Factory.create(:note, |
14 | - :project => Factory.create(:project)).should be_valid } | 17 | + :project => project).should be_valid } |
15 | describe "Scopes" do | 18 | describe "Scopes" do |
16 | it "should have a today named scope that returns ..." do | 19 | it "should have a today named scope that returns ..." do |
17 | Note.today.where_values.should == ["created_at >= '#{Date.today}'"] | 20 | Note.today.where_values.should == ["created_at >= '#{Date.today}'"] |
18 | end | 21 | end |
19 | end | 22 | end |
20 | - | 23 | + |
24 | + describe "Commit notes" do | ||
25 | + | ||
26 | + before do | ||
27 | + @note = Factory :note, | ||
28 | + :project => project, | ||
29 | + :noteable_id => commit.id, | ||
30 | + :noteable_type => "Commit" | ||
31 | + end | ||
32 | + | ||
33 | + it "should save a valid note" do | ||
34 | + @note.noteable_id.should == commit.id | ||
35 | + @note.target.id.should == commit.id | ||
36 | + end | ||
37 | + end | ||
38 | + | ||
39 | + describe "Pre-line commit notes" do | ||
40 | + before do | ||
41 | + @note = Factory :note, | ||
42 | + :project => project, | ||
43 | + :noteable_id => commit.id, | ||
44 | + :noteable_type => "Commit", | ||
45 | + :line_code => "OLD_1_23" | ||
46 | + end | ||
47 | + | ||
48 | + it "should save a valid note" do | ||
49 | + @note.noteable_id.should == commit.id | ||
50 | + @note.target.id.should == commit.id | ||
51 | + end | ||
52 | + | ||
53 | + it { @note.line_type_id.should == "OLD" } | ||
54 | + it { @note.line_file_id.should == 1 } | ||
55 | + it { @note.line_number.should == 23 } | ||
56 | + | ||
57 | + it { @note.for_line?(1, 23, 34).should be_true } | ||
58 | + it { @note.for_line?(1, 23, nil).should be_true } | ||
59 | + it { @note.for_line?(1, 23, 0).should be_true } | ||
60 | + it { @note.for_line?(1, 23, 23).should be_true } | ||
61 | + | ||
62 | + it { @note.for_line?(1, nil, 34).should be_false } | ||
63 | + it { @note.for_line?(1, 24, nil).should be_false } | ||
64 | + it { @note.for_line?(1, 24, 0).should be_false } | ||
65 | + it { @note.for_line?(1, 24, 23).should be_false } | ||
66 | + end | ||
67 | + | ||
21 | describe :authorization do | 68 | describe :authorization do |
22 | before do | 69 | before do |
23 | - @p1 = Factory :project | 70 | + @p1 = project |
24 | @p2 = Factory :project, :code => "alien", :path => "legit_1" | 71 | @p2 = Factory :project, :code => "alien", :path => "legit_1" |
25 | @u1 = Factory :user | 72 | @u1 = Factory :user |
26 | @u2 = Factory :user | 73 | @u2 = Factory :user |
@@ -79,5 +126,6 @@ end | @@ -79,5 +126,6 @@ end | ||
79 | # updated_at :datetime | 126 | # updated_at :datetime |
80 | # project_id :integer | 127 | # project_id :integer |
81 | # attachment :string(255) | 128 | # attachment :string(255) |
129 | +# line_code :string(255) | ||
82 | # | 130 | # |
83 | 131 |
spec/requests/commits_notes_spec.rb
@@ -19,5 +19,10 @@ describe "Issues" do | @@ -19,5 +19,10 @@ describe "Issues" do | ||
19 | it "should conatin new note" do | 19 | it "should conatin new note" do |
20 | page.should have_content("I commented this commit") | 20 | page.should have_content("I commented this commit") |
21 | end | 21 | end |
22 | + | ||
23 | + it "should be displayed when i visit this commit again" do | ||
24 | + visit project_commit_path(project, commit) | ||
25 | + page.should have_content("I commented this commit") | ||
26 | + end | ||
22 | end | 27 | end |
23 | end | 28 | end |