diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2013-07-02 11:47:09 +0300 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2013-07-02 11:47:09 +0300 |
commit | ee890f2b2a66be925746f2238dc462a74b0fd219 (patch) | |
tree | bb2e74eb834d5c69f66e42c7a80af1705e616ea9 /spec | |
parent | f49fb5dca1ecf2b1ae6415920de09b4d95c14bb1 (diff) | |
parent | 7588186e8173f53a7f9b86d2b6959d7f94a3caac (diff) | |
download | gitlab-ce-ee890f2b2a66be925746f2238dc462a74b0fd219.tar.gz |
Merge branch 'master' into 6-0-dev
Conflicts:
app/views/dashboard/projects.html.haml
app/views/layouts/_head_panel.html.haml
config/routes.rb
Diffstat (limited to 'spec')
-rw-r--r-- | spec/factories.rb | 7 | ||||
-rw-r--r-- | spec/features/notes_on_merge_requests_spec.rb | 66 | ||||
-rw-r--r-- | spec/fixtures/dk.png | bin | 0 -> 1143 bytes | |||
-rw-r--r-- | spec/routing/project_routing_spec.rb | 2 |
4 files changed, 74 insertions, 1 deletions
diff --git a/spec/factories.rb b/spec/factories.rb index 272623440e1..793bd2434e8 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -1,3 +1,5 @@ +include ActionDispatch::TestProcess + FactoryGirl.define do sequence :sentence, aliases: [:title, :content] do Faker::Lorem.sentence @@ -127,6 +129,7 @@ FactoryGirl.define do factory :note_on_issue, traits: [:on_issue], aliases: [:votable_note] factory :note_on_merge_request, traits: [:on_merge_request] factory :note_on_merge_request_diff, traits: [:on_merge_request, :on_diff] + factory :note_on_merge_request_with_attachment, traits: [:on_merge_request, :with_attachment] trait :on_commit do project factory: :project_with_code @@ -148,6 +151,10 @@ FactoryGirl.define do noteable_id 1 noteable_type "Issue" end + + trait :with_attachment do + attachment { fixture_file_upload(Rails.root + "spec/fixtures/dk.png", "image/png") } + end end factory :event do diff --git a/spec/features/notes_on_merge_requests_spec.rb b/spec/features/notes_on_merge_requests_spec.rb index 24f5437efff..d7bc66dd9c8 100644 --- a/spec/features/notes_on_merge_requests_spec.rb +++ b/spec/features/notes_on_merge_requests_spec.rb @@ -3,6 +3,7 @@ require 'spec_helper' describe "On a merge request", js: true do let!(:project) { create(:project_with_code) } let!(:merge_request) { create(:merge_request, project: project) } + let!(:note) { create(:note_on_merge_request_with_attachment, project: project) } before do login_as :user @@ -72,6 +73,71 @@ describe "On a merge request", js: true do should_not have_css(".note") end end + + describe "when editing a note", js: true do + it "should contain the hidden edit form" do + within("#note_#{note.id}") { should have_css(".note-edit-form", visible: false) } + end + + describe "editing the note" do + before do + find('.note').hover + find(".js-note-edit").click + end + + it "should show the note edit form and hide the note body" do + within("#note_#{note.id}") do + find(".note-edit-form", visible: true).should be_visible + find(".note-text", visible: false).should_not be_visible + end + end + + it "should reset the edit note form textarea with the original content of the note if cancelled" do + find('.note').hover + find(".js-note-edit").click + + within(".note-edit-form") do + fill_in "note[note]", with: "Some new content" + find(".btn-cancel").click + find(".js-note-text", visible: false).text.should == note.note + end + end + + it "appends the edited at time to the note" do + find('.note').hover + find(".js-note-edit").click + + within(".note-edit-form") do + fill_in "note[note]", with: "Some new content" + find(".btn-save").click + end + + within("#note_#{note.id}") do + should have_css(".note-last-update small") + find(".note-last-update small").text.should match(/Edited just now/) + end + end + end + + describe "deleting an attachment" do + before do + find('.note').hover + find(".js-note-edit").click + end + + it "shows the delete link" do + within(".note-attachment") do + should have_css(".js-note-attachment-delete") + end + end + + it "removes the attachment div and resets the edit form" do + find(".js-note-attachment-delete").click + should_not have_css(".note-attachment") + find(".note-edit-form", visible: false).should_not be_visible + end + end + end end describe "On a merge request diff", js: true, focus: true do diff --git a/spec/fixtures/dk.png b/spec/fixtures/dk.png Binary files differnew file mode 100644 index 00000000000..87ce25e877a --- /dev/null +++ b/spec/fixtures/dk.png diff --git a/spec/routing/project_routing_spec.rb b/spec/routing/project_routing_spec.rb index 35de757b18b..831e464f9cb 100644 --- a/spec/routing/project_routing_spec.rb +++ b/spec/routing/project_routing_spec.rb @@ -237,7 +237,7 @@ end # project_snippet GET /:project_id/snippets/:id(.:format) snippets#show # PUT /:project_id/snippets/:id(.:format) snippets#update # DELETE /:project_id/snippets/:id(.:format) snippets#destroy -describe Projects::SnippetsController, "routing" do +describe SnippetsController, "routing" do it "to #raw" do get("/gitlabhq/snippets/1/raw").should route_to('projects/snippets#raw', project_id: 'gitlabhq', id: '1') end |