Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrandx <dmitriy.zaporozhets@gmail.com>2012-06-21 19:41:22 +0400
committerrandx <dmitriy.zaporozhets@gmail.com>2012-06-21 19:41:22 +0400
commit77cf662034a7187fe7e223e6d16b664b7b525d25 (patch)
tree4b00a9a94bfad3cd1a4b21456215997e7569ee8c
parented247b3893b8af5bfc266ebc03cc029ca31c800f (diff)
Pushed widget improved
-rw-r--r--app/helpers/application_helper.rb5
-rw-r--r--app/roles/account.rb4
-rw-r--r--app/roles/push_event.rb8
-rw-r--r--app/views/events/_event_last_push.html.haml9
-rw-r--r--app/views/projects/show.html.haml8
-rw-r--r--features/step_definitions/dashboard_steps.rb2
-rw-r--r--spec/requests/last_push_widget_spec.rb2
7 files changed, 22 insertions, 16 deletions
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index be0e0c9eedf..8e151ef75df 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -88,4 +88,9 @@ module ApplicationHelper
def app_theme
Gitlab::Theme.css_class_by_id(current_user.try(:theme_id))
end
+
+ def show_last_push_widget?(event)
+ event && event.last_push_to_non_root? &&
+ event.project && event.project.merge_requests_enabled
+ end
end
diff --git a/app/roles/account.rb b/app/roles/account.rb
index 8ff5c613e51..afa1f8a347d 100644
--- a/app/roles/account.rb
+++ b/app/roles/account.rb
@@ -48,8 +48,8 @@ module Account
end
def recent_push project_id = nil
- # Get push events not earlier than 6 hours ago
- events = recent_events.code_push.where("created_at > ?", Time.now - 6.hours)
+ # Get push events not earlier than 2 hours ago
+ events = recent_events.code_push.where("created_at > ?", Time.now - 2.hours)
events = events.where(:project_id => project_id) if project_id
# Take only latest one
diff --git a/app/roles/push_event.rb b/app/roles/push_event.rb
index acec916f893..ff8e28a2db2 100644
--- a/app/roles/push_event.rb
+++ b/app/roles/push_event.rb
@@ -9,6 +9,10 @@ module PushEvent
data[:ref]["refs/tags"]
end
+ def branch?
+ data[:ref]["refs/heads"]
+ end
+
def new_branch?
commit_from =~ /^00000/
end
@@ -87,4 +91,8 @@ module PushEvent
def push_with_commits?
md_ref? && commits.any? && parent_commit && last_commit
end
+
+ def last_push_to_non_root?
+ branch? && project.default_branch != branch_name
+ end
end
diff --git a/app/views/events/_event_last_push.html.haml b/app/views/events/_event_last_push.html.haml
index 8c6918d2548..eb507b55c9b 100644
--- a/app/views/events/_event_last_push.html.haml
+++ b/app/views/events/_event_last_push.html.haml
@@ -1,8 +1,8 @@
-- if event && event.branch_name
+- if show_last_push_widget?(event)
.event_lp
%div
= image_tag gravatar_icon(event.author_email), :class => "avatar"
- %span Your last push was to
+ %span Your pushed to
= event.ref_type
= link_to project_commits_path(event.project, :ref => event.ref_name) do
%strong= event.ref_name
@@ -12,6 +12,5 @@
= time_ago_in_words(event.created_at)
ago.
- - 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
+ = 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/app/views/projects/show.html.haml b/app/views/projects/show.html.haml
index 48b541544ff..44f9053d3f6 100644
--- a/app/views/projects/show.html.haml
+++ b/app/views/projects/show.html.haml
@@ -21,12 +21,6 @@
Issue
= render "events/event_last_push", :event => @last_push
-- unless @events.blank?
- %br
- %h5.cgray
- %span.ico.activities
- Recent Activity
- %hr
- .content_list= render @events
+.content_list= render @events
diff --git a/features/step_definitions/dashboard_steps.rb b/features/step_definitions/dashboard_steps.rb
index ef48a850324..7133d799995 100644
--- a/features/step_definitions/dashboard_steps.rb
+++ b/features/step_definitions/dashboard_steps.rb
@@ -42,7 +42,7 @@ Given /^project "(.*?)" has push event$/ do |arg1|
end
Then /^I should see last push widget$/ do
- page.should have_content "Your last push was to branch new_design"
+ page.should have_content "Your pushed to branch new_design"
page.should have_link "Create Merge Request"
end
diff --git a/spec/requests/last_push_widget_spec.rb b/spec/requests/last_push_widget_spec.rb
index 55ef3f0ac5e..0baa20c6e94 100644
--- a/spec/requests/last_push_widget_spec.rb
+++ b/spec/requests/last_push_widget_spec.rb
@@ -11,7 +11,7 @@ describe "Last Push widget" do
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_content "Your pushed to branch new_design"
page.should have_link "Create Merge Request"
end