Skip to content

Commit e1d35c0

Browse files
committed
Merge pull request #187 from ArturG/rspec
Road to 100% coverage
2 parents f820f9d + cf442d3 commit e1d35c0

21 files changed

Lines changed: 239 additions & 26 deletions

app/controllers/api/rels_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ def index
66
def show
77
@rel = Rel.first(:slug => params[:id])
88
end
9-
end
9+
end
Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,7 @@
11
class ApplicationController < ActionController::Base
22
protect_from_forgery
3-
helper_method :title
43

5-
def title t=nil
6-
@title = t unless t.blank?
7-
@title
8-
end
9-
104
rescue_from CanCan::AccessDenied do |exception|
115
redirect_to login_url, :alert => exception.message
126
end
13-
147
end

app/helpers/application_helper.rb

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
11
module ApplicationHelper
2-
def program_path program
3-
"/users/#{program.author_username}/programs/#{program.slug}"
4-
end
5-
62
def markdown(text)
73
Redcarpet::Markdown.new(Redcarpet::Render::HTML.new(hard_wrap: true), autolink: true).render(text).html_safe
84
end

app/presenters/question_presenter.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@ def collection_path
2222
end
2323

2424
def edit_resource_path
25-
edit_question_path
25+
edit_question_path(@question)
2626
end
2727

2828
def apply_scope(chain)
2929
chain.no_supports
3030
end
3131

3232
def answers_path
33-
question_answer_path(@question)
33+
question_answers_path(@question)
3434
end
3535
end

app/presenters/support_presenter.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@ def collection_path
1818
end
1919

2020
def edit_resource_path
21-
edit_support_question_path
21+
edit_support_question_path(@support_question)
2222
end
2323

2424
def resource_path(question)
2525
if question
2626
support_question_path(question)
2727
else
28-
support_question_path(@question)
28+
support_question_path(@support_question)
2929
end
3030
end
3131

features/step_definitions/user_steps.rb

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
def login_user
2-
@user = User.create!(username: "test_user",
2+
@user = User.create!(username: "test_user",
33
email: "test_user@example.com",
44
password: "foobar",
55
password_confirmation: "foobar")
@@ -20,6 +20,13 @@ def create_other_user
2020
login_user unless @user
2121
end
2222

23+
Given /^a steve exists$/ do
24+
@steve = User.create!(username: "steve",
25+
email: "steve_user@example.com",
26+
password: "foobar",
27+
password_confirmation: "foobar")
28+
end
29+
2330
When /^I go to look at my profile page$/ do
2431
visit user_path(@user)
2532
end
@@ -73,3 +80,7 @@ def create_other_user
7380
page.should have_content("Test user likes to edit his profile")
7481
end
7582

83+
Then(/^I should see 'Steve'$/) do
84+
@user.following?(@steve).should == true
85+
page.should have_link @steve.username
86+
end

features/users.feature

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ Feature: Manage account
33
As a user of this site, I can view and update my profile, see my followers
44

55
Background:
6-
Given a logged in user
6+
Given a steve exists
7+
And a logged in user
78

89
Scenario: View my profile
910
When I go to look at my profile page
@@ -23,4 +24,7 @@ Feature: Manage account
2324
When I am following someone
2425
And I click on the number of people I am following on my profile
2526
Then I should see someone I'm following
26-
27+
28+
Scenario: I should always follow steve and vice versa
29+
When I click on the number of people I am following on my profile
30+
Then I should see 'Steve'

spec/controllers/mailer_controller_spec.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,13 @@
8888
ActionMailer::Base.deliveries.last.body.to_s.should match @message.body
8989
end
9090
end
91+
92+
describe 'empty message' do
93+
it "returns exception" do
94+
post :create
95+
expect(subject).to render_template(:new)
96+
end
97+
end
9198
end
9299

93100
context 'when user is not a moderator' do

spec/controllers/questions_controller_spec.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
require 'spec_helper'
22

33
describe QuestionsController do
4-
54
describe "GET index" do
65
context "with format atom" do
76
it "responds with success" do
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
require 'spec_helper'
2+
3+
describe Api::RelsController do
4+
let(:slug){Fabricate(:rel)}
5+
6+
describe "GET index" do
7+
it "responds with success" do
8+
get :index
9+
response.should be_success
10+
end
11+
end
12+
13+
describe "GET show" do
14+
it "responds with success" do
15+
get :show
16+
response.should be_success
17+
end
18+
end
19+
end

0 commit comments

Comments
 (0)