Commit f8e1f4a7c9ee2554efcf7376a0cfbefae8956d7b

Authored by Riyad Preukschas
1 parent 30227869

Replace commit note request specs with spinach features

features/project/commits/commit_comments.feature
1   -Feature: Project Comment commit
  1 +Feature: Comments on commits
2 2 Background:
3 3 Given I sign in as a user
4 4 And I own project "Shop"
5   - Given I visit project commit page
  5 + And I visit project commit page
6 6  
7 7 @javascript
8   - Scenario: I comment commit
  8 + Scenario: I can comment on a commit
9 9 Given I leave a comment like "XML attached"
10   - Then I should see comment "XML attached"
  10 + Then I should see a comment saying "XML attached"
  11 +
  12 + @javascript
  13 + Scenario: I can't cancel the main form
  14 + Then I should not see the cancel comment button
  15 +
  16 + @javascript
  17 + Scenario: I can't preview without text
  18 + Given I haven't written any comment text
  19 + Then I should not see the comment preview button
  20 +
  21 + @javascript
  22 + Scenario: I can preview with text
  23 + Given I write a comment like "Nice"
  24 + Then I should see the comment preview button
  25 +
  26 + @javascript
  27 + Scenario: I preview a comment
  28 + Given I preview a comment text like "Bug fixed :smile:"
  29 + Then I should see the comment preview
  30 + And I should not see the comment text field
  31 +
  32 + @javascript
  33 + Scenario: I can edit after preview
  34 + Given I preview a comment text like "Bug fixed :smile:"
  35 + Then I should see the comment edit button
  36 +
  37 + @javascript
  38 + Scenario: I have a reset form after posting from preview
  39 + Given I preview a comment text like "Bug fixed :smile:"
  40 + And I submit the comment
  41 + Then I should see an empty comment text field
  42 + And I should not see the comment preview
  43 +
  44 + @javascript
  45 + Scenario: I can delete a comment
  46 + Given I leave a comment like "XML attached"
  47 + And I delete a comment
  48 + Then I should not see a comment saying "XML attached"
... ...
features/steps/project/comments_on_commits.rb 0 → 100644
... ... @@ -0,0 +1,6 @@
  1 +class CommentsOnCommits < Spinach::FeatureSteps
  2 + include SharedAuthentication
  3 + include SharedNote
  4 + include SharedPaths
  5 + include SharedProject
  6 +end
... ...
features/steps/project/project_comment_commit.rb
... ... @@ -1,6 +0,0 @@
1   -class ProjectCommentCommit < Spinach::FeatureSteps
2   - include SharedAuthentication
3   - include SharedProject
4   - include SharedNote
5   - include SharedPaths
6   -end
features/steps/shared/note.rb
1 1 module SharedNote
2 2 include Spinach::DSL
3 3  
  4 + Given 'I delete a comment' do
  5 + first(".js-note-delete").trigger("click")
  6 + end
  7 +
  8 + Given 'I haven\'t written any comment text' do
  9 + within(".js-main-target-form") do
  10 + fill_in "note[note]", with: ""
  11 + end
  12 + end
  13 +
4 14 Given 'I leave a comment like "XML attached"' do
5   - fill_in "note_note", :with => "XML attached"
6   - click_button "Add Comment"
  15 + within(".js-main-target-form") do
  16 + fill_in "note[note]", with: "XML attached"
  17 + click_button "Add Comment"
  18 + end
7 19 end
8 20  
9   - Then 'I should see comment "XML attached"' do
10   - page.should have_content "XML attached"
  21 + Given 'I preview a comment text like "Bug fixed :smile:"' do
  22 + within(".js-main-target-form") do
  23 + fill_in "note[note]", with: "Bug fixed :smile:"
  24 + find(".js-note-preview-button").trigger("click")
  25 + end
11 26 end
12 27  
  28 + Given 'I submit the comment' do
  29 + within(".js-main-target-form") do
  30 + click_button "Add Comment"
  31 + end
  32 + end
  33 +
  34 + Given 'I write a comment like "Nice"' do
  35 + within(".js-main-target-form") do
  36 + fill_in "note[note]", with: "Nice"
  37 + end
  38 + end
  39 +
  40 +
  41 +
  42 + Then 'I should not see a comment saying "XML attached"' do
  43 + page.should_not have_css(".note")
  44 + end
  45 +
  46 + Then 'I should not see the cancel comment button' do
  47 + within(".js-main-target-form") do
  48 + should_not have_link("Cancel")
  49 + end
  50 + end
  51 +
  52 + Then 'I should not see the comment preview' do
  53 + within(".js-main-target-form") do
  54 + page.should have_css(".js-note-preview", visible: false)
  55 + end
  56 + end
  57 +
  58 + Then 'I should not see the comment preview button' do
  59 + within(".js-main-target-form") do
  60 + page.should have_css(".js-note-preview-button", visible: false)
  61 + end
  62 + end
  63 +
  64 + Then 'I should not see the comment text field' do
  65 + within(".js-main-target-form") do
  66 + page.should have_css(".js-note-text", visible: false)
  67 + end
  68 + end
  69 +
  70 + Then 'I should see a comment saying "XML attached"' do
  71 + within(".note") do
  72 + page.should have_content("XML attached")
  73 + end
  74 + end
  75 +
  76 + Then 'I should see an empty comment text field' do
  77 + within(".js-main-target-form") do
  78 + page.should have_field("note[note]", with: "")
  79 + end
  80 + end
  81 +
  82 + Then 'I should see the comment edit button' do
  83 + within(".js-main-target-form") do
  84 + page.should have_css(".js-note-edit-button", visible: true)
  85 + end
  86 + end
  87 +
  88 + Then 'I should see the comment preview' do
  89 + within(".js-main-target-form") do
  90 + page.should have_css(".js-note-preview", visible: true)
  91 + end
  92 + end
  93 +
  94 + Then 'I should see the comment preview button' do
  95 + within(".js-main-target-form") do
  96 + page.should have_css(".js-note-preview-button", visible: true)
  97 + end
  98 + end
  99 +
  100 +
  101 +
  102 + # Wall
  103 +
13 104 Given 'I write new comment "my special test message"' do
14   - fill_in "note_note", :with => "my special test message"
15   - click_button "Add Comment"
  105 + within(".js-main-target-form") do
  106 + fill_in "note[note]", with: "my special test message"
  107 + click_button "Add Comment"
  108 + end
16 109 end
17 110  
18 111 Then 'I should see project wall note "my special test message"' do
... ...
spec/requests/notes_on_commits_spec.rb
1 1 require 'spec_helper'
2 2  
3   -describe "On a commit", js: true do
4   - let!(:project) { create(:project) }
5   - let!(:commit) { project.commit("bcf03b5de6c33f3869ef70d68cf06e679d1d7f9a") }
6   -
7   - before do
8   - login_as :user
9   - project.add_access(@user, :read, :write)
10   -
11   - visit project_commit_path(project, commit)
12   - end
13   -
14   - subject { page }
15   -
16   - describe "the note form" do
17   - # main target form creation
18   - it { should have_css(".js-main-target-form", visible: true, count: 1) }
19   -
20   - # button initalization
21   - it { within(".js-main-target-form") { should have_button("Add Comment") } }
22   - it { within(".js-main-target-form") { should_not have_link("Cancel") } }
23   -
24   - # notifiactions
25   - it { within(".js-main-target-form") { should have_unchecked_field("Project team") } }
26   - it { within(".js-main-target-form") { should have_checked_field("Commit author") } }
27   -
28   - describe "without text" do
29   - it { within(".js-main-target-form") { should have_css(".js-note-preview-button", visible: false) } }
30   - end
31   -
32   - describe "with text" do
33   - before do
34   - within(".js-main-target-form") do
35   - fill_in "note[note]", with: "This is awesome"
36   - end
37   - end
38   -
39   - it { within(".js-main-target-form") { should_not have_css(".js-comment-button[disabled]") } }
40   -
41   - it { within(".js-main-target-form") { should have_css(".js-note-preview-button", visible: true) } }
42   - end
43   -
44   - describe "with preview" do
45   - before do
46   - within(".js-main-target-form") do
47   - fill_in "note[note]", with: "This is awesome"
48   - find(".js-note-preview-button").trigger("click")
49   - end
50   - end
51   -
52   - it { within(".js-main-target-form") { should have_css(".js-note-preview", text: "This is awesome", visible: true) } }
53   -
54   - it { within(".js-main-target-form") { should have_css(".js-note-preview-button", visible: false) } }
55   - it { within(".js-main-target-form") { should have_css(".js-note-edit-button", visible: true) } }
56   - end
57   - end
58   -
59   - describe "when posting a note" do
60   - before do
61   - within(".js-main-target-form") do
62   - fill_in "note[note]", with: "This is awsome!"
63   - find(".js-note-preview-button").trigger("click")
64   - click_button "Add Comment"
65   - end
66   - end
67   -
68   - # note added
69   - it { within(".js-main-target-form") { should have_content("This is awsome!") } }
70   -
71   - # reset form
72   - it { within(".js-main-target-form") { should have_no_field("note[note]", with: "This is awesome!") } }
73   -
74   - # return from preview
75   - it { within(".js-main-target-form") { should have_css(".js-note-preview", visible: false) } }
76   - it { within(".js-main-target-form") { should have_css(".js-note-text", visible: true) } }
77   -
78   -
79   - it "should be removable" do
80   - find(".js-note-delete").trigger("click")
81   -
82   - should_not have_css(".note")
83   - end
84   - end
85   -end
86   -
87   -
88   -
89 3 describe "On a commit diff", js: true do
90 4 let!(:project) { create(:project) }
91   - let!(:commit) { project.commit("bcf03b5de6c33f3869ef70d68cf06e679d1d7f9a") }
  5 + let!(:commit) { project.repository.commit("bcf03b5de6c33f3869ef70d68cf06e679d1d7f9a") }
92 6  
93 7 before do
94 8 login_as :user
95   - project.add_access(@user, :read, :write)
  9 + project.team << [@user, :reporter]
96 10  
97 11 visit project_commit_path(project, commit)
98 12 end
... ...