Commit 8088127a6c3c38c5980aed6530c90b5a8f5c2200
1 parent
5cc81085
Exists in
master
and in
1 other branch
Fix more tests
Showing
6 changed files
with
14 additions
and
16 deletions
Show diff stats
spec/controllers/problems_controller_spec.rb
| @@ -275,7 +275,7 @@ describe ProblemsController do | @@ -275,7 +275,7 @@ describe ProblemsController do | ||
| 275 | end | 275 | end |
| 276 | 276 | ||
| 277 | it "should redirect to problem page" do | 277 | it "should redirect to problem page" do |
| 278 | - expect(response).to redirect_to( app_problem_path(problem.app, problem) ) | 278 | + expect(response).to redirect_to(app_problem_path(problem.app, problem)) |
| 279 | expect(flash[:error]).to be_blank | 279 | expect(flash[:error]).to be_blank |
| 280 | end | 280 | end |
| 281 | end | 281 | end |
spec/errbit_plugin/mock_issue_tracker.rb
| @@ -27,10 +27,9 @@ module ErrbitPlugin | @@ -27,10 +27,9 @@ module ErrbitPlugin | ||
| 27 | end | 27 | end |
| 28 | 28 | ||
| 29 | def errors | 29 | def errors |
| 30 | - errors = {} | ||
| 31 | - errors[:foo] = 'foo is required' unless options[:foo] | ||
| 32 | - errors[:bar] = 'bar is required' unless options[:bar] | ||
| 33 | - | 30 | + errors = [] |
| 31 | + errors << [:foo, 'foo is required'] unless options[:foo] | ||
| 32 | + errors << [:bar, 'bar is required'] unless options[:bar] | ||
| 34 | errors | 33 | errors |
| 35 | end | 34 | end |
| 36 | 35 | ||
| @@ -44,5 +43,3 @@ module ErrbitPlugin | @@ -44,5 +43,3 @@ module ErrbitPlugin | ||
| 44 | def comments_allowed?; false; end | 43 | def comments_allowed?; false; end |
| 45 | end | 44 | end |
| 46 | end | 45 | end |
| 47 | - | ||
| 48 | -ErrbitPlugin::Registry.add_issue_tracker(ErrbitPlugin::MockIssueTracker) |
spec/fabricators/issue_tracker_fabricator.rb
spec/models/issue_spec.rb
| @@ -7,6 +7,11 @@ describe Issue do | @@ -7,6 +7,11 @@ describe Issue do | ||
| 7 | let(:problem) { notice.problem } | 7 | let(:problem) { notice.problem } |
| 8 | let(:notice) { Fabricate(:notice) } | 8 | let(:notice) { Fabricate(:notice) } |
| 9 | let(:user) { Fabricate(:admin) } | 9 | let(:user) { Fabricate(:admin) } |
| 10 | + let(:issue_tracker) do | ||
| 11 | + Fabricate(:issue_tracker).tap do |t| | ||
| 12 | + t.instance_variable_set(:@tracker, ErrbitPlugin::MockIssueTracker.new(t.options)) | ||
| 13 | + end | ||
| 14 | + end | ||
| 10 | 15 | ||
| 11 | context "when app has no issue tracker" do | 16 | context "when app has no issue tracker" do |
| 12 | let(:title) { "Foo" } | 17 | let(:title) { "Foo" } |
| @@ -26,7 +31,6 @@ describe Issue do | @@ -26,7 +31,6 @@ describe Issue do | ||
| 26 | end | 31 | end |
| 27 | 32 | ||
| 28 | context "when has no title" do | 33 | context "when has no title" do |
| 29 | - let(:tracker) { Fabricate(:issue_tracker) } | ||
| 30 | let(:body) { "barrr" } | 34 | let(:body) { "barrr" } |
| 31 | 35 | ||
| 32 | pending "returns an error" do | 36 | pending "returns an error" do |
| @@ -34,7 +38,6 @@ describe Issue do | @@ -34,7 +38,6 @@ describe Issue do | ||
| 34 | end | 38 | end |
| 35 | 39 | ||
| 36 | context "when has no body" do | 40 | context "when has no body" do |
| 37 | - let(:tracker) { Fabricate(:issue_tracker) } | ||
| 38 | let(:title) { "Foo" } | 41 | let(:title) { "Foo" } |
| 39 | 42 | ||
| 40 | pending "returns an error" do | 43 | pending "returns an error" do |
| @@ -42,7 +45,6 @@ describe Issue do | @@ -42,7 +45,6 @@ describe Issue do | ||
| 42 | end | 45 | end |
| 43 | 46 | ||
| 44 | context "when app has a issue tracker" do | 47 | context "when app has a issue tracker" do |
| 45 | - let(:issue_tracker) { Fabricate(:issue_tracker) } | ||
| 46 | let(:title) { "Foo" } | 48 | let(:title) { "Foo" } |
| 47 | let(:body) { "barrr" } | 49 | let(:body) { "barrr" } |
| 48 | 50 |
spec/models/problem_spec.rb
| @@ -391,7 +391,9 @@ describe Problem do | @@ -391,7 +391,9 @@ describe Problem do | ||
| 391 | 391 | ||
| 392 | context "with issue_tracker valid associate to app" do | 392 | context "with issue_tracker valid associate to app" do |
| 393 | let(:issue_tracker) do | 393 | let(:issue_tracker) do |
| 394 | - Fabricate(:issue_tracker) | 394 | + Fabricate(:issue_tracker).tap do |t| |
| 395 | + t.instance_variable_set(:@tracker, ErrbitPlugin::MockIssueTracker.new(t.options)) | ||
| 396 | + end | ||
| 395 | end | 397 | end |
| 396 | 398 | ||
| 397 | it 'return the issue_tracker label' do | 399 | it 'return the issue_tracker label' do |
spec/views/problems/show.html.haml_spec.rb
| @@ -4,15 +4,13 @@ describe "problems/show.html.haml" do | @@ -4,15 +4,13 @@ describe "problems/show.html.haml" do | ||
| 4 | let(:problem) { Fabricate(:problem) } | 4 | let(:problem) { Fabricate(:problem) } |
| 5 | let(:comment) { Fabricate(:comment) } | 5 | let(:comment) { Fabricate(:comment) } |
| 6 | let(:pivotal_tracker) { | 6 | let(:pivotal_tracker) { |
| 7 | - Class.new(ErrbitPlugin::IssueTracker) do | 7 | + Class.new(ErrbitPlugin::MockIssueTracker) do |
| 8 | def self.label; 'pivotal'; end | 8 | def self.label; 'pivotal'; end |
| 9 | - def initialize(options); end | ||
| 10 | def configured?; true; end | 9 | def configured?; true; end |
| 11 | end | 10 | end |
| 12 | } | 11 | } |
| 13 | let(:github_tracker) { | 12 | let(:github_tracker) { |
| 14 | - Class.new(ErrbitPlugin::IssueTracker) do | ||
| 15 | - def initialize(options); end | 13 | + Class.new(ErrbitPlugin::MockIssueTracker) do |
| 16 | def label; 'github'; end | 14 | def label; 'github'; end |
| 17 | def configured?; true; end | 15 | def configured?; true; end |
| 18 | end | 16 | end |