From e65731bb7ebf58366c185a10e50ec1db6eb495c4 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Thu, 3 Jan 2013 09:12:24 +0200 Subject: Add concerns to autoload --- spec/lib/issue_commonality_spec.rb | 70 ----------------------------------- spec/models/concerns/issuable_spec.rb | 70 +++++++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+), 70 deletions(-) delete mode 100644 spec/lib/issue_commonality_spec.rb create mode 100644 spec/models/concerns/issuable_spec.rb (limited to 'spec') diff --git a/spec/lib/issue_commonality_spec.rb b/spec/lib/issue_commonality_spec.rb deleted file mode 100644 index 11f278dea10..00000000000 --- a/spec/lib/issue_commonality_spec.rb +++ /dev/null @@ -1,70 +0,0 @@ -require 'spec_helper' - -describe Issue, "IssueCommonality" do - let(:issue) { create(:issue) } - - describe "Associations" do - it { should belong_to(:project) } - it { should belong_to(:author) } - it { should belong_to(:assignee) } - it { should have_many(:notes).dependent(:destroy) } - end - - describe "Validation" do - it { should validate_presence_of(:project) } - it { should validate_presence_of(:author) } - it { should validate_presence_of(:title) } - it { should ensure_length_of(:title).is_at_least(0).is_at_most(255) } - it { should ensure_inclusion_of(:closed).in_array([true, false]) } - end - - describe "Scope" do - it { described_class.should respond_to(:opened) } - it { described_class.should respond_to(:closed) } - it { described_class.should respond_to(:assigned) } - end - - it "has an :author_id_of_changes accessor" do - issue.should respond_to(:author_id_of_changes) - issue.should respond_to(:author_id_of_changes=) - end - - describe ".search" do - let!(:searchable_issue) { create(:issue, title: "Searchable issue") } - - it "matches by title" do - described_class.search('able').all.should == [searchable_issue] - end - end - - describe "#today?" do - it "returns true when created today" do - # Avoid timezone differences and just return exactly what we want - Date.stub(:today).and_return(issue.created_at.to_date) - issue.today?.should be_true - end - - it "returns false when not created today" do - Date.stub(:today).and_return(Date.yesterday) - issue.today?.should be_false - end - end - - describe "#new?" do - it "returns true when created today and record hasn't been updated" do - issue.stub(:today?).and_return(true) - issue.new?.should be_true - end - - it "returns false when not created today" do - issue.stub(:today?).and_return(false) - issue.new?.should be_false - end - - it "returns false when record has been updated" do - issue.stub(:today?).and_return(true) - issue.touch - issue.new?.should be_false - end - end -end diff --git a/spec/models/concerns/issuable_spec.rb b/spec/models/concerns/issuable_spec.rb new file mode 100644 index 00000000000..b5d4bd7b406 --- /dev/null +++ b/spec/models/concerns/issuable_spec.rb @@ -0,0 +1,70 @@ +require 'spec_helper' + +describe Issue, "Issuable" do + let(:issue) { create(:issue) } + + describe "Associations" do + it { should belong_to(:project) } + it { should belong_to(:author) } + it { should belong_to(:assignee) } + it { should have_many(:notes).dependent(:destroy) } + end + + describe "Validation" do + it { should validate_presence_of(:project) } + it { should validate_presence_of(:author) } + it { should validate_presence_of(:title) } + it { should ensure_length_of(:title).is_at_least(0).is_at_most(255) } + it { should ensure_inclusion_of(:closed).in_array([true, false]) } + end + + describe "Scope" do + it { described_class.should respond_to(:opened) } + it { described_class.should respond_to(:closed) } + it { described_class.should respond_to(:assigned) } + end + + it "has an :author_id_of_changes accessor" do + issue.should respond_to(:author_id_of_changes) + issue.should respond_to(:author_id_of_changes=) + end + + describe ".search" do + let!(:searchable_issue) { create(:issue, title: "Searchable issue") } + + it "matches by title" do + described_class.search('able').all.should == [searchable_issue] + end + end + + describe "#today?" do + it "returns true when created today" do + # Avoid timezone differences and just return exactly what we want + Date.stub(:today).and_return(issue.created_at.to_date) + issue.today?.should be_true + end + + it "returns false when not created today" do + Date.stub(:today).and_return(Date.yesterday) + issue.today?.should be_false + end + end + + describe "#new?" do + it "returns true when created today and record hasn't been updated" do + issue.stub(:today?).and_return(true) + issue.new?.should be_true + end + + it "returns false when not created today" do + issue.stub(:today?).and_return(false) + issue.new?.should be_false + end + + it "returns false when record has been updated" do + issue.stub(:today?).and_return(true) + issue.touch + issue.new?.should be_false + end + end +end -- cgit v1.2.1