Commit 6bd9b90fb6c59282d741964707e3e8461232038a

Authored by Saito
2 parents 4281704f 91d5a906

Merge branch 'master' of dev.gitlabhq.com:gitlabhq

1 -rvm use 1.9.2-p290 1 +#!/usr/bin/env bash
  2 +
  3 +# This is an RVM Project .rvmrc file, used to automatically load the ruby
  4 +# development environment upon cd'ing into the directory
  5 +
  6 +# First we specify our desired <ruby>[@<gemset>], the @gemset name is optional.
  7 +environment_id="ruby-1.9.2-p290@gitlabhq"
  8 +
  9 +#
  10 +# Uncomment following line if you want options to be set only for given project.
  11 +#
  12 +# PROJECT_JRUBY_OPTS=( --1.9 )
  13 +
  14 +#
  15 +# First we attempt to load the desired environment directly from the environment
  16 +# file. This is very fast and efficient compared to running through the entire
  17 +# CLI and selector. If you want feedback on which environment was used then
  18 +# insert the word 'use' after --create as this triggers verbose mode.
  19 +#
  20 +if [[ -d "${rvm_path:-$HOME/.rvm}/environments" \
  21 + && -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]]
  22 +then
  23 + \. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"
  24 +
  25 + if [[ -s "${rvm_path:-$HOME/.rvm}/hooks/after_use" ]]
  26 + then
  27 + . "${rvm_path:-$HOME/.rvm}/hooks/after_use"
  28 + fi
  29 +else
  30 + # If the environment file has not yet been created, use the RVM CLI to select.
  31 + if ! rvm --create "$environment_id"
  32 + then
  33 + echo "Failed to create RVM environment '${environment_id}'."
  34 + exit 1
  35 + fi
  36 +fi
  37 +
  38 +#
  39 +# If you use an RVM gemset file to install a list of gems (*.gems), you can have
  40 +# it be automatically loaded. Uncomment the following and adjust the filename if
  41 +# necessary.
  42 +#
  43 +# filename=".gems"
  44 +# if [[ -s "$filename" ]]
  45 +# then
  46 +# rvm gemset import "$filename" | grep -v already | grep -v listed | grep -v complete | sed '/^$/d'
  47 +# fi
  48 +
  49 +# If you use bundler, this might be useful to you:
  50 +# if command -v bundle && [[ -s Gemfile ]]
  51 +# then
  52 +# bundle
  53 +# fi
  54 +
  55 +
app/models/note.rb
@@ -27,6 +27,7 @@ class Note &lt; ActiveRecord::Base @@ -27,6 +27,7 @@ class Note &lt; ActiveRecord::Base
27 27
28 scope :common, where(:noteable_id => nil) 28 scope :common, where(:noteable_id => nil)
29 29
  30 + scope :today, where("created_at >= :date", :date => Date.today)
30 scope :last_week, where("created_at >= :date", :date => (Date.today - 7.days)) 31 scope :last_week, where("created_at >= :date", :date => (Date.today - 7.days))
31 scope :since, lambda { |day| where("created_at >= :date", :date => (day)) } 32 scope :since, lambda { |day| where("created_at >= :date", :date => (day)) }
32 scope :fresh, order("created_at DESC") 33 scope :fresh, order("created_at DESC")
app/models/user.rb
@@ -30,7 +30,7 @@ class User &lt; ActiveRecord::Base @@ -30,7 +30,7 @@ class User &lt; ActiveRecord::Base
30 scope :not_in_project, lambda { |project| where("id not in (:ids)", :ids => project.users.map(&:id) ) } 30 scope :not_in_project, lambda { |project| where("id not in (:ids)", :ids => project.users.map(&:id) ) }
31 31
32 def identifier 32 def identifier
33 - email.gsub "@", "_" 33 + email.gsub /[@.]/, "_"
34 end 34 end
35 35
36 def is_admin? 36 def is_admin?
app/views/layouts/project.html.haml
@@ -38,7 +38,7 @@ @@ -38,7 +38,7 @@
38 = link_to wall_project_path(@project), :class => current_page?(:controller => "projects", :action => "wall", :id => @project) ? "current" : nil do 38 = link_to wall_project_path(@project), :class => current_page?(:controller => "projects", :action => "wall", :id => @project) ? "current" : nil do
39 Wall 39 Wall
40 - if @project.common_notes.count > 0 40 - if @project.common_notes.count > 0
41 - %span{ :class => "number" }= @project.common_notes.count 41 + %span{ :class => "number" }= @project.common_notes.today.count
42 = link_to project_snippets_path(@project), :class => (controller.controller_name == "snippets") ? "current" : nil do 42 = link_to project_snippets_path(@project), :class => (controller.controller_name == "snippets") ? "current" : nil do
43 Snippets 43 Snippets
44 - if @project.snippets.count > 0 44 - if @project.snippets.count > 0
spec/models/note_spec.rb
@@ -12,7 +12,12 @@ describe Note do @@ -12,7 +12,12 @@ describe Note do
12 12
13 it { Factory.create(:note, 13 it { Factory.create(:note,
14 :project => Factory.create(:project)).should be_valid } 14 :project => Factory.create(:project)).should be_valid }
15 - 15 + describe "Scopes" do
  16 + it "should have a today named scope that returns ..." do
  17 + Note.today.where_values.should == ["created_at >= '#{Date.today}'"]
  18 + end
  19 + end
  20 +
16 describe :authorization do 21 describe :authorization do
17 before do 22 before do
18 @p1 = Factory :project 23 @p1 = Factory :project
spec/models/user_spec.rb
@@ -16,7 +16,7 @@ describe User do @@ -16,7 +16,7 @@ describe User do
16 16
17 it "should return valid identifier" do 17 it "should return valid identifier" do
18 user = User.new(:email => "test@mail.com") 18 user = User.new(:email => "test@mail.com")
19 - user.identifier.should == "test_mail.com" 19 + user.identifier.should == "test_mail_com"
20 end 20 end
21 21
22 it "should have authentication token" do 22 it "should have authentication token" do