Skip to content

Commit

Permalink
Merge 5e297d9 into 027ae66
Browse files Browse the repository at this point in the history
  • Loading branch information
tobscher committed Mar 19, 2013
2 parents 027ae66 + 5e297d9 commit 5524666
Show file tree
Hide file tree
Showing 10 changed files with 58 additions and 18 deletions.
2 changes: 2 additions & 0 deletions Gemfile
Expand Up @@ -69,6 +69,8 @@ group :test, :development do
gem "pry"
gem "factory_girl_rails"
gem "guard-jasmine"
gem "guard-rspec"
gem 'rb-fsevent', '~> 0.9'
gem "jasminerice"
gem "yard"
gem 'coveralls', :require => false
Expand Down
10 changes: 10 additions & 0 deletions Gemfile.lock
Expand Up @@ -136,6 +136,9 @@ GEM
guard (>= 1.1.0)
multi_json
thor
guard-rspec (2.5.0)
guard (>= 1.1)
rspec (~> 2.11)
haml (4.0.0)
tilt
hashie (1.2.0)
Expand Down Expand Up @@ -241,6 +244,7 @@ GEM
rdoc (~> 3.4)
thor (>= 0.14.6, < 2.0)
rake (10.0.3)
rb-fsevent (0.9.3)
rdoc (3.12.2)
json (~> 1.4)
redcarpet (2.2.2)
Expand All @@ -249,6 +253,10 @@ GEM
railties (~> 3.1)
rest-client (1.6.7)
mime-types (>= 1.16)
rspec (2.13.0)
rspec-core (~> 2.13.0)
rspec-expectations (~> 2.13.0)
rspec-mocks (~> 2.13.0)
rspec-cells (0.1.7)
cells (~> 3.4)
railties (>= 3.0, < 4.1)
Expand Down Expand Up @@ -345,6 +353,7 @@ DEPENDENCIES
factory_girl_rails
google_visualr
guard-jasmine
guard-rspec
i18n-js
jasminerice
jquery-cookie-rails
Expand All @@ -361,6 +370,7 @@ DEPENDENCIES
pg
pry
rails (~> 3.2.8)
rb-fsevent (~> 0.9)
redcarpet
responders
rspec-cells
Expand Down
22 changes: 22 additions & 0 deletions Guardfile
Expand Up @@ -7,3 +7,25 @@ guard :jasmine do
watch(%r{spec/javascripts/fixtures/.+$})
watch(%r{app/assets/javascripts/(.+?)\.(js\.coffee|js|coffee)(?:\.\w+)*$}) { |m| "spec/javascripts/#{ m[1] }_spec.#{ m[2] }" }
end

guard 'rspec' do
watch(%r{^spec/.+_spec\.rb$})
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
watch('spec/spec_helper.rb') { "spec" }

# Rails example
watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
watch(%r{^app/(.*)(\.erb|\.haml)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
watch('config/routes.rb') { "spec/routing" }
watch('app/controllers/application_controller.rb') { "spec/controllers" }

# Capybara features specs
watch(%r{^app/views/(.+)/.*\.(erb|haml)$}) { |m| "spec/features/#{m[1]}_spec.rb" }

# Turnip features and steps
watch(%r{^spec/acceptance/(.+)\.feature$})
watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
end

10 changes: 5 additions & 5 deletions app/controllers/application_controller.rb
Expand Up @@ -13,12 +13,12 @@ def current_user
private
def require_login
unless current_user
redirect_to(main_app.login_path)
redirect_to(login_path(:redirect_url => request.path))
end
end

def add_breadcrumb_root
add_breadcrumb "Dashboard", main_app.root_path if current_user
add_breadcrumb "Dashboard", root_path if current_user
end

def load_user
Expand All @@ -30,13 +30,13 @@ def load_user
def load_project
@project = Project.joins(:user).where(:key => params[:key]).where(:users => {:username => params[:user] }).first

add_breadcrumb @project.name, main_app.backlog_path(:user => params[:user], :key => params[:key])
add_breadcrumb @project.name, backlog_path(:user => params[:user], :key => params[:key])
end

def load_issue
@issue = @project.issues.find_by_number(params[:id])

add_breadcrumb @issue.key, main_app.issue_path(:user => params[:user], :key => params[:key], :id => params[:id])
add_breadcrumb @issue.key, issue_path(:user => params[:user], :key => params[:key], :id => params[:id])
end

def is_admin_area?
Expand All @@ -63,6 +63,6 @@ def is_collaborator?
helper_method :is_collaborator?

def ensure_can_collaborate
redirect_to main_app.root_path unless is_collaborator?
redirect_to root_path unless is_collaborator?
end
end
12 changes: 9 additions & 3 deletions app/controllers/sessions_controller.rb
Expand Up @@ -10,20 +10,26 @@ def create
user = AuthProcessor.new(auth_hash).find_or_create_user
session[:user_id] = user.id

redirect_to main_app.root_path, :notice => I18n.t("authentication.logged_in", :username => user.name)
redirect_to redirect_url_for_login, :notice => I18n.t("authentication.logged_in", :username => user.name)
end

# Logout the user
# Redirects to the login page
def destroy
session[:user_id] = nil
redirect_to main_app.login_path, :notice => I18n.t("authentication.logged_out")
redirect_to login_path, :notice => I18n.t("authentication.logged_out")
end

# Displays an error message and redirect to the login page
def failure
flash[:error] = I18n.t("authentication.not_allowed")

redirect_to main_app.login_path
redirect_to login_path
end

private
def redirect_url_for_login
params_hash = (request.env['omniauth.params'] || {})
params_hash["redirect_url"] || root_path
end
end
2 changes: 1 addition & 1 deletion app/views/sessions/new.html.erb
Expand Up @@ -5,6 +5,6 @@
We will create an account for you as you sign in with Github.
</p>
<div class="sign-in-button">
<%= link_to t("authentication.sign_in.github"), "/auth/github", :class => "btn btn-large btn-success" %>
<%= link_to t("authentication.sign_in.github"), "/auth/github?redirect_url=#{params[:redirect_url]}", :class => "btn btn-large btn-success" %>
</div>
</div>
6 changes: 3 additions & 3 deletions spec/controllers/dashboards_controller_spec.rb
Expand Up @@ -3,8 +3,8 @@
describe DashboardsController do
context :not_logged_in do
it "should not allow any actions" do
get :index, :use_route => :tyne_core
response.should redirect_to login_path
get :index
response.should redirect_to login_path(:redirect_url => dashboards_path)
end
end

Expand All @@ -18,7 +18,7 @@

describe :index do
before :each do
get :index, :use_route => :tyne_core
get :index
end

it "should assign the list of the user's projects" do
Expand Down
8 changes: 4 additions & 4 deletions spec/controllers/projects_controller_spec.rb
Expand Up @@ -6,16 +6,16 @@
context :not_logged_in do
it "should not allow any actions" do
post :create
response.should redirect_to login_path
response.should redirect_to login_path(:redirect_url => projects_path)

delete :destroy, :id => 1
response.should redirect_to login_path
response.should redirect_to login_path(:redirect_url => projects_path)

get :github
response.should redirect_to login_path
response.should redirect_to login_path(:redirect_url => projects_path)

post :import
response.should redirect_to login_path
response.should redirect_to login_path(:redirect_url => projects_path)
end
end

Expand Down
2 changes: 1 addition & 1 deletion spec/controllers/team_members_controller_spec.rb
Expand Up @@ -6,7 +6,7 @@
context :not_logged_in do
it "should not allow any actions" do
post :create, :user => "Foo", :key => "Bar", :team_id => 1, :team_member => {}
response.should redirect_to login_path
response.should redirect_to login_path(:redirect_url => team_team_members_path(:user => "Foo", :key => "Bar", :team_id => 1))
end
end

Expand Down
2 changes: 1 addition & 1 deletion spec/controllers/teams_controller_spec.rb
Expand Up @@ -6,7 +6,7 @@
context :not_logged_in do
it "should not allow any actions" do
get :show, :user => "Foo", :key => "Bar", :id => 1
response.should redirect_to login_path
response.should redirect_to login_path(:redirect_url => team_path(:user => "Foo", :key => "Bar", :id => 1))
end
end

Expand Down

0 comments on commit 5524666

Please sign in to comment.