Commit 77cf662034a7187fe7e223e6d16b664b7b525d25

Authored by randx
1 parent ed247b38

Pushed widget improved

app/helpers/application_helper.rb
... ... @@ -88,4 +88,9 @@ module ApplicationHelper
88 88 def app_theme
89 89 Gitlab::Theme.css_class_by_id(current_user.try(:theme_id))
90 90 end
  91 +
  92 + def show_last_push_widget?(event)
  93 + event && event.last_push_to_non_root? &&
  94 + event.project && event.project.merge_requests_enabled
  95 + end
91 96 end
... ...
app/roles/account.rb
... ... @@ -48,8 +48,8 @@ module Account
48 48 end
49 49  
50 50 def recent_push project_id = nil
51   - # Get push events not earlier than 6 hours ago
52   - events = recent_events.code_push.where("created_at > ?", Time.now - 6.hours)
  51 + # Get push events not earlier than 2 hours ago
  52 + events = recent_events.code_push.where("created_at > ?", Time.now - 2.hours)
53 53 events = events.where(:project_id => project_id) if project_id
54 54  
55 55 # Take only latest one
... ...
app/roles/push_event.rb
... ... @@ -9,6 +9,10 @@ module PushEvent
9 9 data[:ref]["refs/tags"]
10 10 end
11 11  
  12 + def branch?
  13 + data[:ref]["refs/heads"]
  14 + end
  15 +
12 16 def new_branch?
13 17 commit_from =~ /^00000/
14 18 end
... ... @@ -87,4 +91,8 @@ module PushEvent
87 91 def push_with_commits?
88 92 md_ref? && commits.any? && parent_commit && last_commit
89 93 end
  94 +
  95 + def last_push_to_non_root?
  96 + branch? && project.default_branch != branch_name
  97 + end
90 98 end
... ...
app/views/events/_event_last_push.html.haml
1   -- if event && event.branch_name
  1 +- if show_last_push_widget?(event)
2 2 .event_lp
3 3 %div
4 4 = image_tag gravatar_icon(event.author_email), :class => "avatar"
5   - %span Your last push was to
  5 + %span Your pushed to
6 6 = event.ref_type
7 7 = link_to project_commits_path(event.project, :ref => event.ref_name) do
8 8 %strong= event.ref_name
... ... @@ -12,6 +12,5 @@
12 12 = time_ago_in_words(event.created_at)
13 13 ago.
14 14  
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
  15 + = link_to new_mr_path_from_push_event(event), :title => "New Merge Request", :class => "btn small padded primary" do
  16 + Create Merge Request
... ...
app/views/projects/show.html.haml
... ... @@ -21,12 +21,6 @@
21 21 Issue
22 22  
23 23 = render "events/event_last_push", :event => @last_push
24   -- unless @events.blank?
25   - %br
26   - %h5.cgray
27   - %span.ico.activities
28   - Recent Activity
29   - %hr
30   - .content_list= render @events
  24 +.content_list= render @events
31 25  
32 26  
... ...
features/step_definitions/dashboard_steps.rb
... ... @@ -42,7 +42,7 @@ Given /^project "(.*?)" has push event$/ do |arg1|
42 42 end
43 43  
44 44 Then /^I should see last push widget$/ do
45   - page.should have_content "Your last push was to branch new_design"
  45 + page.should have_content "Your pushed to branch new_design"
46 46 page.should have_link "Create Merge Request"
47 47 end
48 48  
... ...
spec/requests/last_push_widget_spec.rb
... ... @@ -11,7 +11,7 @@ describe "Last Push widget" do
11 11 end
12 12  
13 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"
  14 + page.should have_content "Your pushed to branch new_design"
15 15 page.should have_link "Create Merge Request"
16 16 end
17 17  
... ...