diff --git a/Gemfile b/Gemfile index 793dad9..6b1c7d9 100644 --- a/Gemfile +++ b/Gemfile @@ -57,6 +57,8 @@ end group :test do gem 'mocha', require: false + gem 'capybara', '2.3.0' + gem 'launchy' end gem 'devise', "~> 3.2.2" diff --git a/Gemfile.lock b/Gemfile.lock index 80dba07..d8364c0 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -27,10 +27,17 @@ GEM minitest (~> 5.1) thread_safe (~> 0.1) tzinfo (~> 1.1) + addressable (2.3.8) arel (5.0.1.20140414130214) bcrypt-ruby (3.1.2) bluecloth (2.2.0) builder (3.2.2) + capybara (2.3.0) + mime-types (>= 1.16) + nokogiri (>= 1.3.3) + rack (>= 1.0.0) + rack-test (>= 0.5.4) + xpath (~> 2.0) coffee-rails (4.0.0) coffee-script (>= 2.2.0) railties (>= 4.0.0.beta, < 5.0) @@ -77,6 +84,8 @@ GEM multi_json (>= 1.5) kgio (2.9.3) kramdown (1.1.0) + launchy (2.4.3) + addressable (~> 2.3) mail (2.5.4) mime-types (~> 1.16) treetop (~> 1.4.8) @@ -87,6 +96,7 @@ GEM rails (> 3.2.0) metaclass (0.0.4) mime-types (1.25.1) + mini_portile (0.6.2) minitest (5.3.3) mocha (1.0.0) metaclass (~> 0.0.1) @@ -94,6 +104,8 @@ GEM multi_json (1.10.0) multi_xml (0.5.4) multipart-post (1.2.0) + nokogiri (1.6.6.2) + mini_portile (~> 0.6.0) oauth2 (0.8.1) faraday (~> 0.8) httpauth (~> 0.1) @@ -206,6 +218,8 @@ GEM activesupport (>= 3.0.7) rails (>= 3.0.7) will_paginate (3.0.4) + xpath (2.0.0) + nokogiri (~> 1.3) yard (0.8.7.3) PLATFORMS @@ -213,6 +227,7 @@ PLATFORMS DEPENDENCIES bluecloth + capybara (= 2.3.0) coffee-rails (~> 4.0.0) dalli devise (~> 3.2.2) @@ -222,6 +237,7 @@ DEPENDENCIES httparty jbuilder (~> 1.0.1) jquery-rails + launchy mail_view (~> 1.0.2) maildown mocha diff --git a/app/controllers/repos_controller.rb b/app/controllers/repos_controller.rb index 6b49a6c..ae68ceb 100644 --- a/app/controllers/repos_controller.rb +++ b/app/controllers/repos_controller.rb @@ -27,10 +27,16 @@ def new end def show - @repo = Repo.where(full_name: params[:full_name]).first + @repo = Repo.where(full_name: params[:full_name]).first if @repo - @docs = @repo.doc_methods.order("created_at DESC").page(params[:page]).per_page(params[:per_page]||20) + @docs = @repo + .doc_methods + .send(params[:doc_status] || :scoper) + .order("created_at DESC") + .page(params[:page]) + .per_page(params[:per_page]||20) + @repo_sub = current_user.repo_subscriptions.where(repo_id: @repo.id).first if current_user @subscribers = @repo. subscribers. diff --git a/app/models/doc_method.rb b/app/models/doc_method.rb index bd0f8c4..417c016 100644 --- a/app/models/doc_method.rb +++ b/app/models/doc_method.rb @@ -18,6 +18,10 @@ def self.with_docs where("doc_comments_count > 0") end + def self.scoper + where(nil) + end + def raw_file read_attribute(:file) end diff --git a/app/models/user.rb b/app/models/user.rb index f253b8a..35e5ded 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -93,7 +93,7 @@ def self.find_for_github_oauth(auth, signed_in_resource=nil) user.update_attributes(params) else email = auth.info.email - email = GitHubBub::Request.fetch("/user/emails", token: token).json_body.first if email.blank? + email = GitHubBub.get("/user/emails", token: token).json_body.first if email.blank? params = params.merge(:password => Devise.friendly_token[0,20], :name => auth.extra.raw_info.name, :email => email) diff --git a/app/views/repos/show.html.erb b/app/views/repos/show.html.erb index 1176ea2..4853f54 100644 --- a/app/views/repos/show.html.erb +++ b/app/views/repos/show.html.erb @@ -80,6 +80,15 @@