Commit b96af79bb8a312e6870ad62637c0e3372eac32b7
1 parent
e0d1fba1
Exists in
master
and in
4 other branches
Specs for last push widget
Showing
3 changed files
with
57 additions
and
3 deletions
Show diff stats
app/assets/stylesheets/common.scss
app/views/events/_event_last_push.html.haml
| 1 | -- if event && event.branch_name && event.project.merge_requests_enabled | |
| 1 | +- if event && event.branch_name | |
| 2 | 2 | .event_lp |
| 3 | 3 | %div |
| 4 | 4 | = image_tag gravatar_icon(event.author_email), :class => "avatar" |
| ... | ... | @@ -12,5 +12,6 @@ |
| 12 | 12 | = time_ago_in_words(event.created_at) |
| 13 | 13 | ago. |
| 14 | 14 | |
| 15 | - = link_to new_mr_path_from_push_event(event), :title => "New Merge Request", :class => "btn small padded primary" do | |
| 16 | - Merge Request | |
| 15 | + - if event.project.merge_requests_enabled | |
| 16 | + = link_to new_mr_path_from_push_event(event), :title => "New Merge Request", :class => "btn small padded primary" do | |
| 17 | + Create Merge Request | ... | ... |
| ... | ... | @@ -0,0 +1,52 @@ |
| 1 | +require 'spec_helper' | |
| 2 | + | |
| 3 | +describe "Last Push widget" do | |
| 4 | + before { login_as :user } | |
| 5 | + | |
| 6 | + before do | |
| 7 | + @project = Factory :project, :owner => @user | |
| 8 | + @project.add_access(@user, :read) | |
| 9 | + create_push_event | |
| 10 | + visit projects_path | |
| 11 | + end | |
| 12 | + | |
| 13 | + it "should display last push widget with link to merge request page" do | |
| 14 | + page.should have_content "Your last push was to branch new_design" | |
| 15 | + page.should have_link "Create Merge Request" | |
| 16 | + end | |
| 17 | + | |
| 18 | + describe "click create MR" do | |
| 19 | + before { click_link "Create Merge Request" } | |
| 20 | + | |
| 21 | + it { current_path.should == new_project_merge_request_path(@project) } | |
| 22 | + it { find("#merge_request_source_branch").value.should == "new_design" } | |
| 23 | + it { find("#merge_request_target_branch").value.should == "master" } | |
| 24 | + it { find("#merge_request_title").value.should == "\nNew Design" } | |
| 25 | + end | |
| 26 | + | |
| 27 | + | |
| 28 | + def create_push_event | |
| 29 | + data = { | |
| 30 | + :before => "0000000000000000000000000000000000000000", | |
| 31 | + :after => "0220c11b9a3e6c69dc8fd35321254ca9a7b98f7e", | |
| 32 | + :ref => "refs/heads/new_design", | |
| 33 | + :user_id => @user.id, | |
| 34 | + :user_name => @user.name, | |
| 35 | + :repository => { | |
| 36 | + :name => @project.name, | |
| 37 | + :url => "localhost/rubinius", | |
| 38 | + :description => "", | |
| 39 | + :homepage => "localhost/rubinius", | |
| 40 | + :private => true | |
| 41 | + } | |
| 42 | + } | |
| 43 | + | |
| 44 | + @event = Event.create( | |
| 45 | + :project => @project, | |
| 46 | + :action => Event::Pushed, | |
| 47 | + :data => data, | |
| 48 | + :author_id => @user.id | |
| 49 | + ) | |
| 50 | + end | |
| 51 | +end | |
| 52 | + | ... | ... |