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

Snippets refactoring: rename public to internal. STEP 1

See merge request !1157
This commit is contained in:
Dmitriy Zaporozhets 2014-10-07 10:05:59 +00:00
commit c0306f78d2
7 changed files with 14 additions and 14 deletions

View file

@ -14,7 +14,7 @@ class SnippetsController < ApplicationController
layout 'navless'
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
def user_index
@ -26,15 +26,15 @@ class SnippetsController < ApplicationController
if @user == current_user
@snippets = case params[:scope]
when 'are_public' then
@snippets.are_public
when 'are_internal' then
@snippets.are_internal
when 'are_private' then
@snippets.are_private
else
@snippets
end
else
@snippets = @snippets.are_public
@snippets = @snippets.are_internal
end
@snippets = @snippets.page(params[:page]).per(20)

View file

@ -32,7 +32,7 @@ class Snippet < ActiveRecord::Base
validates :content, presence: true
# Scopes
scope :are_public, -> { where(private: false) }
scope :are_internal, -> { where(private: false) }
scope :are_private, -> { where(private: true) }
scope :fresh, -> { order("created_at DESC") }
scope :expired, -> { where(["expires_at IS NOT NULL AND expires_at < ?", Time.current]) }

View file

@ -23,7 +23,7 @@
= f.label :private_false, class: 'radio-label' do
= f.radio_button :private, false
%span
%strong Public
%strong Internal
(GitLab users can see this snippet)
.form-group

View file

@ -23,11 +23,11 @@
Private
%span.pull-right
= @user.snippets.are_private.count
= nav_tab :scope, 'are_public' do
= link_to user_snippets_path(@user, scope: 'are_public') do
Public
= nav_tab :scope, 'are_internal' do
= link_to user_snippets_path(@user, scope: 'are_internal') do
Internal
%span.pull-right
= @user.snippets.are_public.count
= @user.snippets.are_internal.count
.col-md-9.my-snippets
= render 'snippets'

View file

@ -18,6 +18,6 @@ Feature: Snippets User
Scenario: I can see only my public snippets
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
And I should not see "Personal snippet private" in snippets

View file

@ -46,7 +46,7 @@ class Spinach::Features::Snippets < Spinach::FeatureSteps
end
step 'I uncheck "Private" checkbox' do
choose "Public"
choose "Internal"
click_button "Save"
end

View file

@ -23,9 +23,9 @@ class Spinach::Features::SnippetsUser < Spinach::FeatureSteps
page.should_not have_content "Personal snippet private"
end
step 'I click "Public" filter' do
step 'I click "Internal" filter' do
within('.nav-stacked') do
click_link "Public"
click_link "Internal"
end
end