Commit c0306f78 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge branch 't1254-snippets-refactoring' into 'master'

Snippets refactoring: rename public to internal. STEP 1

See merge request !1157
parents bbc52b00 fd8d1d9b
...@@ -14,7 +14,7 @@ class SnippetsController < ApplicationController ...@@ -14,7 +14,7 @@ class SnippetsController < ApplicationController
layout 'navless' layout 'navless'
def index def index
@snippets = Snippet.are_public.fresh.non_expired.page(params[:page]).per(20) @snippets = Snippet.are_internal.fresh.non_expired.page(params[:page]).per(20)
end end
def user_index def user_index
...@@ -26,15 +26,15 @@ class SnippetsController < ApplicationController ...@@ -26,15 +26,15 @@ class SnippetsController < ApplicationController
if @user == current_user if @user == current_user
@snippets = case params[:scope] @snippets = case params[:scope]
when 'are_public' then when 'are_internal' then
@snippets.are_public @snippets.are_internal
when 'are_private' then when 'are_private' then
@snippets.are_private @snippets.are_private
else else
@snippets @snippets
end end
else else
@snippets = @snippets.are_public @snippets = @snippets.are_internal
end end
@snippets = @snippets.page(params[:page]).per(20) @snippets = @snippets.page(params[:page]).per(20)
......
...@@ -32,7 +32,7 @@ class Snippet < ActiveRecord::Base ...@@ -32,7 +32,7 @@ class Snippet < ActiveRecord::Base
validates :content, presence: true validates :content, presence: true
# Scopes # Scopes
scope :are_public, -> { where(private: false) } scope :are_internal, -> { where(private: false) }
scope :are_private, -> { where(private: true) } scope :are_private, -> { where(private: true) }
scope :fresh, -> { order("created_at DESC") } scope :fresh, -> { order("created_at DESC") }
scope :expired, -> { where(["expires_at IS NOT NULL AND expires_at < ?", Time.current]) } scope :expired, -> { where(["expires_at IS NOT NULL AND expires_at < ?", Time.current]) }
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
= f.label :private_false, class: 'radio-label' do = f.label :private_false, class: 'radio-label' do
= f.radio_button :private, false = f.radio_button :private, false
%span %span
%strong Public %strong Internal
(GitLab users can see this snippet) (GitLab users can see this snippet)
.form-group .form-group
......
...@@ -23,11 +23,11 @@ ...@@ -23,11 +23,11 @@
Private Private
%span.pull-right %span.pull-right
= @user.snippets.are_private.count = @user.snippets.are_private.count
= nav_tab :scope, 'are_public' do = nav_tab :scope, 'are_internal' do
= link_to user_snippets_path(@user, scope: 'are_public') do = link_to user_snippets_path(@user, scope: 'are_internal') do
Public Internal
%span.pull-right %span.pull-right
= @user.snippets.are_public.count = @user.snippets.are_internal.count
.col-md-9.my-snippets .col-md-9.my-snippets
= render 'snippets' = render 'snippets'
......
...@@ -18,6 +18,6 @@ Feature: Snippets User ...@@ -18,6 +18,6 @@ Feature: Snippets User
Scenario: I can see only my public snippets Scenario: I can see only my public snippets
Given I visit my snippets page Given I visit my snippets page
And I click "Public" filter And I click "Internal" filter
Then I should see "Personal snippet one" in snippets Then I should see "Personal snippet one" in snippets
And I should not see "Personal snippet private" in snippets And I should not see "Personal snippet private" in snippets
...@@ -46,7 +46,7 @@ class Spinach::Features::Snippets < Spinach::FeatureSteps ...@@ -46,7 +46,7 @@ class Spinach::Features::Snippets < Spinach::FeatureSteps
end end
step 'I uncheck "Private" checkbox' do step 'I uncheck "Private" checkbox' do
choose "Public" choose "Internal"
click_button "Save" click_button "Save"
end end
......
...@@ -23,9 +23,9 @@ class Spinach::Features::SnippetsUser < Spinach::FeatureSteps ...@@ -23,9 +23,9 @@ class Spinach::Features::SnippetsUser < Spinach::FeatureSteps
page.should_not have_content "Personal snippet private" page.should_not have_content "Personal snippet private"
end end
step 'I click "Public" filter' do step 'I click "Internal" filter' do
within('.nav-stacked') do within('.nav-stacked') do
click_link "Public" click_link "Internal"
end end
end end
......
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