Commit 0ba03d7e authored by Yorick Peterse's avatar Yorick Peterse

Removed data-user-is view code

With events no longer being cached this is no longer needed.
parent 5371da34
...@@ -347,6 +347,10 @@ class Event < ActiveRecord::Base ...@@ -347,6 +347,10 @@ class Event < ActiveRecord::Base
update_all(last_activity_at: created_at) update_all(last_activity_at: created_at)
end end
def authored_by?(user)
user ? author_id == user.id : false
end
private private
def recent_update? def recent_update?
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
- few_commits.each do |commit| - few_commits.each do |commit|
= render "events/commit", commit: commit, project: project, event: event = render "events/commit", commit: commit, project: project, event: event
- create_mr = event.new_ref? && create_mr_button?(project.default_branch, event.ref_name, project) - create_mr = event.new_ref? && create_mr_button?(project.default_branch, event.ref_name, project) && event.authored_by?(current_user)
- if event.commits_count > 1 - if event.commits_count > 1
%li.commits-stat %li.commits-stat
- if event.commits_count > 2 - if event.commits_count > 2
...@@ -35,12 +35,12 @@ ...@@ -35,12 +35,12 @@
Compare #{from_label}...#{truncate_sha(event.commit_to)} Compare #{from_label}...#{truncate_sha(event.commit_to)}
- if create_mr - if create_mr
%span{"data-user-is" => event.author_id, "data-display" => "inline"} %span
or or
= link_to create_mr_path(project.default_branch, event.ref_name, project) do = link_to create_mr_path(project.default_branch, event.ref_name, project) do
create a merge request create a merge request
- elsif create_mr - elsif create_mr
%li.commits-stat{"data-user-is" => event.author_id} %li.commits-stat
= link_to create_mr_path(project.default_branch, event.ref_name, project) do = link_to create_mr_path(project.default_branch, event.ref_name, project) do
Create Merge Request Create Merge Request
- elsif event.rm_ref? - elsif event.rm_ref?
......
...@@ -56,5 +56,3 @@ ...@@ -56,5 +56,3 @@
= render 'layouts/google_analytics' if extra_config.has_key?('google_analytics_id') = render 'layouts/google_analytics' if extra_config.has_key?('google_analytics_id')
= render 'layouts/piwik' if extra_config.has_key?('piwik_url') && extra_config.has_key?('piwik_site_id') = render 'layouts/piwik' if extra_config.has_key?('piwik_url') && extra_config.has_key?('piwik_site_id')
= render 'layouts/bootlint' if Rails.env.development? = render 'layouts/bootlint' if Rails.env.development?
= render 'layouts/user_styles'
:css
[data-user-is] {
display: none !important;
}
[data-user-is="#{current_user.try(:id)}"] {
display: block !important;
}
[data-user-is="#{current_user.try(:id)}"][data-display="inline"] {
display: inline !important;
}
[data-user-is-not] {
display: block !important;
}
[data-user-is-not][data-display="inline"] {
display: inline !important;
}
[data-user-is-not="#{current_user.try(:id)}"] {
display: none !important;
}
...@@ -260,6 +260,24 @@ describe Event, models: true do ...@@ -260,6 +260,24 @@ describe Event, models: true do
end end
end end
describe '#authored_by?' do
let(:event) { build(:event) }
it 'returns true when the event author and user are the same' do
expect(event.authored_by?(event.author)).to eq(true)
end
it 'returns false when passing nil as an argument' do
expect(event.authored_by?(nil)).to eq(false)
end
it 'returns false when the given user is not the author of the event' do
user = double(:user, id: -1)
expect(event.authored_by?(user)).to eq(false)
end
end
def create_event(project, user, attrs = {}) def create_event(project, user, attrs = {})
data = { data = {
before: Gitlab::Git::BLANK_SHA, before: Gitlab::Git::BLANK_SHA,
......
require 'spec_helper' require 'spec_helper'
describe 'layouts/_head' do describe 'layouts/_head' do
before do
stub_template 'layouts/_user_styles.html.haml' => ''
end
it 'escapes HTML-safe strings in page_title' do it 'escapes HTML-safe strings in page_title' do
stub_helper_with_safe_string(:page_title) stub_helper_with_safe_string(:page_title)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment