Commit e65731bb7ebf58366c185a10e50ec1db6eb495c4
1 parent
a1999955
Exists in
master
and in
4 other branches
Add concerns to autoload
Showing
3 changed files
with
71 additions
and
71 deletions
Show diff stats
config/application.rb
| ... | ... | @@ -16,7 +16,7 @@ module Gitlab |
| 16 | 16 | # -- all .rb files in that directory are automatically loaded. |
| 17 | 17 | |
| 18 | 18 | # Custom directories with classes and modules you want to be autoloadable. |
| 19 | - config.autoload_paths += %W(#{config.root}/lib) | |
| 19 | + config.autoload_paths += %W(#{config.root}/lib #{config.root}/app/models/concerns) | |
| 20 | 20 | |
| 21 | 21 | # Only load the plugins named here, in the order given (default is alphabetical). |
| 22 | 22 | # :all can be used as a placeholder for all plugins not explicitly named. | ... | ... |
spec/lib/issue_commonality_spec.rb
| ... | ... | @@ -1,70 +0,0 @@ |
| 1 | -require 'spec_helper' | |
| 2 | - | |
| 3 | -describe Issue, "IssueCommonality" do | |
| 4 | - let(:issue) { create(:issue) } | |
| 5 | - | |
| 6 | - describe "Associations" do | |
| 7 | - it { should belong_to(:project) } | |
| 8 | - it { should belong_to(:author) } | |
| 9 | - it { should belong_to(:assignee) } | |
| 10 | - it { should have_many(:notes).dependent(:destroy) } | |
| 11 | - end | |
| 12 | - | |
| 13 | - describe "Validation" do | |
| 14 | - it { should validate_presence_of(:project) } | |
| 15 | - it { should validate_presence_of(:author) } | |
| 16 | - it { should validate_presence_of(:title) } | |
| 17 | - it { should ensure_length_of(:title).is_at_least(0).is_at_most(255) } | |
| 18 | - it { should ensure_inclusion_of(:closed).in_array([true, false]) } | |
| 19 | - end | |
| 20 | - | |
| 21 | - describe "Scope" do | |
| 22 | - it { described_class.should respond_to(:opened) } | |
| 23 | - it { described_class.should respond_to(:closed) } | |
| 24 | - it { described_class.should respond_to(:assigned) } | |
| 25 | - end | |
| 26 | - | |
| 27 | - it "has an :author_id_of_changes accessor" do | |
| 28 | - issue.should respond_to(:author_id_of_changes) | |
| 29 | - issue.should respond_to(:author_id_of_changes=) | |
| 30 | - end | |
| 31 | - | |
| 32 | - describe ".search" do | |
| 33 | - let!(:searchable_issue) { create(:issue, title: "Searchable issue") } | |
| 34 | - | |
| 35 | - it "matches by title" do | |
| 36 | - described_class.search('able').all.should == [searchable_issue] | |
| 37 | - end | |
| 38 | - end | |
| 39 | - | |
| 40 | - describe "#today?" do | |
| 41 | - it "returns true when created today" do | |
| 42 | - # Avoid timezone differences and just return exactly what we want | |
| 43 | - Date.stub(:today).and_return(issue.created_at.to_date) | |
| 44 | - issue.today?.should be_true | |
| 45 | - end | |
| 46 | - | |
| 47 | - it "returns false when not created today" do | |
| 48 | - Date.stub(:today).and_return(Date.yesterday) | |
| 49 | - issue.today?.should be_false | |
| 50 | - end | |
| 51 | - end | |
| 52 | - | |
| 53 | - describe "#new?" do | |
| 54 | - it "returns true when created today and record hasn't been updated" do | |
| 55 | - issue.stub(:today?).and_return(true) | |
| 56 | - issue.new?.should be_true | |
| 57 | - end | |
| 58 | - | |
| 59 | - it "returns false when not created today" do | |
| 60 | - issue.stub(:today?).and_return(false) | |
| 61 | - issue.new?.should be_false | |
| 62 | - end | |
| 63 | - | |
| 64 | - it "returns false when record has been updated" do | |
| 65 | - issue.stub(:today?).and_return(true) | |
| 66 | - issue.touch | |
| 67 | - issue.new?.should be_false | |
| 68 | - end | |
| 69 | - end | |
| 70 | -end |
| ... | ... | @@ -0,0 +1,70 @@ |
| 1 | +require 'spec_helper' | |
| 2 | + | |
| 3 | +describe Issue, "Issuable" do | |
| 4 | + let(:issue) { create(:issue) } | |
| 5 | + | |
| 6 | + describe "Associations" do | |
| 7 | + it { should belong_to(:project) } | |
| 8 | + it { should belong_to(:author) } | |
| 9 | + it { should belong_to(:assignee) } | |
| 10 | + it { should have_many(:notes).dependent(:destroy) } | |
| 11 | + end | |
| 12 | + | |
| 13 | + describe "Validation" do | |
| 14 | + it { should validate_presence_of(:project) } | |
| 15 | + it { should validate_presence_of(:author) } | |
| 16 | + it { should validate_presence_of(:title) } | |
| 17 | + it { should ensure_length_of(:title).is_at_least(0).is_at_most(255) } | |
| 18 | + it { should ensure_inclusion_of(:closed).in_array([true, false]) } | |
| 19 | + end | |
| 20 | + | |
| 21 | + describe "Scope" do | |
| 22 | + it { described_class.should respond_to(:opened) } | |
| 23 | + it { described_class.should respond_to(:closed) } | |
| 24 | + it { described_class.should respond_to(:assigned) } | |
| 25 | + end | |
| 26 | + | |
| 27 | + it "has an :author_id_of_changes accessor" do | |
| 28 | + issue.should respond_to(:author_id_of_changes) | |
| 29 | + issue.should respond_to(:author_id_of_changes=) | |
| 30 | + end | |
| 31 | + | |
| 32 | + describe ".search" do | |
| 33 | + let!(:searchable_issue) { create(:issue, title: "Searchable issue") } | |
| 34 | + | |
| 35 | + it "matches by title" do | |
| 36 | + described_class.search('able').all.should == [searchable_issue] | |
| 37 | + end | |
| 38 | + end | |
| 39 | + | |
| 40 | + describe "#today?" do | |
| 41 | + it "returns true when created today" do | |
| 42 | + # Avoid timezone differences and just return exactly what we want | |
| 43 | + Date.stub(:today).and_return(issue.created_at.to_date) | |
| 44 | + issue.today?.should be_true | |
| 45 | + end | |
| 46 | + | |
| 47 | + it "returns false when not created today" do | |
| 48 | + Date.stub(:today).and_return(Date.yesterday) | |
| 49 | + issue.today?.should be_false | |
| 50 | + end | |
| 51 | + end | |
| 52 | + | |
| 53 | + describe "#new?" do | |
| 54 | + it "returns true when created today and record hasn't been updated" do | |
| 55 | + issue.stub(:today?).and_return(true) | |
| 56 | + issue.new?.should be_true | |
| 57 | + end | |
| 58 | + | |
| 59 | + it "returns false when not created today" do | |
| 60 | + issue.stub(:today?).and_return(false) | |
| 61 | + issue.new?.should be_false | |
| 62 | + end | |
| 63 | + | |
| 64 | + it "returns false when record has been updated" do | |
| 65 | + issue.stub(:today?).and_return(true) | |
| 66 | + issue.touch | |
| 67 | + issue.new?.should be_false | |
| 68 | + end | |
| 69 | + end | |
| 70 | +end | ... | ... |