Commit 8088127a6c3c38c5980aed6530c90b5a8f5c2200

Authored by Arthur Neves
1 parent 5cc81085
Exists in master and in 1 other branch production

Fix more tests

spec/controllers/problems_controller_spec.rb
... ... @@ -275,7 +275,7 @@ describe ProblemsController do
275 275 end
276 276  
277 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 279 expect(flash[:error]).to be_blank
280 280 end
281 281 end
... ...
spec/errbit_plugin/mock_issue_tracker.rb
... ... @@ -27,10 +27,9 @@ module ErrbitPlugin
27 27 end
28 28  
29 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 33 errors
35 34 end
36 35  
... ... @@ -44,5 +43,3 @@ module ErrbitPlugin
44 43 def comments_allowed?; false; end
45 44 end
46 45 end
47   -
48   -ErrbitPlugin::Registry.add_issue_tracker(ErrbitPlugin::MockIssueTracker)
... ...
spec/fabricators/issue_tracker_fabricator.rb
... ... @@ -4,6 +4,5 @@ Fabricator :issue_tracker do
4 4 :foo => 'one',
5 5 :bar => 'two'
6 6 }}
7   -
8 7 app
9 8 end
... ...
spec/models/issue_spec.rb
... ... @@ -7,6 +7,11 @@ describe Issue do
7 7 let(:problem) { notice.problem }
8 8 let(:notice) { Fabricate(:notice) }
9 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 16 context "when app has no issue tracker" do
12 17 let(:title) { "Foo" }
... ... @@ -26,7 +31,6 @@ describe Issue do
26 31 end
27 32  
28 33 context "when has no title" do
29   - let(:tracker) { Fabricate(:issue_tracker) }
30 34 let(:body) { "barrr" }
31 35  
32 36 pending "returns an error" do
... ... @@ -34,7 +38,6 @@ describe Issue do
34 38 end
35 39  
36 40 context "when has no body" do
37   - let(:tracker) { Fabricate(:issue_tracker) }
38 41 let(:title) { "Foo" }
39 42  
40 43 pending "returns an error" do
... ... @@ -42,7 +45,6 @@ describe Issue do
42 45 end
43 46  
44 47 context "when app has a issue tracker" do
45   - let(:issue_tracker) { Fabricate(:issue_tracker) }
46 48 let(:title) { "Foo" }
47 49 let(:body) { "barrr" }
48 50  
... ...
spec/models/problem_spec.rb
... ... @@ -391,7 +391,9 @@ describe Problem do
391 391  
392 392 context "with issue_tracker valid associate to app" do
393 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 397 end
396 398  
397 399 it 'return the issue_tracker label' do
... ...
spec/views/problems/show.html.haml_spec.rb
... ... @@ -4,15 +4,13 @@ describe &quot;problems/show.html.haml&quot; do
4 4 let(:problem) { Fabricate(:problem) }
5 5 let(:comment) { Fabricate(:comment) }
6 6 let(:pivotal_tracker) {
7   - Class.new(ErrbitPlugin::IssueTracker) do
  7 + Class.new(ErrbitPlugin::MockIssueTracker) do
8 8 def self.label; 'pivotal'; end
9   - def initialize(options); end
10 9 def configured?; true; end
11 10 end
12 11 }
13 12 let(:github_tracker) {
14   - Class.new(ErrbitPlugin::IssueTracker) do
15   - def initialize(options); end
  13 + Class.new(ErrbitPlugin::MockIssueTracker) do
16 14 def label; 'github'; end
17 15 def configured?; true; end
18 16 end
... ...