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:
authorDouglas Barbosa Alexandre <dbalexandre@gmail.com>2016-01-26 21:59:23 +0300
committerDouglas Barbosa Alexandre <dbalexandre@gmail.com>2016-02-02 16:25:44 +0300
commit64c9768bd6916edfc1e43907ca5e976524b8d51b (patch)
tree850ea9b5a7ac5178555f817d27402647df5e4b0b
parentd20e75a8d80c2828336cd22897ea6868d666f8a5 (diff)
Use truncate helper on spam logs list
-rw-r--r--app/models/spam_log.rb8
-rw-r--r--app/views/admin/spam_logs/_spam_log.html.haml2
-rw-r--r--features/steps/admin/spam_logs.rb22
-rw-r--r--spec/factories/spam_logs.rb4
4 files changed, 21 insertions, 15 deletions
diff --git a/app/models/spam_log.rb b/app/models/spam_log.rb
index 132c5713e0a..b7b32b478a7 100644
--- a/app/models/spam_log.rb
+++ b/app/models/spam_log.rb
@@ -2,12 +2,4 @@ class SpamLog < ActiveRecord::Base
belongs_to :user
validates :user, presence: true
-
- def truncated_description
- if description.present? && description.length > 100
- return description[0..100] + "..."
- end
-
- description
- end
end
diff --git a/app/views/admin/spam_logs/_spam_log.html.haml b/app/views/admin/spam_logs/_spam_log.html.haml
index 1c793bbf738..9f9f1d75895 100644
--- a/app/views/admin/spam_logs/_spam_log.html.haml
+++ b/app/views/admin/spam_logs/_spam_log.html.haml
@@ -16,7 +16,7 @@
%td
= spam_log.title
%td
- = spam_log.truncated_description
+ = truncate(spam_log.description, length: 100)
%td
- if user
= link_to 'Remove user', admin_spam_log_path(spam_log, remove_user: true),
diff --git a/features/steps/admin/spam_logs.rb b/features/steps/admin/spam_logs.rb
index 79d18b036b0..ad825fd414c 100644
--- a/features/steps/admin/spam_logs.rb
+++ b/features/steps/admin/spam_logs.rb
@@ -4,15 +4,25 @@ class Spinach::Features::AdminSpamLogs < Spinach::FeatureSteps
include SharedAdmin
step 'I should see list of spam logs' do
- page.should have_content("Spam Logs")
- spam_log = SpamLog.first
- page.should have_content spam_log.title
- page.should have_content spam_log.description
- page.should have_link("Remove user")
- page.should have_link("Block user")
+ expect(page).to have_content('Spam Logs')
+ expect(page).to have_content spam_log.source_ip
+ expect(page).to have_content spam_log.noteable_type
+ expect(page).to have_content 'N'
+ expect(page).to have_content spam_log.title
+ expect(page).to have_content truncate(spam_log.description)
+ expect(page).to have_link('Remove user')
+ expect(page).to have_link('Block user')
end
step 'spam logs exist' do
create(:spam_log)
end
+
+ def spam_log
+ @spam_log ||= SpamLog.first
+ end
+
+ def truncate(description)
+ "#{spam_log.description[0...97]}..."
+ end
end
diff --git a/spec/factories/spam_logs.rb b/spec/factories/spam_logs.rb
index 9e8686d73c2..d90e5d6bf26 100644
--- a/spec/factories/spam_logs.rb
+++ b/spec/factories/spam_logs.rb
@@ -3,5 +3,9 @@
FactoryGirl.define do
factory :spam_log do
user
+ source_ip { FFaker::Internet.ip_v4_address }
+ noteable_type 'Issue'
+ title { FFaker::Lorem.sentence }
+ description { FFaker::Lorem.paragraph(5) }
end
end