From b96af79bb8a312e6870ad62637c0e3372eac32b7 Mon Sep 17 00:00:00 2001 From: randx Date: Tue, 12 Jun 2012 21:15:34 +0300 Subject: [PATCH] Specs for last push widget --- app/assets/stylesheets/common.scss | 1 + app/views/events/_event_last_push.html.haml | 7 +-- spec/requests/last_push_widget_spec.rb | 52 +++++++++++++++++++++ 3 files changed, 57 insertions(+), 3 deletions(-) create mode 100644 spec/requests/last_push_widget_spec.rb diff --git a/app/assets/stylesheets/common.scss b/app/assets/stylesheets/common.scss index f7c24191..7a94c127 100644 --- a/app/assets/stylesheets/common.scss +++ b/app/assets/stylesheets/common.scss @@ -745,4 +745,5 @@ li.note { border-style: solid; border-width: 1px; @include border-radius(4px); + min-height:42px; } diff --git a/app/views/events/_event_last_push.html.haml b/app/views/events/_event_last_push.html.haml index 95ae01bd..8c6918d2 100644 --- a/app/views/events/_event_last_push.html.haml +++ b/app/views/events/_event_last_push.html.haml @@ -1,4 +1,4 @@ -- if event && event.branch_name && event.project.merge_requests_enabled +- if event && event.branch_name .event_lp %div = image_tag gravatar_icon(event.author_email), :class => "avatar" @@ -12,5 +12,6 @@ = time_ago_in_words(event.created_at) ago. - = link_to new_mr_path_from_push_event(event), :title => "New Merge Request", :class => "btn small padded primary" do - Merge Request + - if event.project.merge_requests_enabled + = link_to new_mr_path_from_push_event(event), :title => "New Merge Request", :class => "btn small padded primary" do + Create Merge Request diff --git a/spec/requests/last_push_widget_spec.rb b/spec/requests/last_push_widget_spec.rb new file mode 100644 index 00000000..f3d06e86 --- /dev/null +++ b/spec/requests/last_push_widget_spec.rb @@ -0,0 +1,52 @@ +require 'spec_helper' + +describe "Last Push widget" do + before { login_as :user } + + before do + @project = Factory :project, :owner => @user + @project.add_access(@user, :read) + create_push_event + visit projects_path + end + + it "should display last push widget with link to merge request page" do + page.should have_content "Your last push was to branch new_design" + page.should have_link "Create Merge Request" + end + + describe "click create MR" do + before { click_link "Create Merge Request" } + + it { current_path.should == new_project_merge_request_path(@project) } + it { find("#merge_request_source_branch").value.should == "new_design" } + it { find("#merge_request_target_branch").value.should == "master" } + it { find("#merge_request_title").value.should == "\nNew Design" } + end + + + def create_push_event + data = { + :before => "0000000000000000000000000000000000000000", + :after => "0220c11b9a3e6c69dc8fd35321254ca9a7b98f7e", + :ref => "refs/heads/new_design", + :user_id => @user.id, + :user_name => @user.name, + :repository => { + :name => @project.name, + :url => "localhost/rubinius", + :description => "", + :homepage => "localhost/rubinius", + :private => true + } + } + + @event = Event.create( + :project => @project, + :action => Event::Pushed, + :data => data, + :author_id => @user.id + ) + end +end +