From b99bb23b572a96c396c591b1b55b6351f71ec247 Mon Sep 17 00:00:00 2001 From: Rhys Powell Date: Wed, 23 Nov 2011 22:39:28 +1100 Subject: [PATCH 001/161] Update README.md --- README.md | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index f4dbd2de..877b1272 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,18 @@ -# hackety-hack.com +# hackety-hack.com # [![Build status](https://secure.travis-ci.org/hacketyhack/hackety-hack.com.png)](http://travis-ci.org/#!/hacketyhack/hackety-hack.com) -This is the source code for hackety-hack.com. +[hackety-hack.com][hh.com] is the web backend powering the collaborative features of [Hackety Hack][hh]. It is written in Rails 3 and continues to be under active development (see 'Helping Out'), the switch to Rails 3 happened quite recently so there's still lots to be done. -At the moment, we're re-building it for Rails 3. So there's not a lot of docs. Sorry about that! +## Helping Out ## + +If you have any experience writing Rails apps, feel free to help out, we're open to pull requests as long as you follow a few conditions. + ++ **Test your code**, we really can't stress this enough, ideally you should be practicing [TDD][tdd] and writing tests before you even write your code. If you don't test your code, we have no way of knowing if it works properly so please do test. ++ **If it's a major feature, file an issue**, if you file an issue we can discuss certain aspects of the new feature with you and ensure it's a good fit for hackety-hack.com. + +Additionally, if you're _not_ a developer and you have a feature you'd really like to see on the site, file an issue and we'll be sure to look into it on your behalf. + +[hh.com]: http://hackety-hack.com/ +[hh]: https://github.com/hacketyhack/hacketyhack +[tdd]: http://en.wikipedia.org/wiki/Test-driven_development \ No newline at end of file From e2b0fb5be7ea251a08d75e3094000cc7eb4390cd Mon Sep 17 00:00:00 2001 From: Rhys Powell Date: Thu, 24 Nov 2011 10:09:10 +1100 Subject: [PATCH 002/161] Added questions to a user's profile page --- app/views/users/show.html.haml | 6 ++++++ features/questions.feature | 1 + features/step_definitions/question_steps.rb | 5 +++++ 3 files changed, 12 insertions(+) diff --git a/app/views/users/show.html.haml b/app/views/users/show.html.haml index 44eac61e..33aac17c 100644 --- a/app/views/users/show.html.haml +++ b/app/views/users/show.html.haml @@ -24,6 +24,12 @@ %p Followers: = link_to resource.followers.count, resource_path(resource) + "/followers" + %section.questions + %header + %h2 Questions + - @user.questions.each do |question| + %article.question + %h1= question.title %hr - if can? :update, resource = link_to "Change My Settings", edit_registration_path(resource), :class => "btn success" diff --git a/features/questions.feature b/features/questions.feature index c7c2fb85..ac233e90 100644 --- a/features/questions.feature +++ b/features/questions.feature @@ -6,6 +6,7 @@ Feature: CRUD actions for question When I create a new question Then I should be told the question was created And I should be able to see the new question + And I should be able to see the question on my profile page Scenario: Update a question Given I am a user that has created a question diff --git a/features/step_definitions/question_steps.rb b/features/step_definitions/question_steps.rb index 296afdc0..f9b3a9e5 100644 --- a/features/step_definitions/question_steps.rb +++ b/features/step_definitions/question_steps.rb @@ -43,3 +43,8 @@ def create_question_for(user) page.should have_content('An edited question') page.should have_content('Just a quick edit') end + +Then /^I should be able to see the question on my profile page$/ do + visit user_path(@user) + page.should have_content("My Question") +end From 6fe74f2e4d35500f71e18ca18459c8ac68aec27d Mon Sep 17 00:00:00 2001 From: Rhys Powell Date: Thu, 24 Nov 2011 10:27:01 +1100 Subject: [PATCH 003/161] Made user profiles look a bit better --- app/views/users/show.html.haml | 65 ++++++++++++++++++---------------- 1 file changed, 34 insertions(+), 31 deletions(-) diff --git a/app/views/users/show.html.haml b/app/views/users/show.html.haml index 33aac17c..607a168b 100644 --- a/app/views/users/show.html.haml +++ b/app/views/users/show.html.haml @@ -1,35 +1,38 @@ - content_for :title do = "#{resource.username}'s page" -.about-user - %img{:src => gravatar_url(resource.email)} - - if current_user && current_user != resource - -if current_user.following?(resource) - = simple_form_for(resource, :url => resource_path(current_user) + '/unfollow', :method=>:post) do |f| - = f.hidden_field :followee, :value => resource.id - = f.button :submit, :value => "Unfollow", :class => "primary btn" - - else - = simple_form_for(resource, :url => resource_path(current_user) + '/follow', :method=>:post) do |f| - = f.hidden_field :followee, :value => resource.id - = f.button :submit, :value => "Follow", :class => "primary btn" +-content_for :sidebar do + %section.about-user + %img{:src => gravatar_url(resource.email)} + - if current_user && current_user != resource + -if current_user.following?(resource) + = simple_form_for(resource, :url => resource_path(current_user) + '/unfollow', :method=>:post) do |f| + = f.hidden_field :followee, :value => resource.id + = f.button :submit, :value => "Unfollow", :class => "primary btn" + - else + = simple_form_for(resource, :url => resource_path(current_user) + '/follow', :method=>:post) do |f| + = f.hidden_field :followee, :value => resource.id + = f.button :submit, :value => "Follow", :class => "primary btn" - %h2= "About #{resource.username}" - %h4= resource.about - %hr - %p - = link_to "Programs", user_programs_path(resource) - %p - Following: - =link_to resource.following.count, resource_path(resource) + "/following" - %p - Followers: - = link_to resource.followers.count, resource_path(resource) + "/followers" - %section.questions - %header - %h2 Questions - - @user.questions.each do |question| - %article.question - %h1= question.title - %hr - - if can? :update, resource - = link_to "Change My Settings", edit_registration_path(resource), :class => "btn success" + %h2= "About #{resource.username}" + %h4= resource.about + %hr + %p + = link_to "Programs", user_programs_path(resource) + %p + Following: + =link_to resource.following.count, resource_path(resource) + "/following" + %p + Followers: + = link_to resource.followers.count, resource_path(resource) + "/followers" + %hr + - if can? :update, resource + = link_to "Change My Settings", edit_registration_path(resource), :class => "btn success" + + +%section.questions + %header + %h2 Questions + - @user.questions.each do |question| + %article.question + %h4= link_to question.title, question_path(question) From 18f6c5dfe7433011fd207e47daa7734534af6cfe Mon Sep 17 00:00:00 2001 From: Rhys Powell Date: Thu, 24 Nov 2011 10:30:18 +1100 Subject: [PATCH 004/161] Made questions only show on profile if questions present --- app/views/users/show.html.haml | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/app/views/users/show.html.haml b/app/views/users/show.html.haml index 607a168b..10c4d2d2 100644 --- a/app/views/users/show.html.haml +++ b/app/views/users/show.html.haml @@ -30,9 +30,10 @@ = link_to "Change My Settings", edit_registration_path(resource), :class => "btn success" -%section.questions - %header - %h2 Questions - - @user.questions.each do |question| - %article.question - %h4= link_to question.title, question_path(question) +- if @user.questions.count != 0 + %section.questions + %header + %h2 Questions + - @user.questions.each do |question| + %article.question + %h4= link_to question.title, question_path(question) From 4b882df7d624f77cee722280982fd618c61e43a1 Mon Sep 17 00:00:00 2001 From: Rhys Powell Date: Thu, 24 Nov 2011 10:56:44 +1100 Subject: [PATCH 005/161] Answers shown on user page --- app/views/users/show.html.haml | 11 ++++++++++- features/answers.feature | 1 + features/step_definitions/answer_steps.rb | 6 ++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/app/views/users/show.html.haml b/app/views/users/show.html.haml index 10c4d2d2..bd6751c7 100644 --- a/app/views/users/show.html.haml +++ b/app/views/users/show.html.haml @@ -30,10 +30,19 @@ = link_to "Change My Settings", edit_registration_path(resource), :class => "btn success" -- if @user.questions.count != 0 +- unless @user.questions.empty? %section.questions %header %h2 Questions - @user.questions.each do |question| %article.question %h4= link_to question.title, question_path(question) + +- unless @user.answers.empty? + %section.answers + %header + %h2 Answers + - @user.answers.each do |answer| + %article.answer + %h4= "#{@user.username} answered \"#{answer.question.title}\" with:" + %p= answer.description diff --git a/features/answers.feature b/features/answers.feature index e7bd240d..70aca6cb 100644 --- a/features/answers.feature +++ b/features/answers.feature @@ -7,5 +7,6 @@ Feature: CRUD actions for answers And I answer that question Then I should be notified that my answer was submitted And I should be able to see my answer + And my answer should show on my profile page Scenario: Accept an answer diff --git a/features/step_definitions/answer_steps.rb b/features/step_definitions/answer_steps.rb index 37351127..59ebf284 100644 --- a/features/step_definitions/answer_steps.rb +++ b/features/step_definitions/answer_steps.rb @@ -17,3 +17,9 @@ page.should have_content("#{@user.username} says") page.should have_content("Have you tried turning it off and on again?") end + +Then /^my answer should show on my profile page$/ do + visit user_path(@user) + page.should have_content("answered \"#{@question.title}\" with") + page.should have_content("Have you tried turning it off and on again?") +end From 778393de4581d288d47e8f1f0a519f664f8b6f1d Mon Sep 17 00:00:00 2001 From: Rhys Powell Date: Thu, 24 Nov 2011 11:04:34 +1100 Subject: [PATCH 006/161] Styled answers on user pages better --- app/views/users/show.html.haml | 5 ++++- features/step_definitions/answer_steps.rb | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/views/users/show.html.haml b/app/views/users/show.html.haml index bd6751c7..f99b0b6f 100644 --- a/app/views/users/show.html.haml +++ b/app/views/users/show.html.haml @@ -44,5 +44,8 @@ %h2 Answers - @user.answers.each do |answer| %article.answer - %h4= "#{@user.username} answered \"#{answer.question.title}\" with:" + %h4 + = "#{@user.username} answered" + = link_to(answer.question.title, answer.question) + with: %p= answer.description diff --git a/features/step_definitions/answer_steps.rb b/features/step_definitions/answer_steps.rb index 59ebf284..e90f03f5 100644 --- a/features/step_definitions/answer_steps.rb +++ b/features/step_definitions/answer_steps.rb @@ -20,6 +20,6 @@ Then /^my answer should show on my profile page$/ do visit user_path(@user) - page.should have_content("answered \"#{@question.title}\" with") + page.should have_content(@question.title) page.should have_content("Have you tried turning it off and on again?") end From 0dadd2be7d8344393e9d481acb2a7e66c6b65528 Mon Sep 17 00:00:00 2001 From: Rhys Powell Date: Thu, 24 Nov 2011 11:23:34 +1100 Subject: [PATCH 007/161] Added alert informing logged out users about hh Closes #28 --- app/assets/stylesheets/content.css.scss | 8 +++++++- app/views/programs/show.html.haml | 9 +++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/app/assets/stylesheets/content.css.scss b/app/assets/stylesheets/content.css.scss index 98c32454..2b65e430 100644 --- a/app/assets/stylesheets/content.css.scss +++ b/app/assets/stylesheets/content.css.scss @@ -15,4 +15,10 @@ p { margin-top: 1em; color: $heading; } -} \ No newline at end of file +} + +.alert-message > a { + color: white; + font-weight: bold; + text-decoration: underline; +} diff --git a/app/views/programs/show.html.haml b/app/views/programs/show.html.haml index 3dc2d1c7..eba20d58 100644 --- a/app/views/programs/show.html.haml +++ b/app/views/programs/show.html.haml @@ -1,3 +1,12 @@ +- unless current_user + .alert-message.info + = @program.author_username + is learning how to program with + %strong Hackety Hack! + = link_to "Why not join them?", new_user_registration_path + + + %h1 '#{@program.title}', a program by #{@program.author_username} %pre From d0032c68836c02bd4804ecadc66b31d7adff682e Mon Sep 17 00:00:00 2001 From: Rhys Powell Date: Thu, 24 Nov 2011 11:44:41 +1100 Subject: [PATCH 008/161] Added syntax highlighting to program listings Closes #112 --- app/views/layouts/application.html.haml | 4 ++ app/views/programs/show.html.haml | 5 +- vendor/assets/javascripts/prettify.js | 28 ++++++++ vendor/assets/stylesheets/prettify.css | 94 +++++++++++++++++++++++++ 4 files changed, 128 insertions(+), 3 deletions(-) create mode 100644 vendor/assets/javascripts/prettify.js create mode 100644 vendor/assets/stylesheets/prettify.css diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index f526dc82..dc8a026d 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -23,6 +23,10 @@ (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(ga); })(); + + + + %body{:class => "body-#{@page_class}"} %header.topbar .topbar-inner diff --git a/app/views/programs/show.html.haml b/app/views/programs/show.html.haml index eba20d58..fb8e44a7 100644 --- a/app/views/programs/show.html.haml +++ b/app/views/programs/show.html.haml @@ -9,9 +9,8 @@ %h1 '#{@program.title}', a program by #{@program.author_username} -%pre - %code - = @program.source_code +%pre.prettyprint + = @program.source_code %hr/ diff --git a/vendor/assets/javascripts/prettify.js b/vendor/assets/javascripts/prettify.js new file mode 100644 index 00000000..eef5ad7e --- /dev/null +++ b/vendor/assets/javascripts/prettify.js @@ -0,0 +1,28 @@ +var q=null;window.PR_SHOULD_USE_CONTINUATION=!0; +(function(){function L(a){function m(a){var f=a.charCodeAt(0);if(f!==92)return f;var b=a.charAt(1);return(f=r[b])?f:"0"<=b&&b<="7"?parseInt(a.substring(1),8):b==="u"||b==="x"?parseInt(a.substring(2),16):a.charCodeAt(1)}function e(a){if(a<32)return(a<16?"\\x0":"\\x")+a.toString(16);a=String.fromCharCode(a);if(a==="\\"||a==="-"||a==="["||a==="]")a="\\"+a;return a}function h(a){for(var f=a.substring(1,a.length-1).match(/\\u[\dA-Fa-f]{4}|\\x[\dA-Fa-f]{2}|\\[0-3][0-7]{0,2}|\\[0-7]{1,2}|\\[\S\s]|[^\\]/g),a= +[],b=[],o=f[0]==="^",c=o?1:0,i=f.length;c122||(d<65||j>90||b.push([Math.max(65,j)|32,Math.min(d,90)|32]),d<97||j>122||b.push([Math.max(97,j)&-33,Math.min(d,122)&-33]))}}b.sort(function(a,f){return a[0]-f[0]||f[1]-a[1]});f=[];j=[NaN,NaN];for(c=0;ci[0]&&(i[1]+1>i[0]&&b.push("-"),b.push(e(i[1])));b.push("]");return b.join("")}function y(a){for(var f=a.source.match(/\[(?:[^\\\]]|\\[\S\s])*]|\\u[\dA-Fa-f]{4}|\\x[\dA-Fa-f]{2}|\\\d+|\\[^\dux]|\(\?[!:=]|[()^]|[^()[\\^]+/g),b=f.length,d=[],c=0,i=0;c=2&&a==="["?f[c]=h(j):a!=="\\"&&(f[c]=j.replace(/[A-Za-z]/g,function(a){a=a.charCodeAt(0);return"["+String.fromCharCode(a&-33,a|32)+"]"}));return f.join("")}for(var t=0,s=!1,l=!1,p=0,d=a.length;p=5&&"lang-"===b.substring(0,5))&&!(o&&typeof o[1]==="string"))c=!1,b="src";c||(r[f]=b)}i=d;d+=f.length;if(c){c=o[1];var j=f.indexOf(c),k=j+c.length;o[2]&&(k=f.length-o[2].length,j=k-c.length);b=b.substring(5);B(l+i,f.substring(0,j),e,p);B(l+i+j,c,C(b,c),p);B(l+i+k,f.substring(k),e,p)}else p.push(l+i,b)}a.e=p}var h={},y;(function(){for(var e=a.concat(m), +l=[],p={},d=0,g=e.length;d=0;)h[n.charAt(k)]=r;r=r[1];n=""+r;p.hasOwnProperty(n)||(l.push(r),p[n]=q)}l.push(/[\S\s]/);y=L(l)})();var t=m.length;return e}function u(a){var m=[],e=[];a.tripleQuotedStrings?m.push(["str",/^(?:'''(?:[^'\\]|\\[\S\s]|''?(?=[^']))*(?:'''|$)|"""(?:[^"\\]|\\[\S\s]|""?(?=[^"]))*(?:"""|$)|'(?:[^'\\]|\\[\S\s])*(?:'|$)|"(?:[^"\\]|\\[\S\s])*(?:"|$))/,q,"'\""]):a.multiLineStrings?m.push(["str",/^(?:'(?:[^'\\]|\\[\S\s])*(?:'|$)|"(?:[^"\\]|\\[\S\s])*(?:"|$)|`(?:[^\\`]|\\[\S\s])*(?:`|$))/, +q,"'\"`"]):m.push(["str",/^(?:'(?:[^\n\r'\\]|\\.)*(?:'|$)|"(?:[^\n\r"\\]|\\.)*(?:"|$))/,q,"\"'"]);a.verbatimStrings&&e.push(["str",/^@"(?:[^"]|"")*(?:"|$)/,q]);var h=a.hashComments;h&&(a.cStyleComments?(h>1?m.push(["com",/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,q,"#"]):m.push(["com",/^#(?:(?:define|elif|else|endif|error|ifdef|include|ifndef|line|pragma|undef|warning)\b|[^\n\r]*)/,q,"#"]),e.push(["str",/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h|[a-z]\w*)>/,q])):m.push(["com",/^#[^\n\r]*/, +q,"#"]));a.cStyleComments&&(e.push(["com",/^\/\/[^\n\r]*/,q]),e.push(["com",/^\/\*[\S\s]*?(?:\*\/|$)/,q]));a.regexLiterals&&e.push(["lang-regex",/^(?:^^\.?|[!+-]|!=|!==|#|%|%=|&|&&|&&=|&=|\(|\*|\*=|\+=|,|-=|->|\/|\/=|:|::|;|<|<<|<<=|<=|=|==|===|>|>=|>>|>>=|>>>|>>>=|[?@[^]|\^=|\^\^|\^\^=|{|\||\|=|\|\||\|\|=|~|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\s*(\/(?=[^*/])(?:[^/[\\]|\\[\S\s]|\[(?:[^\\\]]|\\[\S\s])*(?:]|$))+\/)/]);(h=a.types)&&e.push(["typ",h]);a=(""+a.keywords).replace(/^ | $/g, +"");a.length&&e.push(["kwd",RegExp("^(?:"+a.replace(/[\s,]+/g,"|")+")\\b"),q]);m.push(["pln",/^\s+/,q," \r\n\t\xa0"]);e.push(["lit",/^@[$_a-z][\w$@]*/i,q],["typ",/^(?:[@_]?[A-Z]+[a-z][\w$@]*|\w+_t\b)/,q],["pln",/^[$_a-z][\w$@]*/i,q],["lit",/^(?:0x[\da-f]+|(?:\d(?:_\d+)*\d*(?:\.\d*)?|\.\d\+)(?:e[+-]?\d+)?)[a-z]*/i,q,"0123456789"],["pln",/^\\[\S\s]?/,q],["pun",/^.[^\s\w"-$'./@\\`]*/,q]);return x(m,e)}function D(a,m){function e(a){switch(a.nodeType){case 1:if(k.test(a.className))break;if("BR"===a.nodeName)h(a), +a.parentNode&&a.parentNode.removeChild(a);else for(a=a.firstChild;a;a=a.nextSibling)e(a);break;case 3:case 4:if(p){var b=a.nodeValue,d=b.match(t);if(d){var c=b.substring(0,d.index);a.nodeValue=c;(b=b.substring(d.index+d[0].length))&&a.parentNode.insertBefore(s.createTextNode(b),a.nextSibling);h(a);c||a.parentNode.removeChild(a)}}}}function h(a){function b(a,d){var e=d?a.cloneNode(!1):a,f=a.parentNode;if(f){var f=b(f,1),g=a.nextSibling;f.appendChild(e);for(var h=g;h;h=g)g=h.nextSibling,f.appendChild(h)}return e} +for(;!a.nextSibling;)if(a=a.parentNode,!a)return;for(var a=b(a.nextSibling,0),e;(e=a.parentNode)&&e.nodeType===1;)a=e;d.push(a)}var k=/(?:^|\s)nocode(?:\s|$)/,t=/\r\n?|\n/,s=a.ownerDocument,l;a.currentStyle?l=a.currentStyle.whiteSpace:window.getComputedStyle&&(l=s.defaultView.getComputedStyle(a,q).getPropertyValue("white-space"));var p=l&&"pre"===l.substring(0,3);for(l=s.createElement("LI");a.firstChild;)l.appendChild(a.firstChild);for(var d=[l],g=0;g=0;){var h=m[e];A.hasOwnProperty(h)?window.console&&console.warn("cannot override language handler %s",h):A[h]=a}}function C(a,m){if(!a||!A.hasOwnProperty(a))a=/^\s*=o&&(h+=2);e>=c&&(a+=2)}}catch(w){"console"in window&&console.log(w&&w.stack?w.stack:w)}}var v=["break,continue,do,else,for,if,return,while"],w=[[v,"auto,case,char,const,default,double,enum,extern,float,goto,int,long,register,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"], +"catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"],F=[w,"alignof,align_union,asm,axiom,bool,concept,concept_map,const_cast,constexpr,decltype,dynamic_cast,explicit,export,friend,inline,late_check,mutable,namespace,nullptr,reinterpret_cast,static_assert,static_cast,template,typeid,typename,using,virtual,where"],G=[w,"abstract,boolean,byte,extends,final,finally,implements,import,instanceof,null,native,package,strictfp,super,synchronized,throws,transient"], +H=[G,"as,base,by,checked,decimal,delegate,descending,dynamic,event,fixed,foreach,from,group,implicit,in,interface,internal,into,is,lock,object,out,override,orderby,params,partial,readonly,ref,sbyte,sealed,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,var"],w=[w,"debugger,eval,export,function,get,null,set,undefined,var,with,Infinity,NaN"],I=[v,"and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None"], +J=[v,"alias,and,begin,case,class,def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,rescue,retry,self,super,then,true,undef,unless,until,when,yield,BEGIN,END"],v=[v,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"],K=/^(DIR|FILE|vector|(de|priority_)?queue|list|stack|(const_)?iterator|(multi)?(set|map)|bitset|u?(int|float)\d*)/,N=/\S/,O=u({keywords:[F,H,w,"caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END"+ +I,J,v],hashComments:!0,cStyleComments:!0,multiLineStrings:!0,regexLiterals:!0}),A={};k(O,["default-code"]);k(x([],[["pln",/^[^]*(?:>|$)/],["com",/^<\!--[\S\s]*?(?:--\>|$)/],["lang-",/^<\?([\S\s]+?)(?:\?>|$)/],["lang-",/^<%([\S\s]+?)(?:%>|$)/],["pun",/^(?:<[%?]|[%?]>)/],["lang-",/^]*>([\S\s]+?)<\/xmp\b[^>]*>/i],["lang-js",/^]*>([\S\s]*?)(<\/script\b[^>]*>)/i],["lang-css",/^]*>([\S\s]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i]]), +["default-markup","htm","html","mxml","xhtml","xml","xsl"]);k(x([["pln",/^\s+/,q," \t\r\n"],["atv",/^(?:"[^"]*"?|'[^']*'?)/,q,"\"'"]],[["tag",/^^<\/?[a-z](?:[\w-.:]*\w)?|\/?>$/i],["atn",/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^\s"'>]*(?:[^\s"'/>]|\/(?=\s)))/],["pun",/^[/<->]+/],["lang-js",/^on\w+\s*=\s*"([^"]+)"/i],["lang-js",/^on\w+\s*=\s*'([^']+)'/i],["lang-js",/^on\w+\s*=\s*([^\s"'>]+)/i],["lang-css",/^style\s*=\s*"([^"]+)"/i],["lang-css",/^style\s*=\s*'([^']+)'/i],["lang-css", +/^style\s*=\s*([^\s"'>]+)/i]]),["in.tag"]);k(x([],[["atv",/^[\S\s]+/]]),["uq.val"]);k(u({keywords:F,hashComments:!0,cStyleComments:!0,types:K}),["c","cc","cpp","cxx","cyc","m"]);k(u({keywords:"null,true,false"}),["json"]);k(u({keywords:H,hashComments:!0,cStyleComments:!0,verbatimStrings:!0,types:K}),["cs"]);k(u({keywords:G,cStyleComments:!0}),["java"]);k(u({keywords:v,hashComments:!0,multiLineStrings:!0}),["bsh","csh","sh"]);k(u({keywords:I,hashComments:!0,multiLineStrings:!0,tripleQuotedStrings:!0}), +["cv","py"]);k(u({keywords:"caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END",hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["perl","pl","pm"]);k(u({keywords:J,hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["rb"]);k(u({keywords:w,cStyleComments:!0,regexLiterals:!0}),["js"]);k(u({keywords:"all,and,by,catch,class,else,extends,false,finally,for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then,true,try,unless,until,when,while,yes", +hashComments:3,cStyleComments:!0,multilineStrings:!0,tripleQuotedStrings:!0,regexLiterals:!0}),["coffee"]);k(x([],[["str",/^[\S\s]+/]]),["regex"]);window.prettyPrintOne=function(a,m,e){var h=document.createElement("PRE");h.innerHTML=a;e&&D(h,e);E({g:m,i:e,h:h});return h.innerHTML};window.prettyPrint=function(a){function m(){for(var e=window.PR_SHOULD_USE_CONTINUATION?l.now()+250:Infinity;p=0){var k=k.match(g),f,b;if(b= +!k){b=n;for(var o=void 0,c=b.firstChild;c;c=c.nextSibling)var i=c.nodeType,o=i===1?o?b:c:i===3?N.test(c.nodeValue)?b:o:o;b=(f=o===b?void 0:o)&&"CODE"===f.tagName}b&&(k=f.className.match(g));k&&(k=k[1]);b=!1;for(o=n.parentNode;o;o=o.parentNode)if((o.tagName==="pre"||o.tagName==="code"||o.tagName==="xmp")&&o.className&&o.className.indexOf("prettyprint")>=0){b=!0;break}b||((b=(b=n.className.match(/\blinenums\b(?::(\d+))?/))?b[1]&&b[1].length?+b[1]:!0:!1)&&D(n,b),d={g:k,h:n,i:b},E(d))}}p Date: Thu, 24 Nov 2011 14:49:25 +1100 Subject: [PATCH 009/161] Worked on the site's design a bit --- app/assets/stylesheets/application.css.scss | 3 ++- app/assets/stylesheets/content.css.scss | 18 ++++++++++++---- app/assets/stylesheets/layout.css.scss | 2 +- app/views/layouts/application.html.haml | 5 ++++- app/views/programs/show.html.haml | 24 ++++++++++++++------- 5 files changed, 37 insertions(+), 15 deletions(-) diff --git a/app/assets/stylesheets/application.css.scss b/app/assets/stylesheets/application.css.scss index 42daa395..ab32850a 100644 --- a/app/assets/stylesheets/application.css.scss +++ b/app/assets/stylesheets/application.css.scss @@ -13,4 +13,5 @@ @import "forms.css.scss"; @import "content.css.scss"; @import "home.css.scss"; -@import "questions.css.scss"; \ No newline at end of file +@import "questions.css.scss"; + diff --git a/app/assets/stylesheets/content.css.scss b/app/assets/stylesheets/content.css.scss index 2b65e430..12544bef 100644 --- a/app/assets/stylesheets/content.css.scss +++ b/app/assets/stylesheets/content.css.scss @@ -17,8 +17,18 @@ p { } } -.alert-message > a { - color: white; - font-weight: bold; - text-decoration: underline; +#content { + margin-top: 32px; +} + +.page-title { + margin-bottom: 17px; + border-bottom: 1px solid #DDD; + -webkit-box-shadow: 0 1px 0 rgba(255, 255, 255, 0.5); + -moz-box-shadow: 0 1px 0 rgba(255, 255, 255, 0.5); + box-shadow: 0 1px 0 rgba(255, 255, 255, 0.5); +} + +.page-title h1 { + margin-bottom: 0px; } diff --git a/app/assets/stylesheets/layout.css.scss b/app/assets/stylesheets/layout.css.scss index b73cd725..1fda8b6f 100644 --- a/app/assets/stylesheets/layout.css.scss +++ b/app/assets/stylesheets/layout.css.scss @@ -109,4 +109,4 @@ footer { background-color: #444; } } -} \ No newline at end of file +} diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index dc8a026d..2e12f274 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -50,7 +50,10 @@ #{flash[:alert]} - unless title.empty? - %h1.title= title + .page-title + %h1.title + = title + %small= yield :subtitle #content{:class => @content_class} = yield diff --git a/app/views/programs/show.html.haml b/app/views/programs/show.html.haml index fb8e44a7..21ce85a6 100644 --- a/app/views/programs/show.html.haml +++ b/app/views/programs/show.html.haml @@ -1,16 +1,24 @@ - unless current_user - .alert-message.info - = @program.author_username - is learning how to program with - %strong Hackety Hack! - = link_to "Why not join them?", new_user_registration_path + .alert-message.block-message.info + %p + = @program.author_username + and many others are using + %strong Hackety Hack + to learn how to code. + %p Hackety Hack is a free program for Windows, Mac OS X and Linux that can teach you how to make games, applications and more and share those programs with your friends. You can ask other budding programmers questions and follow them to see what code they're working on through the Hackety Hack website. + = link_to "Sign up", new_user_registration_path, :class => "btn primary" + = link_to "Learn More", root_path, :class => "btn" +- content_for :title do + = @program.title -%h1 '#{@program.title}', a program by #{@program.author_username} +- content_for :subtitle do + %small + by + = link_to @program.author_username, user_path(@program.author_username) -%pre.prettyprint - = @program.source_code +%pre.prettyprint= @program.source_code %hr/ From c927b687af5f230843983482611c5f5d14a0acf2 Mon Sep 17 00:00:00 2001 From: Rhys Powell Date: Thu, 24 Nov 2011 14:55:41 +1100 Subject: [PATCH 010/161] Further design tweaks --- app/assets/stylesheets/content.css.scss | 11 +++++------ app/views/static/faq.html.haml | 2 -- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/app/assets/stylesheets/content.css.scss b/app/assets/stylesheets/content.css.scss index 12544bef..71a22fef 100644 --- a/app/assets/stylesheets/content.css.scss +++ b/app/assets/stylesheets/content.css.scss @@ -8,8 +8,7 @@ p { line-height: 1.15; padding: 0.5em 0; margin: 0.5em 0; - border-bottom: 1px solid #ccc; - border-top: 1px solid #ccc; + border-bottom: 1px solid #DDD; } h1 { margin-top: 1em; @@ -17,10 +16,6 @@ p { } } -#content { - margin-top: 32px; -} - .page-title { margin-bottom: 17px; border-bottom: 1px solid #DDD; @@ -32,3 +27,7 @@ p { .page-title h1 { margin-bottom: 0px; } + +.block-message { + margin-top: 18px; +} diff --git a/app/views/static/faq.html.haml b/app/views/static/faq.html.haml index c71f9439..3ddccca1 100644 --- a/app/views/static/faq.html.haml +++ b/app/views/static/faq.html.haml @@ -7,8 +7,6 @@ #faq :markdown - (or FAQ re: HH) - ##My install of Hackety-Hack crashes? Yes, we noticed that. Sorry. Multi-platform weirdness and all that. There are some known problems with HH on Windows Vista and XP, and they are being worked on. From b0aaf013182b03639329f81c80ff4f8ec3152ed1 Mon Sep 17 00:00:00 2001 From: Dominic Dagradi Date: Thu, 24 Nov 2011 16:24:12 -0500 Subject: [PATCH 011/161] removed *so many* borders, styled programs page --- app/assets/stylesheets/programs.css.scss | 48 ++++++++++++++++++++++++ app/helpers/programs_helper.rb | 5 +++ 2 files changed, 53 insertions(+) create mode 100644 app/assets/stylesheets/programs.css.scss create mode 100644 app/helpers/programs_helper.rb diff --git a/app/assets/stylesheets/programs.css.scss b/app/assets/stylesheets/programs.css.scss new file mode 100644 index 00000000..18f78291 --- /dev/null +++ b/app/assets/stylesheets/programs.css.scss @@ -0,0 +1,48 @@ +.programs { + + margin-bottom: 2em; + .heading { + @include clearfix; + padding: 0.75em; + background: $green; + + h3, .description { + color: white; + } + + h3 { + float: left; + margin-bottom: 0; + margin-right: 1em; + } + .description { + float: left; + margin-top: 0.2em; + } + } + + + ul { + @include clearfix; + margin: 0; + padding-top: 1em; + + li { + @include columns(4); + padding: 0.75em 0; + border-top: 1px solid #ddd; + } + li:nth-child(4n) { + margin-right: 0; + } + li:nth-child(4n+1) { + clear: both; + } + } +} + +#featured { + .heading { + background: $orangered; + } +} \ No newline at end of file diff --git a/app/helpers/programs_helper.rb b/app/helpers/programs_helper.rb new file mode 100644 index 00000000..783bc0c9 --- /dev/null +++ b/app/helpers/programs_helper.rb @@ -0,0 +1,5 @@ +module ProgramsHelper + def program_link program_name, program_slug, username + "#{link_to(program_name, user_program_path(username, program_slug))} by #{link_to(username, user_path(username))}".html_safe + end +end From 96fb06c1631a0aea973be1fcd59f7885af23e00c Mon Sep 17 00:00:00 2001 From: Brandon Hays Date: Thu, 24 Nov 2011 14:27:31 -0700 Subject: [PATCH 012/161] Created Moderators and the ability to move questions to/from support --- app/assets/stylesheets/questions.css.scss | 5 +++++ app/models/ability.rb | 6 +++++- app/models/question.rb | 2 +- app/models/user.rb | 1 + app/views/questions/_list.html.haml | 2 ++ 5 files changed, 14 insertions(+), 2 deletions(-) diff --git a/app/assets/stylesheets/questions.css.scss b/app/assets/stylesheets/questions.css.scss index 592368d6..3ceccaa5 100644 --- a/app/assets/stylesheets/questions.css.scss +++ b/app/assets/stylesheets/questions.css.scss @@ -108,3 +108,8 @@ background: rgba(158, 183,68, 0.1) url("accepted.png") 99% 0.5em no-repeat; } } + +.move_question { + float:right; + padding-top:4px; +} diff --git a/app/models/ability.rb b/app/models/ability.rb index ca0d984e..16b37006 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -4,7 +4,11 @@ class Ability def initialize(user) user ||= User.new - can :read, :all + if user.moderator? + can :manage, :all + else + can :read, :all + end unless user.new_record? can :create, [Question, Answer] diff --git a/app/models/question.rb b/app/models/question.rb index f57ecbf6..9c734a52 100644 --- a/app/models/question.rb +++ b/app/models/question.rb @@ -14,5 +14,5 @@ class Question scope :newest_first, sort(:created_at.desc) scope :supports, where(:support => true ) - scope :no_supports, where(:support => nil) + scope :no_supports, where('$or' => [{:support=> false}, {:support => nil}]) end diff --git a/app/models/user.rb b/app/models/user.rb index 695107a7..8c43a7f7 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -8,6 +8,7 @@ class User key :username, String key :email, String key :about, String + key :moderator, Boolean many :questions many :answers diff --git a/app/views/questions/_list.html.haml b/app/views/questions/_list.html.haml index fdea6bb2..db17c87d 100644 --- a/app/views/questions/_list.html.haml +++ b/app/views/questions/_list.html.haml @@ -11,3 +11,5 @@ %span.date= time_ago_in_words(list.created_at) ago .description= truncate(list.description, :length => 150) + - if current_user && current_user.moderator? + %div.move_question= link_to "Move to #{list.support? ? 'Questions' : 'Support'} ยป", question_path(list, :question => { :support => (list.support? ? "false" : "true") }), :method => :put, :class => "btn small info" From 3b67730e176e3afd8e5fda3fe16735bb105bd3ff Mon Sep 17 00:00:00 2001 From: Rhys Powell Date: Sun, 27 Nov 2011 16:20:37 +1100 Subject: [PATCH 013/161] Made website default to device viewport width on mobile browsers. Closes #96 --- app/views/layouts/application.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 2e12f274..33e44529 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -5,7 +5,7 @@ - title = yield :title %title #{title.blank? ? "" : "#{title} | "}Hackety Hack! - + / = stylesheet_link_tag "application" From 5b9f286f3b3ebc974317a8439fc0c717e4638c09 Mon Sep 17 00:00:00 2001 From: Rhys Powell Date: Mon, 28 Nov 2011 12:45:14 +1100 Subject: [PATCH 014/161] Added hint that our answer forms support Markdown --- app/views/answers/_form.html.haml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/views/answers/_form.html.haml b/app/views/answers/_form.html.haml index 964a3635..f15e2502 100644 --- a/app/views/answers/_form.html.haml +++ b/app/views/answers/_form.html.haml @@ -2,7 +2,8 @@ = f.error_notification .inputs - = f.input :description, :as => :text, :label => "Answer" + = f.input :description, :as => :text, :label => "Answer", + :hint => "You can format your input with Markdown".html_safe .actions = f.button :submit, :value => "Post Answer", :class => "primary btn" From ae6bc2f360c980f741a9f0ed0cdaf7eea8ec7693 Mon Sep 17 00:00:00 2001 From: Rhys Powell Date: Mon, 28 Nov 2011 12:47:59 +1100 Subject: [PATCH 015/161] Added hint that our question form supports Markdown Closes #114 --- app/views/questions/_form.html.haml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/views/questions/_form.html.haml b/app/views/questions/_form.html.haml index ced38b9f..6a21dc7f 100644 --- a/app/views/questions/_form.html.haml +++ b/app/views/questions/_form.html.haml @@ -4,7 +4,8 @@ .inputs = f.input :title, :hint => "What's your question?" - = f.input :description, :as => :text, :hint => "Provide some details about your problem to help diagnose it" + = f.input :description, :as => :text, + :hint => "Provide some details about your problem to help diagnose it You can format your input with Markdown".html_safe .actions - = f.button :submit , 'Ask Everyone', :class => "primary btn" \ No newline at end of file + = f.button :submit , 'Ask Everyone', :class => "primary btn" From f9447eb9c4702795ff9e501524fb2af46475d538 Mon Sep 17 00:00:00 2001 From: Abhi Rao Date: Mon, 5 Dec 2011 00:08:02 -0600 Subject: [PATCH 016/161] Adding presenters dir to load path --- config/application.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/application.rb b/config/application.rb index bdfec545..d2382e0a 100644 --- a/config/application.rb +++ b/config/application.rb @@ -11,7 +11,7 @@ module HacketyHackCom class Application < Rails::Application - config.autoload_paths += %W(#{config.root}/lib) + config.autoload_paths << "#{config.root}/lib" << "#{config.root}/presenters" config.encoding = "utf-8" From c0a83ad5328013441b8ab1feec3421ccf3680142 Mon Sep 17 00:00:00 2001 From: Abhi Rao Date: Mon, 5 Dec 2011 00:08:26 -0600 Subject: [PATCH 017/161] Adding nested /answers to /supports Previously support answers were actually being processed in /questions --- config/routes.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/config/routes.rb b/config/routes.rb index f9144702..e139c368 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -9,7 +9,9 @@ match "/download" => redirect("/downloads/latest") scope '/support', :as => 'support' do - resources :questions, :controller => 'questions' + resources :questions, :controller => 'questions' do + resources :answers + end end constraints(ApiConstraint) do From 76862a98dde2a41716c7f2a3613c0c39f0fd607c Mon Sep 17 00:00:00 2001 From: Abhi Rao Date: Mon, 5 Dec 2011 00:09:25 -0600 Subject: [PATCH 018/161] Adding presenters for question/support pages Replacing hack that generated the questions/supports pages with presenters. View now delegates all logic to presenters. Which presenter is used is determined by controller. --- app/controllers/questions_controller.rb | 40 ++++++++++++++++++------- app/presenters/question_presenter.rb | 35 ++++++++++++++++++++++ app/presenters/support_presenter.rb | 35 ++++++++++++++++++++++ app/views/questions/_form.html.haml | 3 +- app/views/shared/_ask.html.haml | 2 +- 5 files changed, 101 insertions(+), 14 deletions(-) create mode 100644 app/presenters/question_presenter.rb create mode 100644 app/presenters/support_presenter.rb diff --git a/app/controllers/questions_controller.rb b/app/controllers/questions_controller.rb index 36b4f4ba..d80ef834 100644 --- a/app/controllers/questions_controller.rb +++ b/app/controllers/questions_controller.rb @@ -1,6 +1,7 @@ class QuestionsController < InheritedController - before_filter :set_support load_and_authorize_resource + prepend_before_filter :set_presenter + prepend_before_filter :set_support def create @question = Question.create params[:question] @@ -18,22 +19,31 @@ def update end def collection - if @support - @questions ||= end_of_association_chain.supports.newest_first.paginate(:page => params[:page]) - else - @questions ||= end_of_association_chain.no_supports.newest_first.paginate(:page => params[:page]) - end + @questions = @presenter.apply_scope(end_of_association_chain).newest_first.paginate(:page => params[:page]) end - + def collection_url - @support ? support_questions_path : questions_path + collection_path end + + def collection_path + @presenter.collection_path + end + def new_resource_path - @support ? new_support_question_path : new_question_path + @presenter.new_resource_path + end + + def resource_url(*params) + resource_path(params) end - def resource_path(*resource) - @support ? support_question_path(*resource) : question_path(*resource) + def resource_path(*other) + if other[0] + @presenter.resource_path(other) + else + @presenter.resource_path(resource) + end end def edit_resource_path @@ -47,4 +57,12 @@ def set_support end end + def set_presenter + if @support + @presenter = SupportPresenter.new(resource) + else + @presenter = QuestionPresenter.new(resource) + end + end + end diff --git a/app/presenters/question_presenter.rb b/app/presenters/question_presenter.rb new file mode 100644 index 00000000..aaaba577 --- /dev/null +++ b/app/presenters/question_presenter.rb @@ -0,0 +1,35 @@ +class QuestionPresenter + include Rails.application.routes.url_helpers + + def initialize(q) + @question = q + end + + def resource_path(question) + if question + question_path(question) + else + question_path(@question) + end + end + + def new_resource_path + new_question_path + end + + def collection_path + questions_path + end + + def edit_resource_path + edit_question_path + end + + def apply_scope(chain) + chain.no_supports + end + + def answers_path + question_answer_path(@question) + end +end diff --git a/app/presenters/support_presenter.rb b/app/presenters/support_presenter.rb new file mode 100644 index 00000000..2075cf09 --- /dev/null +++ b/app/presenters/support_presenter.rb @@ -0,0 +1,35 @@ +class SupportPresenter + include Rails.application.routes.url_helpers + + def initialize(sq) + @support_question = sq + end + + def page_title + "Support Questions" + end + + def new_resource_path + new_support_question_path + end + + def collection_path + support_questions_path + end + + def edit_resource_path + edit_support_question_path + end + + def resource_path(question) + if question + support_question_path(question) + else + support_question_path(@question) + end + end + + def apply_scope(chain) + chain.supports + end +end diff --git a/app/views/questions/_form.html.haml b/app/views/questions/_form.html.haml index 6a21dc7f..20f8843e 100644 --- a/app/views/questions/_form.html.haml +++ b/app/views/questions/_form.html.haml @@ -1,5 +1,4 @@ -- curr_module = @support ? '/support' : '' -= simple_form_for(resource, :url => curr_module.concat(@form_url)) do |f| += simple_form_for(resource, :url => @form_url) do |f| = f.error_notification .inputs diff --git a/app/views/shared/_ask.html.haml b/app/views/shared/_ask.html.haml index 0fd3ec35..24935a4b 100644 --- a/app/views/shared/_ask.html.haml +++ b/app/views/shared/_ask.html.haml @@ -2,7 +2,7 @@ %h2 Have A Question? %p Ask away! No question is too big or too small. - if current_user - = link_to "Ask a Question", new_question_path, :class => "btn success" + = link_to "Ask a Question", new_resource_path, :class => "btn success" - else %p Log in to ask a question = link_to "Log In", login_path, :class => "btn success" \ No newline at end of file From d11de37967c9fd922b44fc2f10db6bfd7d1ddfb0 Mon Sep 17 00:00:00 2001 From: Dominic Dagradi Date: Thu, 29 Dec 2011 15:05:26 -0500 Subject: [PATCH 019/161] Program page updates * Refactored list markup into a few helpers * Updated program page styles * Removed dead CSS * Refactored bad FAQ/title CSS, tweaked other areas --- app/assets/stylesheets/application.css.scss | 1 + app/assets/stylesheets/content.css.scss | 34 ++++--------- app/assets/stylesheets/home.css.scss | 51 +++---------------- app/assets/stylesheets/layout.css.scss | 28 +++++----- .../stylesheets/lib/bootstrap/preboot.scss | 8 +-- app/assets/stylesheets/lib/shared.css.scss | 1 + app/assets/stylesheets/programs.css.scss | 19 +++++-- app/assets/stylesheets/questions.css.scss | 19 ++++--- app/controllers/programs_controller.rb | 6 +-- app/helpers/programs_helper.rb | 11 +++- app/models/program.rb | 3 ++ app/views/layouts/application.html.haml | 2 + app/views/programs/index.html.haml | 46 ++++++++--------- app/views/programs/show.html.haml | 19 +++---- app/views/static/faq.html.haml | 2 +- 15 files changed, 109 insertions(+), 141 deletions(-) diff --git a/app/assets/stylesheets/application.css.scss b/app/assets/stylesheets/application.css.scss index ab32850a..e4bedc72 100644 --- a/app/assets/stylesheets/application.css.scss +++ b/app/assets/stylesheets/application.css.scss @@ -14,4 +14,5 @@ @import "content.css.scss"; @import "home.css.scss"; @import "questions.css.scss"; +@import "programs.css.scss"; diff --git a/app/assets/stylesheets/content.css.scss b/app/assets/stylesheets/content.css.scss index 71a22fef..7ef67f1d 100644 --- a/app/assets/stylesheets/content.css.scss +++ b/app/assets/stylesheets/content.css.scss @@ -1,33 +1,19 @@ p { - margin: 0; - padding-bottom: 0.5em; + margin-bottom: 1em; } -#faq { - h2 { - line-height: 1.15; - padding: 0.5em 0; - margin: 0.5em 0; - border-bottom: 1px solid #DDD; - } - h1 { - margin-top: 1em; - color: $heading; - } -} +h1 { -.page-title { - margin-bottom: 17px; - border-bottom: 1px solid #DDD; - -webkit-box-shadow: 0 1px 0 rgba(255, 255, 255, 0.5); - -moz-box-shadow: 0 1px 0 rgba(255, 255, 255, 0.5); - box-shadow: 0 1px 0 rgba(255, 255, 255, 0.5); } -.page-title h1 { - margin-bottom: 0px; +h2 { + font-size: 1.75em; + margin-bottom: 0.5em; } .block-message { - margin-top: 18px; -} + margin-bottom: 0.5em; + p { + margin-bottom: 1em; + } +} \ No newline at end of file diff --git a/app/assets/stylesheets/home.css.scss b/app/assets/stylesheets/home.css.scss index d47f45ec..8a7eff79 100644 --- a/app/assets/stylesheets/home.css.scss +++ b/app/assets/stylesheets/home.css.scss @@ -23,13 +23,13 @@ .container { padding-top: 0; } - + border-top: none; section { @include clearfix; background: white; padding-bottom: 1em; - + p { font-size: 1.25em; line-height: 1.75em; @@ -45,7 +45,7 @@ } } - + #download { background: white url("download.png") 0 4em no-repeat; h1 { @@ -58,7 +58,7 @@ text-align: center; margin-top: 1em; margin-bottom: 1em; - + .download { text-transform: uppercase; margin-bottom: 1em; @@ -72,7 +72,7 @@ @include offset(5); } } - + #explore { background: white url("explore.png") 95% 7em no-repeat; h1 { @@ -84,7 +84,7 @@ margin-left: 2em; } } - + #ask { background: white url("ask.png") 0 7em no-repeat; min-height: 340px; @@ -98,41 +98,4 @@ @include offset(5); } } -} - -/*.body-home #content-wrap { - border-top: none;*/ -/* section { - @include clearfix; - margin: 0 36px 36px 18px; - padding-bottom: 36px; - border-bottom: 6px dotted $linkColor; - - font-size: 1.7em; - - h1 { - font-size: 1.6em; - } - p { - font-size: 1em; - line-height: 1.5em; - margin-bottom: 1em; - } - - img.new_program { - @include columns(5); - } - img.lesson { - @include columns(8); - float: right; - margin-right: 0; - margin-left: $gridGutterWidth*2; - - } - } - - section.last { - border: none; - margin-bottom: 0; - } -}*/ +} \ No newline at end of file diff --git a/app/assets/stylesheets/layout.css.scss b/app/assets/stylesheets/layout.css.scss index 1fda8b6f..ab2ea601 100644 --- a/app/assets/stylesheets/layout.css.scss +++ b/app/assets/stylesheets/layout.css.scss @@ -7,25 +7,25 @@ body { } .topbar { - position: relative; + position: relative; height: auto; @include box-shadow(0px 1px 10px rgba(0,0,0,0.5)); border-bottom: 1px solid $heading + #444; } -header .topbar-inner { +header .topbar-inner { background: $heading; .container { padding: 0.6em 0; } - + li a { border-radius: 8px; font-size: 14px; padding: 11px 11px 10px; text-shadow: 0 1px 1px rgba(0, 0, 0, 0.5); } - + li a:hover { background-color: $heading + #111; text-shadow: none; @@ -36,7 +36,7 @@ header .topbar-inner { margin-left: -40px; width: 185px; height: 40px; - + a { position: absolute; top: -2px; @@ -53,13 +53,13 @@ header .topbar-inner { #content-wrap { border-top: 1px solid ($heading + #444); margin: auto; - + .container { position: relative; - } + } } -#content-wrap > .container { +#content-wrap > .container { background: white; border-radius: 0 0 8px 8px; padding: 40px 18px 18px; @@ -70,7 +70,7 @@ header .topbar-inner { #content { @include columns(11); } - + #sidebar { @include columns(5, true); .edit, .delete { @@ -83,11 +83,11 @@ header .topbar-inner { padding: 1.5em; } } - + } -p, h1,h2,h3,h4,h5 { - color: #555; +p,h1,h2,h3,h4,h5 { + color: $text-color; } .alert-message { @@ -98,7 +98,7 @@ p, h1,h2,h3,h4,h5 { footer { background: $heading; padding: 0.5em 0; - + .pills { margin: 0; a { @@ -108,5 +108,5 @@ footer { a:hover { background-color: #444; } - } + } } diff --git a/app/assets/stylesheets/lib/bootstrap/preboot.scss b/app/assets/stylesheets/lib/bootstrap/preboot.scss index 0c75a7fc..82af2bae 100644 --- a/app/assets/stylesheets/lib/bootstrap/preboot.scss +++ b/app/assets/stylesheets/lib/bootstrap/preboot.scss @@ -131,7 +131,7 @@ $analog2: spin($baseColor, -22); width: ($gridColumnWidth * $columnSpan) + ($gridGutterWidth * ($columnSpan - 1)); display: inline; float: left; - + @if $last { margin-right: 0; } @@ -203,7 +203,7 @@ $analog2: spin($baseColor, -22); background-image: -webkit-linear-gradient(left, $startColor, $endColor); // Safari 5.1+, Chrome 10+ background-image: -o-linear-gradient(left, $startColor, $endColor); // Opera 11.10 background-image: linear-gradient(left, $startColor, $endColor); // Le standard - filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#{$startColor}', endColorstr='#{$endColor}', GradientType=1); // IE9 and down + filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#{$startColor}', endColorstr='#{$endColor}', GradientType=1); // IE9 and down } @mixin gradient-vertical ($startColor: #555, $endColor: #333) { background-color: $endColor; @@ -215,7 +215,7 @@ $analog2: spin($baseColor, -22); background-image: -webkit-linear-gradient(top, $startColor, $endColor); // Safari 5.1+, Chrome 10+ background-image: -o-linear-gradient(top, $startColor, $endColor); // Opera 11.10 background-image: linear-gradient(top, $startColor, $endColor); // The standard - filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#{$startColor}', endColorstr='#{$endColor}', GradientType=0); // IE9 and down + filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#{$startColor}', endColorstr='#{$endColor}', GradientType=0); // IE9 and down } @mixin gradient-directional ($startColor: #555, $endColor: #333, $deg: 45deg) { background-color: $endColor; @@ -235,7 +235,7 @@ $analog2: spin($baseColor, -22); background-image: -ms-linear-gradient($startColor, $midColor $colorStop, $endColor); background-image: -o-linear-gradient($startColor, $midColor $colorStop, $endColor); background-image: linear-gradient($startColor, $midColor $colorStop, $endColor); - filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#{$startColor}', endColorstr='#{$endColor}', GradientType=0); // IE9 and down, gets no color-stop at all for proper fallback + filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#{$startColor}', endColorstr='#{$endColor}', GradientType=0); // IE9 and down, gets no color-stop at all for proper fallback } // Gradient Bar Colors for buttons and allerts diff --git a/app/assets/stylesheets/lib/shared.css.scss b/app/assets/stylesheets/lib/shared.css.scss index 159ce7a3..679cc2d0 100644 --- a/app/assets/stylesheets/lib/shared.css.scss +++ b/app/assets/stylesheets/lib/shared.css.scss @@ -1,5 +1,6 @@ $heading: #253E59; $background: $heading + #999; +$text-color: #555; $orangered: #BF4904; diff --git a/app/assets/stylesheets/programs.css.scss b/app/assets/stylesheets/programs.css.scss index 18f78291..457ba835 100644 --- a/app/assets/stylesheets/programs.css.scss +++ b/app/assets/stylesheets/programs.css.scss @@ -28,14 +28,23 @@ padding-top: 1em; li { - @include columns(4); + @include columns(5); padding: 0.75em 0; border-top: 1px solid #ddd; + + .title { + font-weight: bold; + margin-bottom: 0.1em; + } + + .author { + a { + font-style: italic; + color: lighten($text-color, 20%); + } + } } - li:nth-child(4n) { - margin-right: 0; - } - li:nth-child(4n+1) { + li:nth-child(3n+1) { clear: both; } } diff --git a/app/assets/stylesheets/questions.css.scss b/app/assets/stylesheets/questions.css.scss index 592368d6..c32642fe 100644 --- a/app/assets/stylesheets/questions.css.scss +++ b/app/assets/stylesheets/questions.css.scss @@ -4,7 +4,7 @@ margin-bottom: 0.15em; } .meta { - a { + a { font-style: italic; } font-style: italic; @@ -32,10 +32,10 @@ } @include columns(1); padding: 6px - } + } .summary { @include columns(9, last); - + h2 { line-height: 1; margin-bottom: 0.15em; @@ -45,7 +45,7 @@ } } } - + .unanswered { .answer-count, .answer-count h3 { color: $orangered; @@ -59,17 +59,16 @@ .accepted { background-image: url("accepted.png"); } - + } .question { - color: #555; p { font-size: 1.15em; line-height: 1.5; margin-bottom: 1.25em; } - + h2 { margin-top: 0.5em; padding-bottom: 0.5em; @@ -83,8 +82,8 @@ position: relative; list-style-type: none; padding: 1em 1em; - border-bottom: 1px solid #ddd; - + border-bottom: 1px solid #ddd; + .choose { float: left; opacity: 0.5; @@ -106,5 +105,5 @@ } .selected-answer { background: rgba(158, 183,68, 0.1) url("accepted.png") 99% 0.5em no-repeat; - } + } } diff --git a/app/controllers/programs_controller.rb b/app/controllers/programs_controller.rb index fcaadd71..f4e306df 100644 --- a/app/controllers/programs_controller.rb +++ b/app/controllers/programs_controller.rb @@ -4,9 +4,9 @@ class ProgramsController < InheritedController belongs_to :user, :optional => true respond_to :html, :only => [:index, :show] - def show - # @program = Program.find_by_slug(params[:slug]) - show! + def index + @featured = Program.featured + index! end ################# diff --git a/app/helpers/programs_helper.rb b/app/helpers/programs_helper.rb index 783bc0c9..747b7327 100644 --- a/app/helpers/programs_helper.rb +++ b/app/helpers/programs_helper.rb @@ -1,5 +1,12 @@ module ProgramsHelper - def program_link program_name, program_slug, username - "#{link_to(program_name, user_program_path(username, program_slug))} by #{link_to(username, user_path(username))}".html_safe + # def program_link program_name, program_slug, username + # "#{link_to(program_name, user_program_path(username, program_slug))} by #{link_to(username, user_path(username))}".html_safe + # end + def program_link program + "#{link_to(program.title, user_program_path(program.author_username, program))}".html_safe + end + + def author_link username + "#{link_to(username, user_path(username))}".html_safe end end diff --git a/app/models/program.rb b/app/models/program.rb index 29b095b8..d6a94b63 100644 --- a/app/models/program.rb +++ b/app/models/program.rb @@ -5,8 +5,10 @@ class Program key :slug, String key :title, String key :source_code, String + key :featured, Boolean scope :by_username, lambda { |username| where(:author_username => username) } + scope :featured, where(:featured => true) before_create :make_slug @@ -21,4 +23,5 @@ def to_param slug end + end diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 33e44529..b9ef0bf4 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -49,6 +49,8 @@ .alert-message.alert #{flash[:alert]} + = yield :alert + - unless title.empty? .page-title %h1.title diff --git a/app/views/programs/index.html.haml b/app/views/programs/index.html.haml index 51934198..5e63fc9a 100644 --- a/app/views/programs/index.html.haml +++ b/app/views/programs/index.html.haml @@ -1,29 +1,25 @@ -%h1 Every Awesome Program We've Got +- content_for :title do + Programs -Here's the motherload! Check out these great programs everybody has made! +- unless @featured.blank? + #featured.programs + .heading + %h3 Featured + .description Our favorite selection of projects. -%h2 The Super Sweet List + %ul + - @featured.each do |program| + %li + .title= program_link program + .author= author_link program.author_username -We've picked out a few extra-awesome ones for your enjoyment. +#all-programs.programs + .heading + %h3 All Programs + .description Every program uploaded by our users! -%ul - %li - :markdown - [Connect Four](http://hackety-hack.com/users/wilkie/programs/connect_four), by [wilkie](http://hackety-hack.com/users/wilkie) - %li - :markdown - [Calender basic](http://hackety-hack.com/users/cyber/programs/calender_basic), by [cyber](http://hackety-hack.com/users/cyber) - %li - :markdown - [Space Invaders](http://hackety-hack.com/users/wilkie/programs/invaders), by [wilkie](http://hackety-hack.com/users/wilkie) - %li - :markdown - [Turtle Fun](http://hackety-hack.com/users/frog/programs/turtle_fun), by [frog](http://hackety-hack.com/users/frog) - -%h2 Other Great Programs - -Here it is: every single program we've got. Check them out! - -%ul - - collection.each do |program| - %li #{link_to program.title, program_path(program)}, by #{link_to program.author_username, "/users/#{program.author_username}"} + %ul + - @programs.each do |program| + %li + .title= program_link program + .author= author_link program.author_username diff --git a/app/views/programs/show.html.haml b/app/views/programs/show.html.haml index 21ce85a6..66830e36 100644 --- a/app/views/programs/show.html.haml +++ b/app/views/programs/show.html.haml @@ -1,14 +1,15 @@ - unless current_user - .alert-message.block-message.info - %p - = @program.author_username - and many others are using - %strong Hackety Hack - to learn how to code. - %p Hackety Hack is a free program for Windows, Mac OS X and Linux that can teach you how to make games, applications and more and share those programs with your friends. You can ask other budding programmers questions and follow them to see what code they're working on through the Hackety Hack website. + - content_for :alert do + .alert-message.block-message.info + %p + = author_link @program.author_username + and many others are using + %strong Hackety Hack + to learn how to code. + %p Hackety Hack is a free program for Windows, Mac OS X and Linux that can teach you how to make games, applications and more and share those programs with your friends. You can ask other budding programmers questions and follow them to see what code they're working on through the Hackety Hack website. - = link_to "Sign up", new_user_registration_path, :class => "btn primary" - = link_to "Learn More", root_path, :class => "btn" + = link_to "Sign up", new_user_registration_path, :class => "btn primary" + = link_to "Learn More", root_path, :class => "btn" - content_for :title do = @program.title diff --git a/app/views/static/faq.html.haml b/app/views/static/faq.html.haml index 3ddccca1..f93698a7 100644 --- a/app/views/static/faq.html.haml +++ b/app/views/static/faq.html.haml @@ -80,6 +80,6 @@ [Raindropmemory](http://raindropmemory.deviantart.com/#/d1xzrog) on Deviant Art made them. They're super great, aren't they? - # Thanks! + ## Thanks! Special thanks goes out to Eric Affleck for writing this FAQ. From c4374a7114ce169122417d32dc8108b9187d79ae Mon Sep 17 00:00:00 2001 From: Dominic Dagradi Date: Thu, 29 Dec 2011 15:30:34 -0500 Subject: [PATCH 020/161] Added timestamps to programs Display timestamps on the program page, and output program titles with '.titleize' --- app/assets/stylesheets/programs.css.scss | 5 ++--- app/helpers/programs_helper.rb | 16 ++++++++++------ app/models/program.rb | 1 + app/views/programs/index.html.haml | 4 ++-- 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/app/assets/stylesheets/programs.css.scss b/app/assets/stylesheets/programs.css.scss index 457ba835..bc537018 100644 --- a/app/assets/stylesheets/programs.css.scss +++ b/app/assets/stylesheets/programs.css.scss @@ -38,9 +38,8 @@ } .author { - a { - font-style: italic; - color: lighten($text-color, 20%); + a, & { + color: lighten($text-color, 40%); } } } diff --git a/app/helpers/programs_helper.rb b/app/helpers/programs_helper.rb index 747b7327..f67b71e5 100644 --- a/app/helpers/programs_helper.rb +++ b/app/helpers/programs_helper.rb @@ -1,12 +1,16 @@ module ProgramsHelper - # def program_link program_name, program_slug, username - # "#{link_to(program_name, user_program_path(username, program_slug))} by #{link_to(username, user_path(username))}".html_safe - # end def program_link program - "#{link_to(program.title, user_program_path(program.author_username, program))}".html_safe + "#{link_to(program.title.titleize, user_program_path(program.author_username, program))}".html_safe end - def author_link username - "#{link_to(username, user_path(username))}".html_safe + def author_link username, program = nil + output = "" + output += link_to(username, user_path(username)) + + if program + output += ", #{program.created_at.strftime('%m/%d/%y')}" unless program.created_at.nil? + end + + output.html_safe end end diff --git a/app/models/program.rb b/app/models/program.rb index d6a94b63..f36399f6 100644 --- a/app/models/program.rb +++ b/app/models/program.rb @@ -6,6 +6,7 @@ class Program key :title, String key :source_code, String key :featured, Boolean + timestamps! scope :by_username, lambda { |username| where(:author_username => username) } scope :featured, where(:featured => true) diff --git a/app/views/programs/index.html.haml b/app/views/programs/index.html.haml index 5e63fc9a..b1624175 100644 --- a/app/views/programs/index.html.haml +++ b/app/views/programs/index.html.haml @@ -11,7 +11,7 @@ - @featured.each do |program| %li .title= program_link program - .author= author_link program.author_username + .author= author_link program.author_username, program #all-programs.programs .heading @@ -22,4 +22,4 @@ - @programs.each do |program| %li .title= program_link program - .author= author_link program.author_username + .author= author_link program.author_username, program From a89b0fe0a9b5aac898769406e420960cd482c1c7 Mon Sep 17 00:00:00 2001 From: Dominic Dagradi Date: Thu, 29 Dec 2011 15:45:57 -0500 Subject: [PATCH 021/161] Fixed incorrect question link on FAQ page --- app/views/shared/_ask.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/shared/_ask.html.haml b/app/views/shared/_ask.html.haml index 24935a4b..0fd3ec35 100644 --- a/app/views/shared/_ask.html.haml +++ b/app/views/shared/_ask.html.haml @@ -2,7 +2,7 @@ %h2 Have A Question? %p Ask away! No question is too big or too small. - if current_user - = link_to "Ask a Question", new_resource_path, :class => "btn success" + = link_to "Ask a Question", new_question_path, :class => "btn success" - else %p Log in to ask a question = link_to "Log In", login_path, :class => "btn success" \ No newline at end of file From db0b3aa47a795b8e6b4715f0f95851cb5f0e9f0b Mon Sep 17 00:00:00 2001 From: Dominic Dagradi Date: Thu, 29 Dec 2011 15:48:32 -0500 Subject: [PATCH 022/161] Added consistent sub-navigation to program index and show --- app/assets/stylesheets/content.css.scss | 22 ++++++++++++++++++++++ app/views/programs/index.html.haml | 19 ++++++++++++++----- app/views/programs/show.html.haml | 11 +++++------ app/views/users/show.html.haml | 12 ++++++------ 4 files changed, 47 insertions(+), 17 deletions(-) diff --git a/app/assets/stylesheets/content.css.scss b/app/assets/stylesheets/content.css.scss index 7ef67f1d..67fc2286 100644 --- a/app/assets/stylesheets/content.css.scss +++ b/app/assets/stylesheets/content.css.scss @@ -16,4 +16,26 @@ h2 { p { margin-bottom: 1em; } +} + +ul.inline-menu { + @include clearfix; + list-style-type: none; + margin: 0; + li { + float: left; + padding-right: 1em; + border-right: 1px solid #ccc; + margin-right: 1em; + } + li:last-child { + border: none; + margin: 0; + padding: 0; + } +} + +.bottom-nav { + border-top: 1px solid #ccc; + padding-top: 1.5em; } \ No newline at end of file diff --git a/app/views/programs/index.html.haml b/app/views/programs/index.html.haml index b1624175..46f0a890 100644 --- a/app/views/programs/index.html.haml +++ b/app/views/programs/index.html.haml @@ -1,7 +1,10 @@ - content_for :title do - Programs + - if @user + #{@user.username}'s Programs + - else + Programs -- unless @featured.blank? +- unless @featured.blank? or @user #featured.programs .heading %h3 Featured @@ -14,12 +17,18 @@ .author= author_link program.author_username, program #all-programs.programs - .heading - %h3 All Programs - .description Every program uploaded by our users! + - unless @user + .heading + %h3 All Programs + .description Every program uploaded by our users! %ul - @programs.each do |program| %li .title= program_link program .author= author_link program.author_username, program + +- if @user + %ul.inline-menu.bottom-nav + %li= link_to "All Programs", programs_path + %li= link_to "#{@user.username}'s profile", user_path(@user) diff --git a/app/views/programs/show.html.haml b/app/views/programs/show.html.haml index 66830e36..6a2441f8 100644 --- a/app/views/programs/show.html.haml +++ b/app/views/programs/show.html.haml @@ -19,10 +19,9 @@ by = link_to @program.author_username, user_path(@program.author_username) -%pre.prettyprint= @program.source_code +#program + %pre.prettyprint= @program.source_code -%hr/ - -%h3 Other Programs - -Make sure to check out all the other programs other users have made on the #{link_to "All Programs page", programs_path}! + %ul.inline-menu.bottom-nav + %li= link_to "#{@program.author_username}'s programs", user_programs_path(@program.author_username) + %li= link_to "All Programs", programs_path diff --git a/app/views/users/show.html.haml b/app/views/users/show.html.haml index f99b0b6f..0e71a2be 100644 --- a/app/views/users/show.html.haml +++ b/app/views/users/show.html.haml @@ -17,12 +17,12 @@ %h2= "About #{resource.username}" %h4= resource.about %hr - %p - = link_to "Programs", user_programs_path(resource) - %p + %p + = link_to pluralize(resource.programs.count, "Program"), user_programs_path(resource) + %p Following: =link_to resource.following.count, resource_path(resource) + "/following" - %p + %p Followers: = link_to resource.followers.count, resource_path(resource) + "/followers" %hr @@ -32,7 +32,7 @@ - unless @user.questions.empty? %section.questions - %header + %header %h2 Questions - @user.questions.each do |question| %article.question @@ -44,7 +44,7 @@ %h2 Answers - @user.answers.each do |answer| %article.answer - %h4 + %h4 = "#{@user.username} answered" = link_to(answer.question.title, answer.question) with: From ec58f808f5449483bf54f44d815c9d52a825d5bf Mon Sep 17 00:00:00 2001 From: Dominic Dagradi Date: Thu, 29 Dec 2011 16:28:25 -0500 Subject: [PATCH 023/161] Refactored user profiles * Unified user's question and answer lists * Updated user info sidebar styles * User edit page uses correct form elements and appropriate sidebar --- app/assets/stylesheets/application.css.scss | 1 + app/assets/stylesheets/content.css.scss | 21 +++++++++ app/assets/stylesheets/layout.css.scss | 8 ++-- app/assets/stylesheets/programs.css.scss | 20 --------- app/assets/stylesheets/users.css.scss | 23 ++++++++++ app/models/answer.rb | 1 + app/views/devise/registrations/edit.html.erb | 26 ----------- app/views/devise/registrations/edit.html.haml | 21 +++++++++ app/views/users/_form.html.erb | 15 ------- app/views/users/show.html.haml | 43 ++++++++++--------- features/step_definitions/user_steps.rb | 2 +- 11 files changed, 96 insertions(+), 85 deletions(-) create mode 100644 app/assets/stylesheets/users.css.scss delete mode 100644 app/views/devise/registrations/edit.html.erb create mode 100644 app/views/devise/registrations/edit.html.haml delete mode 100644 app/views/users/_form.html.erb diff --git a/app/assets/stylesheets/application.css.scss b/app/assets/stylesheets/application.css.scss index e4bedc72..e5ba7b96 100644 --- a/app/assets/stylesheets/application.css.scss +++ b/app/assets/stylesheets/application.css.scss @@ -15,4 +15,5 @@ @import "home.css.scss"; @import "questions.css.scss"; @import "programs.css.scss"; +@import "users.css.scss"; diff --git a/app/assets/stylesheets/content.css.scss b/app/assets/stylesheets/content.css.scss index 67fc2286..89192c0a 100644 --- a/app/assets/stylesheets/content.css.scss +++ b/app/assets/stylesheets/content.css.scss @@ -11,6 +11,27 @@ h2 { margin-bottom: 0.5em; } +.heading { + @include clearfix; + padding: 0.75em; + background: $green; + + h3, .description { + color: white; + } + + h3 { + float: left; + margin-bottom: 0; + margin-right: 1em; + } + .description { + float: left; + margin-top: 0.2em; + } +} + + .block-message { margin-bottom: 0.5em; p { diff --git a/app/assets/stylesheets/layout.css.scss b/app/assets/stylesheets/layout.css.scss index ab2ea601..54f76169 100644 --- a/app/assets/stylesheets/layout.css.scss +++ b/app/assets/stylesheets/layout.css.scss @@ -3,9 +3,14 @@ html { } body { + color: $text-color; background: $background url("square_bg.png") fixed; } +p,h1,h2,h3,h4,h5 { + color: $text-color; +} + .topbar { position: relative; height: auto; @@ -86,9 +91,6 @@ header .topbar-inner { } -p,h1,h2,h3,h4,h5 { - color: $text-color; -} .alert-message { margin-top: -18px; diff --git a/app/assets/stylesheets/programs.css.scss b/app/assets/stylesheets/programs.css.scss index bc537018..84b3a897 100644 --- a/app/assets/stylesheets/programs.css.scss +++ b/app/assets/stylesheets/programs.css.scss @@ -1,26 +1,6 @@ .programs { margin-bottom: 2em; - .heading { - @include clearfix; - padding: 0.75em; - background: $green; - - h3, .description { - color: white; - } - - h3 { - float: left; - margin-bottom: 0; - margin-right: 1em; - } - .description { - float: left; - margin-top: 0.2em; - } - } - ul { @include clearfix; diff --git a/app/assets/stylesheets/users.css.scss b/app/assets/stylesheets/users.css.scss new file mode 100644 index 00000000..45be3005 --- /dev/null +++ b/app/assets/stylesheets/users.css.scss @@ -0,0 +1,23 @@ +.user-questions, .user-answers { + ul { + margin: 0; + list-style-type: none; + padding: 1em 0; + + li { + @include clearfix; + padding-bottom: 0.5em; + border-bottom: 1px solid #ddd; + margin-bottom: 0.5em; + + .title, .description { + @include columns(8); + } + + .meta { + @include columns(3, true); + text-align: right; + } + } + } +} \ No newline at end of file diff --git a/app/models/answer.rb b/app/models/answer.rb index e5d27c3b..bfed4f8a 100644 --- a/app/models/answer.rb +++ b/app/models/answer.rb @@ -2,6 +2,7 @@ class Answer include MongoMapper::Document key :description, String + timestamps! validates_presence_of :description diff --git a/app/views/devise/registrations/edit.html.erb b/app/views/devise/registrations/edit.html.erb deleted file mode 100644 index 310baf93..00000000 --- a/app/views/devise/registrations/edit.html.erb +++ /dev/null @@ -1,26 +0,0 @@ -<% content_for :title do %> -Edit <%= resource_name.to_s.humanize %> -<% end %> - -<%= simple_form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :method => :put }) do |f| %> - <%= f.error_notification %> - -
- <%= f.input :username, :autofocus => true %> - <%= f.input :email, :autofocus => true %> - <%= f.input :password, :hint => "leave it blank if you don't want to change it", :required => false %> - <%= f.input :password_confirmation, :required => false %> - <%= f.input :current_password, :hint => "we need your current password to confirm your changes", :required => true %> - <%= f.input :about %> -
- -
- <%= f.button :submit, "Update" %> -
-<% end %> - -

Cancel my account

- -

Unhappy? <%= link_to "Cancel my account", registration_path(resource_name), :confirm => "Are you sure?", :method => :delete %>.

- -<%= link_to "Back", :back %> diff --git a/app/views/devise/registrations/edit.html.haml b/app/views/devise/registrations/edit.html.haml new file mode 100644 index 00000000..d1f375d4 --- /dev/null +++ b/app/views/devise/registrations/edit.html.haml @@ -0,0 +1,21 @@ +- content_for :title do + Edit #{resource_name.to_s.humanize} + += simple_form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :method => :put }) do |f| + = f.error_notification + .inputs + = f.input :username, :autofocus => true + = f.input :email, :autofocus => true + .inputs + = f.input :password, :hint => "Leave it blank if you don't want to change it", :required => false + = f.input :password_confirmation, :required => false + .inputs + = f.input :about, :as => :text + .actions + = f.button :submit, "Update", :class => "btn primary" + +- content_for :sidebar do + %section + %h2 Cancel my account + %p + Unhappy? #{link_to "Cancel my account", registration_path(resource_name), :confirm => "Are you sure?", :method => :delete}. diff --git a/app/views/users/_form.html.erb b/app/views/users/_form.html.erb deleted file mode 100644 index eca09d5b..00000000 --- a/app/views/users/_form.html.erb +++ /dev/null @@ -1,15 +0,0 @@ -<%= simple_form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| %> - <%= f.error_notification %> - -
- <%= f.input :username, :autofocus => true %> - <%= f.input :email %> - <%= f.input :password %> - <%= f.input :password_confirmation %> - <%= f.input :about, :as => :text %> -
- -
- <%= f.button :submit, "Sign up", :class => "btn primary" %> -
-<% end %> diff --git a/app/views/users/show.html.haml b/app/views/users/show.html.haml index 0e71a2be..c85b0b8f 100644 --- a/app/views/users/show.html.haml +++ b/app/views/users/show.html.haml @@ -1,5 +1,5 @@ - content_for :title do - = "#{resource.username}'s page" + = "#{resource.username}'s Profile" -content_for :sidebar do %section.about-user @@ -14,9 +14,8 @@ = f.hidden_field :followee, :value => resource.id = f.button :submit, :value => "Follow", :class => "primary btn" - %h2= "About #{resource.username}" - %h4= resource.about - %hr + - unless resource.about.blank? + %p= resource.about %p = link_to pluralize(resource.programs.count, "Program"), user_programs_path(resource) %p @@ -31,21 +30,25 @@ - unless @user.questions.empty? - %section.questions - %header - %h2 Questions - - @user.questions.each do |question| - %article.question - %h4= link_to question.title, question_path(question) + %section.user-questions + .heading + %h3= pluralize(@user.questions.count, "Question") + %ul + - @user.questions.each do |question| + %li + .title + = link_to question.title, question_path(question) + .meta + asked #{question.created_at.strftime("%b %e, %l:%M %p")} - unless @user.answers.empty? - %section.answers - %header - %h2 Answers - - @user.answers.each do |answer| - %article.answer - %h4 - = "#{@user.username} answered" - = link_to(answer.question.title, answer.question) - with: - %p= answer.description + %section.user-answers + .heading + %h3= pluralize(@user.answers.count, "Answer") + %ul + - @user.answers.each do |answer| + %li + .description + = answer.description.truncate(100) + .meta + = link_to("View Answer", answer.question) diff --git a/features/step_definitions/user_steps.rb b/features/step_definitions/user_steps.rb index dd5c3554..5915f4d1 100644 --- a/features/step_definitions/user_steps.rb +++ b/features/step_definitions/user_steps.rb @@ -19,7 +19,7 @@ def login_user Then /^it should have the right information$/ do page.should have_selector('title', :content => "#{@user.username}'s page") - page.should have_content("About #{@user.username}") + page.should have_content("#{@user.username}'s Profile") end When /^I edit my profile$/ do From a6bb076319a0e1dacd977bdb60cf2349ea938e65 Mon Sep 17 00:00:00 2001 From: Dominic Dagradi Date: Thu, 29 Dec 2011 16:34:15 -0500 Subject: [PATCH 024/161] Reverted missing 'current password' field on user edit --- app/views/devise/registrations/edit.html.haml | 1 + 1 file changed, 1 insertion(+) diff --git a/app/views/devise/registrations/edit.html.haml b/app/views/devise/registrations/edit.html.haml index d1f375d4..e41bb470 100644 --- a/app/views/devise/registrations/edit.html.haml +++ b/app/views/devise/registrations/edit.html.haml @@ -9,6 +9,7 @@ .inputs = f.input :password, :hint => "Leave it blank if you don't want to change it", :required => false = f.input :password_confirmation, :required => false + = f.input :current_password, :hint => "we need your current password to confirm your changes", :required => true .inputs = f.input :about, :as => :text .actions From 7269df25999eb96c9c42bab061a3bc458db01e6a Mon Sep 17 00:00:00 2001 From: Steve Klabnik Date: Mon, 2 Jan 2012 02:59:34 -0500 Subject: [PATCH 025/161] Fixing downloads page --- app/views/users/_form.html.haml | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 app/views/users/_form.html.haml diff --git a/app/views/users/_form.html.haml b/app/views/users/_form.html.haml new file mode 100644 index 00000000..e69de29b From 991ffb2b19af0d8beef769bf32cc2600374c3f87 Mon Sep 17 00:00:00 2001 From: Steve Klabnik Date: Wed, 4 Jan 2012 14:58:14 -0500 Subject: [PATCH 026/161] Revert "Refactored user profiles" This reverts commit ec58f808f5449483bf54f44d815c9d52a825d5bf. Conflicts: app/views/devise/registrations/edit.html.haml --- app/assets/stylesheets/application.css.scss | 1 - app/assets/stylesheets/content.css.scss | 21 --------- app/assets/stylesheets/layout.css.scss | 8 ++-- app/assets/stylesheets/programs.css.scss | 20 +++++++++ app/assets/stylesheets/users.css.scss | 23 ---------- app/models/answer.rb | 1 - app/views/devise/registrations/edit.html.erb | 26 +++++++++++ app/views/devise/registrations/edit.html.haml | 22 ---------- app/views/users/_form.html.erb | 15 +++++++ app/views/users/show.html.haml | 43 +++++++++---------- features/step_definitions/user_steps.rb | 2 +- 11 files changed, 85 insertions(+), 97 deletions(-) delete mode 100644 app/assets/stylesheets/users.css.scss create mode 100644 app/views/devise/registrations/edit.html.erb delete mode 100644 app/views/devise/registrations/edit.html.haml create mode 100644 app/views/users/_form.html.erb diff --git a/app/assets/stylesheets/application.css.scss b/app/assets/stylesheets/application.css.scss index e5ba7b96..e4bedc72 100644 --- a/app/assets/stylesheets/application.css.scss +++ b/app/assets/stylesheets/application.css.scss @@ -15,5 +15,4 @@ @import "home.css.scss"; @import "questions.css.scss"; @import "programs.css.scss"; -@import "users.css.scss"; diff --git a/app/assets/stylesheets/content.css.scss b/app/assets/stylesheets/content.css.scss index 89192c0a..67fc2286 100644 --- a/app/assets/stylesheets/content.css.scss +++ b/app/assets/stylesheets/content.css.scss @@ -11,27 +11,6 @@ h2 { margin-bottom: 0.5em; } -.heading { - @include clearfix; - padding: 0.75em; - background: $green; - - h3, .description { - color: white; - } - - h3 { - float: left; - margin-bottom: 0; - margin-right: 1em; - } - .description { - float: left; - margin-top: 0.2em; - } -} - - .block-message { margin-bottom: 0.5em; p { diff --git a/app/assets/stylesheets/layout.css.scss b/app/assets/stylesheets/layout.css.scss index 54f76169..ab2ea601 100644 --- a/app/assets/stylesheets/layout.css.scss +++ b/app/assets/stylesheets/layout.css.scss @@ -3,14 +3,9 @@ html { } body { - color: $text-color; background: $background url("square_bg.png") fixed; } -p,h1,h2,h3,h4,h5 { - color: $text-color; -} - .topbar { position: relative; height: auto; @@ -91,6 +86,9 @@ header .topbar-inner { } +p,h1,h2,h3,h4,h5 { + color: $text-color; +} .alert-message { margin-top: -18px; diff --git a/app/assets/stylesheets/programs.css.scss b/app/assets/stylesheets/programs.css.scss index 84b3a897..bc537018 100644 --- a/app/assets/stylesheets/programs.css.scss +++ b/app/assets/stylesheets/programs.css.scss @@ -1,6 +1,26 @@ .programs { margin-bottom: 2em; + .heading { + @include clearfix; + padding: 0.75em; + background: $green; + + h3, .description { + color: white; + } + + h3 { + float: left; + margin-bottom: 0; + margin-right: 1em; + } + .description { + float: left; + margin-top: 0.2em; + } + } + ul { @include clearfix; diff --git a/app/assets/stylesheets/users.css.scss b/app/assets/stylesheets/users.css.scss deleted file mode 100644 index 45be3005..00000000 --- a/app/assets/stylesheets/users.css.scss +++ /dev/null @@ -1,23 +0,0 @@ -.user-questions, .user-answers { - ul { - margin: 0; - list-style-type: none; - padding: 1em 0; - - li { - @include clearfix; - padding-bottom: 0.5em; - border-bottom: 1px solid #ddd; - margin-bottom: 0.5em; - - .title, .description { - @include columns(8); - } - - .meta { - @include columns(3, true); - text-align: right; - } - } - } -} \ No newline at end of file diff --git a/app/models/answer.rb b/app/models/answer.rb index bfed4f8a..e5d27c3b 100644 --- a/app/models/answer.rb +++ b/app/models/answer.rb @@ -2,7 +2,6 @@ class Answer include MongoMapper::Document key :description, String - timestamps! validates_presence_of :description diff --git a/app/views/devise/registrations/edit.html.erb b/app/views/devise/registrations/edit.html.erb new file mode 100644 index 00000000..310baf93 --- /dev/null +++ b/app/views/devise/registrations/edit.html.erb @@ -0,0 +1,26 @@ +<% content_for :title do %> +Edit <%= resource_name.to_s.humanize %> +<% end %> + +<%= simple_form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :method => :put }) do |f| %> + <%= f.error_notification %> + +
+ <%= f.input :username, :autofocus => true %> + <%= f.input :email, :autofocus => true %> + <%= f.input :password, :hint => "leave it blank if you don't want to change it", :required => false %> + <%= f.input :password_confirmation, :required => false %> + <%= f.input :current_password, :hint => "we need your current password to confirm your changes", :required => true %> + <%= f.input :about %> +
+ +
+ <%= f.button :submit, "Update" %> +
+<% end %> + +

Cancel my account

+ +

Unhappy? <%= link_to "Cancel my account", registration_path(resource_name), :confirm => "Are you sure?", :method => :delete %>.

+ +<%= link_to "Back", :back %> diff --git a/app/views/devise/registrations/edit.html.haml b/app/views/devise/registrations/edit.html.haml deleted file mode 100644 index e41bb470..00000000 --- a/app/views/devise/registrations/edit.html.haml +++ /dev/null @@ -1,22 +0,0 @@ -- content_for :title do - Edit #{resource_name.to_s.humanize} - -= simple_form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :method => :put }) do |f| - = f.error_notification - .inputs - = f.input :username, :autofocus => true - = f.input :email, :autofocus => true - .inputs - = f.input :password, :hint => "Leave it blank if you don't want to change it", :required => false - = f.input :password_confirmation, :required => false - = f.input :current_password, :hint => "we need your current password to confirm your changes", :required => true - .inputs - = f.input :about, :as => :text - .actions - = f.button :submit, "Update", :class => "btn primary" - -- content_for :sidebar do - %section - %h2 Cancel my account - %p - Unhappy? #{link_to "Cancel my account", registration_path(resource_name), :confirm => "Are you sure?", :method => :delete}. diff --git a/app/views/users/_form.html.erb b/app/views/users/_form.html.erb new file mode 100644 index 00000000..eca09d5b --- /dev/null +++ b/app/views/users/_form.html.erb @@ -0,0 +1,15 @@ +<%= simple_form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| %> + <%= f.error_notification %> + +
+ <%= f.input :username, :autofocus => true %> + <%= f.input :email %> + <%= f.input :password %> + <%= f.input :password_confirmation %> + <%= f.input :about, :as => :text %> +
+ +
+ <%= f.button :submit, "Sign up", :class => "btn primary" %> +
+<% end %> diff --git a/app/views/users/show.html.haml b/app/views/users/show.html.haml index c85b0b8f..0e71a2be 100644 --- a/app/views/users/show.html.haml +++ b/app/views/users/show.html.haml @@ -1,5 +1,5 @@ - content_for :title do - = "#{resource.username}'s Profile" + = "#{resource.username}'s page" -content_for :sidebar do %section.about-user @@ -14,8 +14,9 @@ = f.hidden_field :followee, :value => resource.id = f.button :submit, :value => "Follow", :class => "primary btn" - - unless resource.about.blank? - %p= resource.about + %h2= "About #{resource.username}" + %h4= resource.about + %hr %p = link_to pluralize(resource.programs.count, "Program"), user_programs_path(resource) %p @@ -30,25 +31,21 @@ - unless @user.questions.empty? - %section.user-questions - .heading - %h3= pluralize(@user.questions.count, "Question") - %ul - - @user.questions.each do |question| - %li - .title - = link_to question.title, question_path(question) - .meta - asked #{question.created_at.strftime("%b %e, %l:%M %p")} + %section.questions + %header + %h2 Questions + - @user.questions.each do |question| + %article.question + %h4= link_to question.title, question_path(question) - unless @user.answers.empty? - %section.user-answers - .heading - %h3= pluralize(@user.answers.count, "Answer") - %ul - - @user.answers.each do |answer| - %li - .description - = answer.description.truncate(100) - .meta - = link_to("View Answer", answer.question) + %section.answers + %header + %h2 Answers + - @user.answers.each do |answer| + %article.answer + %h4 + = "#{@user.username} answered" + = link_to(answer.question.title, answer.question) + with: + %p= answer.description diff --git a/features/step_definitions/user_steps.rb b/features/step_definitions/user_steps.rb index 5915f4d1..dd5c3554 100644 --- a/features/step_definitions/user_steps.rb +++ b/features/step_definitions/user_steps.rb @@ -19,7 +19,7 @@ def login_user Then /^it should have the right information$/ do page.should have_selector('title', :content => "#{@user.username}'s page") - page.should have_content("#{@user.username}'s Profile") + page.should have_content("About #{@user.username}") end When /^I edit my profile$/ do From 6e7f9c9054c7d232f04f1fef047e21485a922eab Mon Sep 17 00:00:00 2001 From: Steve Klabnik Date: Thu, 5 Jan 2012 18:18:33 -0500 Subject: [PATCH 027/161] support questions now go in support --- app/controllers/questions_controller.rb | 2 +- app/views/questions/_form.html.haml | 2 ++ app/views/shared/_ask.html.haml | 7 +++++-- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/app/controllers/questions_controller.rb b/app/controllers/questions_controller.rb index d80ef834..34483830 100644 --- a/app/controllers/questions_controller.rb +++ b/app/controllers/questions_controller.rb @@ -51,7 +51,7 @@ def edit_resource_path end def set_support - @support = request.env['PATH_INFO'].include?('support') + @support = request.env['PATH_INFO'].include?('support') || params[:support] if @support && params[:question] params[:question][:support] = true end diff --git a/app/views/questions/_form.html.haml b/app/views/questions/_form.html.haml index 20f8843e..de4eec3f 100644 --- a/app/views/questions/_form.html.haml +++ b/app/views/questions/_form.html.haml @@ -3,6 +3,8 @@ .inputs = f.input :title, :hint => "What's your question?" + - if @support + = f.hidden_field :support, :value => true = f.input :description, :as => :text, :hint => "Provide some details about your problem to help diagnose it You can format your input with Markdown".html_safe diff --git a/app/views/shared/_ask.html.haml b/app/views/shared/_ask.html.haml index 0fd3ec35..7f7efda5 100644 --- a/app/views/shared/_ask.html.haml +++ b/app/views/shared/_ask.html.haml @@ -2,7 +2,10 @@ %h2 Have A Question? %p Ask away! No question is too big or too small. - if current_user - = link_to "Ask a Question", new_question_path, :class => "btn success" + - if @support + = link_to "Ask a Question", new_question_path(:support => true), :class => "btn success" + - else + = link_to "Ask a Question", new_question_path, :class => "btn success" - else %p Log in to ask a question - = link_to "Log In", login_path, :class => "btn success" \ No newline at end of file + = link_to "Log In", login_path, :class => "btn success" From f782d0e857677889a8a0f3d87f729f70a2c7ad7c Mon Sep 17 00:00:00 2001 From: Steve Klabnik Date: Sun, 8 Jan 2012 14:42:01 -0500 Subject: [PATCH 028/161] adding mailer. --- app/mailers/notification.rb | 10 +++++++++ app/views/notification/new_answer.html.haml | 3 +++ spec/mailers/notification_spec.rb | 24 +++++++++++++++++++++ spec/spec_helper.rb | 3 +++ spec/support/mailer_macros.rb | 10 +++++++++ 5 files changed, 50 insertions(+) create mode 100644 app/mailers/notification.rb create mode 100644 app/views/notification/new_answer.html.haml create mode 100644 spec/mailers/notification_spec.rb create mode 100644 spec/support/mailer_macros.rb diff --git a/app/mailers/notification.rb b/app/mailers/notification.rb new file mode 100644 index 00000000..bacee1e6 --- /dev/null +++ b/app/mailers/notification.rb @@ -0,0 +1,10 @@ +class Notification < ActionMailer::Base + default from: "steve@hackety.com" + default_url_options[:host] = "example.com" + + def new_answer(question) + @question = question + @url = question_url(question, :host => "hackety.com") + mail(:to => question.user.email, :subject => "New Answer on Hackety.com!") + end +end diff --git a/app/views/notification/new_answer.html.haml b/app/views/notification/new_answer.html.haml new file mode 100644 index 00000000..0c38fe81 --- /dev/null +++ b/app/views/notification/new_answer.html.haml @@ -0,0 +1,3 @@ +Hey there! You asked a question on Hackety.com: "" + +Someone has replied with an answer! Check it out here: #{@url} diff --git a/spec/mailers/notification_spec.rb b/spec/mailers/notification_spec.rb new file mode 100644 index 00000000..6fba9fb0 --- /dev/null +++ b/spec/mailers/notification_spec.rb @@ -0,0 +1,24 @@ +require "spec_helper" + +describe Notification do + describe "new_answer" do + let(:question) { Fabricate(:question) } + let(:mail) { Notification.new_answer(question) } + + it "has a link to the question" do + mail.body.encoded.should match(question_url(question, :host => "hackety.com")) + end + + it "is from Steve" do + mail.from.should eq(["steve@hackety.com"]) + end + + it "is to the question's author" do + mail.to.should eq([question.user.email]) + end + + it "has the proper subject" do + mail.subject.should eq("New Answer on Hackety.com!") + end + end +end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 5b980bc2..75b19268 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -23,4 +23,7 @@ config.before(:each) do DatabaseCleaner[:mongo_mapper].clean end + + config.include(MailerMacros) + config.before(:each) { reset_email } end diff --git a/spec/support/mailer_macros.rb b/spec/support/mailer_macros.rb new file mode 100644 index 00000000..f082fda9 --- /dev/null +++ b/spec/support/mailer_macros.rb @@ -0,0 +1,10 @@ +module MailerMacros + def last_email + ActionMailer::Base.deliveries.last + end + + def reset_email + ActionMailer::Base.deliveries = [] + end +end + From f330677b8dd3a1d822216a41ffcfd3054893868a Mon Sep 17 00:00:00 2001 From: Steve Klabnik Date: Sun, 8 Jan 2012 14:49:29 -0500 Subject: [PATCH 029/161] Updating all dependencies --- Gemfile.lock | 115 +++++++++++++++++++++++++-------------------------- 1 file changed, 57 insertions(+), 58 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 94dbbe34..26771617 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -46,18 +46,19 @@ GEM multi_json (~> 1.0) arel (2.2.1) bcrypt-ruby (3.0.1) - bson (1.3.1) - bson_ext (1.3.1) + bson (1.5.2) + bson_ext (1.5.2) + bson (= 1.5.2) builder (3.0.0) cancan (1.6.7) - capybara (1.1.1) + capybara (1.1.2) mime-types (>= 1.16) nokogiri (>= 1.3.3) rack (>= 1.0.0) rack-test (>= 0.5.4) selenium-webdriver (~> 2.0) xpath (~> 0.1.4) - childprocess (0.2.2) + childprocess (0.2.6) ffi (~> 1.0.6) coderay (0.9.8) coffee-rails (3.1.1) @@ -66,33 +67,33 @@ GEM coffee-script (2.2.0) coffee-script-source execjs - coffee-script-source (1.1.2) - cucumber (1.1.1) + coffee-script-source (1.2.0) + cucumber (1.1.4) builder (>= 2.1.2) diff-lcs (>= 1.1.2) - gherkin (~> 2.6.0) + gherkin (~> 2.7.1) json (>= 1.4.6) term-ansicolor (>= 1.0.6) - cucumber-rails (1.1.1) - capybara (>= 1.1.1) - cucumber (>= 1.1.0) + cucumber-rails (1.2.1) + capybara (>= 1.1.2) + cucumber (>= 1.1.3) nokogiri (>= 1.5.0) - database_cleaner (0.6.7) - devise (1.4.9) + database_cleaner (0.7.0) + devise (1.5.3) bcrypt-ruby (~> 3.0) orm_adapter (~> 0.0.3) - warden (~> 1.0.3) + warden (~> 1.1) diff-lcs (1.1.3) erubis (2.7.0) - execjs (1.2.9) + execjs (1.2.13) multi_json (~> 1.0) fabrication (1.2.0) faker (1.0.1) i18n (~> 0.4) - ffi (1.0.9) - gherkin (2.6.1) + ffi (1.0.11) + gherkin (2.7.2) json (>= 1.4.6) - haml (3.1.3) + haml (3.1.4) haml-rails (0.3.4) actionpack (~> 3.0) activesupport (~> 3.0) @@ -106,12 +107,11 @@ GEM responders (~> 0.6.0) jnunemaker-validatable (1.8.4) activesupport (>= 2.3.4) - jquery-rails (1.0.16) + jquery-rails (1.0.19) railties (~> 3.0) thor (~> 0.14) - json (1.6.1) - json_pure (1.6.1) - kgio (2.6.0) + json (1.6.4) + kgio (2.7.2) mail (2.3.0) i18n (>= 0.4.0) mime-types (~> 1.16) @@ -125,25 +125,25 @@ GEM mongo_mapper (>= 0.9.0) mocha (0.10.0) metaclass (~> 0.0.1) - mongo (1.3.1) - bson (>= 1.3.1) - mongo_mapper (0.9.2) + mongo (1.5.2) + bson (= 1.5.2) + mongo_mapper (0.10.1) activemodel (~> 3.0) activesupport (~> 3.0) - plucky (~> 0.3.8) - multi_json (1.0.3) + plucky (~> 0.4.0) + multi_json (1.0.4) nokogiri (1.5.0) orm_adapter (0.0.5) - pg (0.11.0) - plucky (0.3.8) + pg (0.12.2) + plucky (0.4.3) mongo (~> 1.3) - polyglot (0.3.2) - pry (0.9.7.3) + polyglot (0.3.3) + pry (0.9.7.4) coderay (~> 0.9.8) method_source (~> 0.6.7) ruby_parser (>= 2.3.1) slop (~> 2.1.0) - rack (1.3.5) + rack (1.3.6) rack-cache (1.0.3) rack (>= 0.4) rack-mount (0.8.3) @@ -170,59 +170,58 @@ GEM raindrops (0.8.0) rake (0.9.2.2) rdiscount (1.6.8) - rdoc (3.11) + rdoc (3.12) json (~> 1.4) responders (0.6.4) - rspec (2.7.0) - rspec-core (~> 2.7.0) - rspec-expectations (~> 2.7.0) - rspec-mocks (~> 2.7.0) - rspec-core (2.7.1) - rspec-expectations (2.7.0) + rspec (2.8.0) + rspec-core (~> 2.8.0) + rspec-expectations (~> 2.8.0) + rspec-mocks (~> 2.8.0) + rspec-core (2.8.0) + rspec-expectations (2.8.0) diff-lcs (~> 1.1.2) - rspec-mocks (2.7.0) - rspec-rails (2.7.0) - actionpack (~> 3.0) - activesupport (~> 3.0) - railties (~> 3.0) - rspec (~> 2.7.0) + rspec-mocks (2.8.0) + rspec-rails (2.8.1) + actionpack (>= 3.0) + activesupport (>= 3.0) + railties (>= 3.0) + rspec (~> 2.8.0) ruby_parser (2.3.1) sexp_processor (~> 3.0) - rubyzip (0.9.4) - sass (3.1.10) - sass-rails (3.1.4) + rubyzip (0.9.5) + sass (3.1.12) + sass-rails (3.1.5) actionpack (~> 3.1.0) railties (~> 3.1.0) - sass (>= 3.1.4) - sprockets (~> 2.0.0) + sass (~> 3.1.10) tilt (~> 1.3.2) - selenium-webdriver (2.10.0) - childprocess (>= 0.2.1) - ffi (= 1.0.9) - json_pure + selenium-webdriver (2.16.0) + childprocess (>= 0.2.5) + ffi (~> 1.0.9) + multi_json (~> 1.0.4) rubyzip - sexp_processor (3.0.7) + sexp_processor (3.0.10) slop (2.1.0) sprockets (2.0.3) hike (~> 1.2) rack (~> 1.0) tilt (~> 1.1, != 1.3.0) - sqlite3 (1.3.4) + sqlite3 (1.3.5) term-ansicolor (1.0.7) thor (0.14.6) tilt (1.3.3) treetop (1.4.10) polyglot polyglot (>= 0.3.1) - tzinfo (0.3.30) - uglifier (1.0.4) + tzinfo (0.3.31) + uglifier (1.2.1) execjs (>= 0.3.0) multi_json (>= 1.0.2) unicorn (4.1.1) kgio (~> 2.4) rack raindrops (~> 0.6) - warden (1.0.6) + warden (1.1.0) rack (>= 1.0) will_paginate (3.0.2) xpath (0.1.4) From f18d01cb3ed0b45db08254939dccb9b6d2079996 Mon Sep 17 00:00:00 2001 From: Steve Klabnik Date: Sun, 8 Jan 2012 15:16:07 -0500 Subject: [PATCH 030/161] Answers generate email notifications --- app/controllers/answers_controller.rb | 3 +++ config/environments/production.rb | 2 +- features/answers.feature | 1 + features/step_definitions/answer_steps.rb | 5 +++++ features/support/mailer.rb | 3 +++ 5 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 features/support/mailer.rb diff --git a/app/controllers/answers_controller.rb b/app/controllers/answers_controller.rb index b03d47ad..48ed6f11 100644 --- a/app/controllers/answers_controller.rb +++ b/app/controllers/answers_controller.rb @@ -7,6 +7,9 @@ def create @answer = Answer.create params[:answer] @answer.question = @question @answer.user = current_user + + Notification.new_answer(@question).deliver + create!(:notice => "Answer Posted!"){ question_url(params[:question_id]) } end diff --git a/config/environments/production.rb b/config/environments/production.rb index 20a5678f..9562087c 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -57,7 +57,7 @@ :authentication => :plain, :user_name => ENV['SENDGRID_USERNAME'], :password => ENV['SENDGRID_PASSWORD'], - :domain => 'hackety-hack.com' + :domain => 'hackety.com' } ActionMailer::Base.delivery_method = :smtp diff --git a/features/answers.feature b/features/answers.feature index 70aca6cb..1cf5d852 100644 --- a/features/answers.feature +++ b/features/answers.feature @@ -6,6 +6,7 @@ Feature: CRUD actions for answers Given a question exists And I answer that question Then I should be notified that my answer was submitted + And an email should be sent to the author And I should be able to see my answer And my answer should show on my profile page diff --git a/features/step_definitions/answer_steps.rb b/features/step_definitions/answer_steps.rb index e90f03f5..7743488b 100644 --- a/features/step_definitions/answer_steps.rb +++ b/features/step_definitions/answer_steps.rb @@ -23,3 +23,8 @@ page.should have_content(@question.title) page.should have_content("Have you tried turning it off and on again?") end + +Then /^an email should be sent to the author$/ do + ActionMailer::Base.deliveries.should_not be_empty +end + diff --git a/features/support/mailer.rb b/features/support/mailer.rb new file mode 100644 index 00000000..8cdfb2f1 --- /dev/null +++ b/features/support/mailer.rb @@ -0,0 +1,3 @@ +Before do + ActionMailer::Base.deliveries.clear +end From 94c20a03e144a34fbf26df40b277582539724150 Mon Sep 17 00:00:00 2001 From: Dominic Dagradi Date: Sun, 8 Jan 2012 16:00:12 -0500 Subject: [PATCH 031/161] Added account creation and program page tests --- Gemfile | 1 + Gemfile.lock | 4 ++ app/views/users/_form.html.haml | 0 app/views/users/show.html.haml | 2 +- features/programs.feature | 16 ++++++++ features/signup.feature | 7 ++++ features/step_definitions/program_steps.rb | 47 ++++++++++++++++++++++ features/step_definitions/signup_steps.rb | 17 ++++++++ features/step_definitions/user_steps.rb | 2 +- features/users.feature | 6 +-- 10 files changed, 97 insertions(+), 5 deletions(-) delete mode 100644 app/views/users/_form.html.haml create mode 100644 features/programs.feature create mode 100644 features/signup.feature create mode 100644 features/step_definitions/program_steps.rb create mode 100644 features/step_definitions/signup_steps.rb diff --git a/Gemfile b/Gemfile index 7cdb7648..2d7ece86 100644 --- a/Gemfile +++ b/Gemfile @@ -51,4 +51,5 @@ end group :test do gem "mocha" gem "database_cleaner" + gem "launchy" end diff --git a/Gemfile.lock b/Gemfile.lock index 26771617..e6c7b046 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -44,6 +44,7 @@ GEM activesupport (= 3.1.0) activesupport (3.1.0) multi_json (~> 1.0) + addressable (2.2.6) arel (2.2.1) bcrypt-ruby (3.0.1) bson (1.5.2) @@ -112,6 +113,8 @@ GEM thor (~> 0.14) json (1.6.4) kgio (2.7.2) + launchy (2.0.5) + addressable (~> 2.2.6) mail (2.3.0) i18n (>= 0.4.0) mime-types (~> 1.16) @@ -244,6 +247,7 @@ DEPENDENCIES jnunemaker-validatable (>= 1.8.4) jquery-rails json + launchy mm-devise (>= 1.2) mocha mongo_mapper diff --git a/app/views/users/_form.html.haml b/app/views/users/_form.html.haml deleted file mode 100644 index e69de29b..00000000 diff --git a/app/views/users/show.html.haml b/app/views/users/show.html.haml index 0e71a2be..c71dd2bc 100644 --- a/app/views/users/show.html.haml +++ b/app/views/users/show.html.haml @@ -18,7 +18,7 @@ %h4= resource.about %hr %p - = link_to pluralize(resource.programs.count, "Program"), user_programs_path(resource) + = link_to pluralize(resource.programs.count, "Program"), user_programs_path(resource), :class => "user-programs" %p Following: =link_to resource.following.count, resource_path(resource) + "/following" diff --git a/features/programs.feature b/features/programs.feature new file mode 100644 index 00000000..bbbe906b --- /dev/null +++ b/features/programs.feature @@ -0,0 +1,16 @@ +Feature: Access Programs + + As a user of the site, I want to access users' programs + + Scenario: View a featured program + Given there is a featured program + Then I should be able to view a highlighted program + + Scenario: View my programs + Given a logged in user + And I have uploaded a program + Then I should be able to view my programs + + Scenario: View another user's programs + Given a user has uploaded a program + Then I should be able to view their programs \ No newline at end of file diff --git a/features/signup.feature b/features/signup.feature new file mode 100644 index 00000000..2cb76b84 --- /dev/null +++ b/features/signup.feature @@ -0,0 +1,7 @@ +Feature: Sign up for an account + + As a new Hackety user, I want to create a new account and log in with it + + Scenario: Create an account via the signup form + When I register a new account + Then I should be logged in with my new account \ No newline at end of file diff --git a/features/step_definitions/program_steps.rb b/features/step_definitions/program_steps.rb new file mode 100644 index 00000000..63105587 --- /dev/null +++ b/features/step_definitions/program_steps.rb @@ -0,0 +1,47 @@ +Given /^there is a featured program$/ do + @program = Program.create!(:author_username => "username", + :slug => "slug", + :title => "My Featured Program", + :featured => true) +end + +Then /^I should be able to view a highlighted program$/ do + visit programs_path + within "#featured" do + page.should have_content("My Featured Program") + end +end + +def upload_program(user) + @program = Program.create!(:author_username => user.username, + :slug => "slug", + :title => "#{user.username}'s program") +end + +Given /^I have uploaded a program$/ do + upload_program(@user) +end + +Given /^a user has uploaded a program$/ do + @user = User.create!(:username => "some_user", + :password => "password", + :password_confirmation => "password", + :email => "some_user@example.com") + upload_program(@user) +end + +def visit_user_programs_page + visit user_path(@user) + within ".about-user" do + find(".user-programs").click() + end + page.should have_content(@program.title.titleize) +end + +Then /^I should be able to view my programs$/ do + visit_user_programs_page +end + +Then /^I should be able to view their programs$/ do + visit_user_programs_page +end \ No newline at end of file diff --git a/features/step_definitions/signup_steps.rb b/features/step_definitions/signup_steps.rb new file mode 100644 index 00000000..65c64ce4 --- /dev/null +++ b/features/step_definitions/signup_steps.rb @@ -0,0 +1,17 @@ +When /^I register a new account$/ do + @user_info = {:username => "username", :password => "password", :email => "test@example.com"} + + visit new_user_registration_path + + fill_in("Username", :with => @user_info[:username]) + fill_in("Email", :with => @user_info[:email]) + fill_in("Password", :with => @user_info[:password]) + fill_in("Password confirmation", :with => @user_info[:password]) + + click_button "Sign up" +end + +When /^I should be logged in with my new account$/ do + page.should have_content("You have signed up successfully") + page.should have_content(@user_info[:username]) +end \ No newline at end of file diff --git a/features/step_definitions/user_steps.rb b/features/step_definitions/user_steps.rb index dd5c3554..2484ffbb 100644 --- a/features/step_definitions/user_steps.rb +++ b/features/step_definitions/user_steps.rb @@ -3,7 +3,7 @@ def login_user email: "test_user@example.com", password: "foobar", password_confirmation: "foobar") - visit('/login') + visit login_path fill_in("Username", :with => @user.username) fill_in("Password", :with => @user.password) click_button("Sign in") diff --git a/features/users.feature b/features/users.feature index 6cb18e17..5a4f82ff 100644 --- a/features/users.feature +++ b/features/users.feature @@ -1,5 +1,5 @@ Feature: Manage account - + As a user of this site, I can view and update my profile Background: The user is logged in @@ -8,8 +8,8 @@ Feature: Manage account Scenario: View my profile When I go to look at my profile page Then it should have the right information - + Scenario: Edit my profile When I edit my profile Then I should be notified that my profile was updated - And I should see my changes reflected on my profile page + And I should see my changes reflected on my profile page \ No newline at end of file From 863c9376389a28a1dbe4aa8303262e55f1fed0d5 Mon Sep 17 00:00:00 2001 From: Dominic Dagradi Date: Thu, 29 Dec 2011 16:28:25 -0500 Subject: [PATCH 032/161] Refactored user profiles * Unified user's question and answer lists * Updated user info sidebar styles * User edit page uses correct form elements and appropriate sidebar --- app/assets/stylesheets/application.css.scss | 1 + app/assets/stylesheets/content.css.scss | 21 +++++++++ app/assets/stylesheets/layout.css.scss | 8 ++-- app/assets/stylesheets/programs.css.scss | 20 --------- app/assets/stylesheets/users.css.scss | 23 ++++++++++ app/models/answer.rb | 1 + app/views/devise/registrations/edit.html.erb | 26 ----------- app/views/devise/registrations/edit.html.haml | 21 +++++++++ app/views/users/_form.html.erb | 15 ------- app/views/users/show.html.haml | 43 ++++++++++--------- features/step_definitions/user_steps.rb | 2 +- 11 files changed, 96 insertions(+), 85 deletions(-) create mode 100644 app/assets/stylesheets/users.css.scss delete mode 100644 app/views/devise/registrations/edit.html.erb create mode 100644 app/views/devise/registrations/edit.html.haml delete mode 100644 app/views/users/_form.html.erb diff --git a/app/assets/stylesheets/application.css.scss b/app/assets/stylesheets/application.css.scss index e4bedc72..e5ba7b96 100644 --- a/app/assets/stylesheets/application.css.scss +++ b/app/assets/stylesheets/application.css.scss @@ -15,4 +15,5 @@ @import "home.css.scss"; @import "questions.css.scss"; @import "programs.css.scss"; +@import "users.css.scss"; diff --git a/app/assets/stylesheets/content.css.scss b/app/assets/stylesheets/content.css.scss index 67fc2286..89192c0a 100644 --- a/app/assets/stylesheets/content.css.scss +++ b/app/assets/stylesheets/content.css.scss @@ -11,6 +11,27 @@ h2 { margin-bottom: 0.5em; } +.heading { + @include clearfix; + padding: 0.75em; + background: $green; + + h3, .description { + color: white; + } + + h3 { + float: left; + margin-bottom: 0; + margin-right: 1em; + } + .description { + float: left; + margin-top: 0.2em; + } +} + + .block-message { margin-bottom: 0.5em; p { diff --git a/app/assets/stylesheets/layout.css.scss b/app/assets/stylesheets/layout.css.scss index ab2ea601..54f76169 100644 --- a/app/assets/stylesheets/layout.css.scss +++ b/app/assets/stylesheets/layout.css.scss @@ -3,9 +3,14 @@ html { } body { + color: $text-color; background: $background url("square_bg.png") fixed; } +p,h1,h2,h3,h4,h5 { + color: $text-color; +} + .topbar { position: relative; height: auto; @@ -86,9 +91,6 @@ header .topbar-inner { } -p,h1,h2,h3,h4,h5 { - color: $text-color; -} .alert-message { margin-top: -18px; diff --git a/app/assets/stylesheets/programs.css.scss b/app/assets/stylesheets/programs.css.scss index bc537018..84b3a897 100644 --- a/app/assets/stylesheets/programs.css.scss +++ b/app/assets/stylesheets/programs.css.scss @@ -1,26 +1,6 @@ .programs { margin-bottom: 2em; - .heading { - @include clearfix; - padding: 0.75em; - background: $green; - - h3, .description { - color: white; - } - - h3 { - float: left; - margin-bottom: 0; - margin-right: 1em; - } - .description { - float: left; - margin-top: 0.2em; - } - } - ul { @include clearfix; diff --git a/app/assets/stylesheets/users.css.scss b/app/assets/stylesheets/users.css.scss new file mode 100644 index 00000000..45be3005 --- /dev/null +++ b/app/assets/stylesheets/users.css.scss @@ -0,0 +1,23 @@ +.user-questions, .user-answers { + ul { + margin: 0; + list-style-type: none; + padding: 1em 0; + + li { + @include clearfix; + padding-bottom: 0.5em; + border-bottom: 1px solid #ddd; + margin-bottom: 0.5em; + + .title, .description { + @include columns(8); + } + + .meta { + @include columns(3, true); + text-align: right; + } + } + } +} \ No newline at end of file diff --git a/app/models/answer.rb b/app/models/answer.rb index e5d27c3b..bfed4f8a 100644 --- a/app/models/answer.rb +++ b/app/models/answer.rb @@ -2,6 +2,7 @@ class Answer include MongoMapper::Document key :description, String + timestamps! validates_presence_of :description diff --git a/app/views/devise/registrations/edit.html.erb b/app/views/devise/registrations/edit.html.erb deleted file mode 100644 index 310baf93..00000000 --- a/app/views/devise/registrations/edit.html.erb +++ /dev/null @@ -1,26 +0,0 @@ -<% content_for :title do %> -Edit <%= resource_name.to_s.humanize %> -<% end %> - -<%= simple_form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :method => :put }) do |f| %> - <%= f.error_notification %> - -
- <%= f.input :username, :autofocus => true %> - <%= f.input :email, :autofocus => true %> - <%= f.input :password, :hint => "leave it blank if you don't want to change it", :required => false %> - <%= f.input :password_confirmation, :required => false %> - <%= f.input :current_password, :hint => "we need your current password to confirm your changes", :required => true %> - <%= f.input :about %> -
- -
- <%= f.button :submit, "Update" %> -
-<% end %> - -

Cancel my account

- -

Unhappy? <%= link_to "Cancel my account", registration_path(resource_name), :confirm => "Are you sure?", :method => :delete %>.

- -<%= link_to "Back", :back %> diff --git a/app/views/devise/registrations/edit.html.haml b/app/views/devise/registrations/edit.html.haml new file mode 100644 index 00000000..d1f375d4 --- /dev/null +++ b/app/views/devise/registrations/edit.html.haml @@ -0,0 +1,21 @@ +- content_for :title do + Edit #{resource_name.to_s.humanize} + += simple_form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :method => :put }) do |f| + = f.error_notification + .inputs + = f.input :username, :autofocus => true + = f.input :email, :autofocus => true + .inputs + = f.input :password, :hint => "Leave it blank if you don't want to change it", :required => false + = f.input :password_confirmation, :required => false + .inputs + = f.input :about, :as => :text + .actions + = f.button :submit, "Update", :class => "btn primary" + +- content_for :sidebar do + %section + %h2 Cancel my account + %p + Unhappy? #{link_to "Cancel my account", registration_path(resource_name), :confirm => "Are you sure?", :method => :delete}. diff --git a/app/views/users/_form.html.erb b/app/views/users/_form.html.erb deleted file mode 100644 index eca09d5b..00000000 --- a/app/views/users/_form.html.erb +++ /dev/null @@ -1,15 +0,0 @@ -<%= simple_form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| %> - <%= f.error_notification %> - -
- <%= f.input :username, :autofocus => true %> - <%= f.input :email %> - <%= f.input :password %> - <%= f.input :password_confirmation %> - <%= f.input :about, :as => :text %> -
- -
- <%= f.button :submit, "Sign up", :class => "btn primary" %> -
-<% end %> diff --git a/app/views/users/show.html.haml b/app/views/users/show.html.haml index c71dd2bc..6ad5a01a 100644 --- a/app/views/users/show.html.haml +++ b/app/views/users/show.html.haml @@ -1,5 +1,5 @@ - content_for :title do - = "#{resource.username}'s page" + = "#{resource.username}'s Profile" -content_for :sidebar do %section.about-user @@ -14,9 +14,8 @@ = f.hidden_field :followee, :value => resource.id = f.button :submit, :value => "Follow", :class => "primary btn" - %h2= "About #{resource.username}" - %h4= resource.about - %hr + - unless resource.about.blank? + %p= resource.about %p = link_to pluralize(resource.programs.count, "Program"), user_programs_path(resource), :class => "user-programs" %p @@ -31,21 +30,25 @@ - unless @user.questions.empty? - %section.questions - %header - %h2 Questions - - @user.questions.each do |question| - %article.question - %h4= link_to question.title, question_path(question) + %section.user-questions + .heading + %h3= pluralize(@user.questions.count, "Question") + %ul + - @user.questions.each do |question| + %li + .title + = link_to question.title, question_path(question) + .meta + asked #{question.created_at.strftime("%b %e, %l:%M %p")} - unless @user.answers.empty? - %section.answers - %header - %h2 Answers - - @user.answers.each do |answer| - %article.answer - %h4 - = "#{@user.username} answered" - = link_to(answer.question.title, answer.question) - with: - %p= answer.description + %section.user-answers + .heading + %h3= pluralize(@user.answers.count, "Answer") + %ul + - @user.answers.each do |answer| + %li + .description + = answer.description.truncate(100) + .meta + = link_to("View Answer", answer.question) diff --git a/features/step_definitions/user_steps.rb b/features/step_definitions/user_steps.rb index 2484ffbb..671ca3ab 100644 --- a/features/step_definitions/user_steps.rb +++ b/features/step_definitions/user_steps.rb @@ -19,7 +19,7 @@ def login_user Then /^it should have the right information$/ do page.should have_selector('title', :content => "#{@user.username}'s page") - page.should have_content("About #{@user.username}") + page.should have_content("#{@user.username}'s Profile") end When /^I edit my profile$/ do From bb0b410f463fb832455efba0cb815e29dbe8231f Mon Sep 17 00:00:00 2001 From: Dominic Dagradi Date: Sun, 8 Jan 2012 22:14:29 -0500 Subject: [PATCH 033/161] correctly refactored profile --- app/views/devise/registrations/edit.html.haml | 13 +------------ app/views/devise/registrations/new.html.erb | 2 +- app/views/users/_form.html.haml | 16 ++++++++++++++++ 3 files changed, 18 insertions(+), 13 deletions(-) create mode 100644 app/views/users/_form.html.haml diff --git a/app/views/devise/registrations/edit.html.haml b/app/views/devise/registrations/edit.html.haml index d1f375d4..d945daa0 100644 --- a/app/views/devise/registrations/edit.html.haml +++ b/app/views/devise/registrations/edit.html.haml @@ -1,18 +1,7 @@ - content_for :title do Edit #{resource_name.to_s.humanize} -= simple_form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :method => :put }) do |f| - = f.error_notification - .inputs - = f.input :username, :autofocus => true - = f.input :email, :autofocus => true - .inputs - = f.input :password, :hint => "Leave it blank if you don't want to change it", :required => false - = f.input :password_confirmation, :required => false - .inputs - = f.input :about, :as => :text - .actions - = f.button :submit, "Update", :class => "btn primary" += render :partial => "users/form", :locals => {:submit_label => "Update"} - content_for :sidebar do %section diff --git a/app/views/devise/registrations/new.html.erb b/app/views/devise/registrations/new.html.erb index 65d498fa..0167dca8 100644 --- a/app/views/devise/registrations/new.html.erb +++ b/app/views/devise/registrations/new.html.erb @@ -2,6 +2,6 @@ Sign Up <% end %> -<%= render :partial => "users/form" %> +<%= render :partial => "users/form", :locals => {:submit_label => "Sign up"} %> <%= render :partial => "devise/shared/links" %> diff --git a/app/views/users/_form.html.haml b/app/views/users/_form.html.haml new file mode 100644 index 00000000..80976dd3 --- /dev/null +++ b/app/views/users/_form.html.haml @@ -0,0 +1,16 @@ +- submit_label ||= "Update" += simple_form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| + = f.error_notification + .inputs + = f.input :username, :autofocus => true + = f.input :email, :autofocus => true + .inputs + = f.input :password, :hint => "Leave it blank if you don't want to change it", :required => false + = f.input :password_confirmation, :required => false + .inputs + = f.input :about, :as => :text + - unless resource.new_record? + .inputs + = f.input :current_password, :required => true, :hint => "We need your password to update your account." + .actions + = f.button :submit, submit_label, :class => "btn primary" \ No newline at end of file From 68997eb36439409a2e3a611d158968b78a248fc9 Mon Sep 17 00:00:00 2001 From: Steve Klabnik Date: Tue, 10 Jan 2012 10:53:59 -0500 Subject: [PATCH 034/161] zomg whoops, left in example.com --- app/mailers/notification.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/mailers/notification.rb b/app/mailers/notification.rb index bacee1e6..24e91128 100644 --- a/app/mailers/notification.rb +++ b/app/mailers/notification.rb @@ -1,6 +1,6 @@ class Notification < ActionMailer::Base default from: "steve@hackety.com" - default_url_options[:host] = "example.com" + default_url_options[:host] = "hackety.com" def new_answer(question) @question = question From 8423d75f615f7513ca187643659380e65ff997f5 Mon Sep 17 00:00:00 2001 From: Matt Gauger Date: Sun, 15 Jan 2012 18:09:06 -0600 Subject: [PATCH 035/161] Basic implementation of a program description field --- app/models/program.rb | 1 + app/views/programs/index.html.haml | 1 + features/programs.feature | 8 +++++++- features/step_definitions/program_steps.rb | 13 ++++++++++++- spec/unit/program_spec.rb | 3 ++- 5 files changed, 23 insertions(+), 3 deletions(-) diff --git a/app/models/program.rb b/app/models/program.rb index f36399f6..3fb65f5e 100644 --- a/app/models/program.rb +++ b/app/models/program.rb @@ -4,6 +4,7 @@ class Program key :author_username, String key :slug, String key :title, String + key :description, String key :source_code, String key :featured, Boolean timestamps! diff --git a/app/views/programs/index.html.haml b/app/views/programs/index.html.haml index 46f0a890..da9aafb3 100644 --- a/app/views/programs/index.html.haml +++ b/app/views/programs/index.html.haml @@ -27,6 +27,7 @@ %li .title= program_link program .author= author_link program.author_username, program + .description= program.description - if @user %ul.inline-menu.bottom-nav diff --git a/features/programs.feature b/features/programs.feature index bbbe906b..48e673d4 100644 --- a/features/programs.feature +++ b/features/programs.feature @@ -13,4 +13,10 @@ Feature: Access Programs Scenario: View another user's programs Given a user has uploaded a program - Then I should be able to view their programs \ No newline at end of file + Then I should be able to view their programs + + Scenario: View a program with a description + Given a user has uploaded a program + And they have given their program a description + Then I should be able to view their programs + And I should see the description on their program diff --git a/features/step_definitions/program_steps.rb b/features/step_definitions/program_steps.rb index 63105587..e5c898e6 100644 --- a/features/step_definitions/program_steps.rb +++ b/features/step_definitions/program_steps.rb @@ -30,6 +30,13 @@ def upload_program(user) upload_program(@user) end +Given /^they have given their program a description$/ do + @program = Program.last + @program.description = "A really cool program!" + @program.save +end + + def visit_user_programs_page visit user_path(@user) within ".about-user" do @@ -44,4 +51,8 @@ def visit_user_programs_page Then /^I should be able to view their programs$/ do visit_user_programs_page -end \ No newline at end of file +end + +Then /^I should see the description on their program$/ do + page.should have_content("A really cool program!") +end diff --git a/spec/unit/program_spec.rb b/spec/unit/program_spec.rb index 172d9bd7..c93ba99e 100644 --- a/spec/unit/program_spec.rb +++ b/spec/unit/program_spec.rb @@ -1,7 +1,8 @@ require 'spec_helper' describe Program do - let(:prog) { Program.create(author_username: 'tester', title: 'test title')} + let(:prog) { Program.create(author_username: 'tester', title: 'test title')} + it "sets the slug" do prog.slug.should == 'test-title' end From c7857eaadff48f381020a90a6fae419d47b8060b Mon Sep 17 00:00:00 2001 From: Matt Gauger Date: Sun, 15 Jan 2012 18:48:08 -0600 Subject: [PATCH 036/161] Description should be in program show - Add scenarios around detecting program source and description. --- app/views/programs/index.html.haml | 5 ++--- app/views/programs/show.html.haml | 3 +++ features/programs.feature | 11 +++++++++-- features/step_definitions/program_steps.rb | 17 +++++++++++++++-- 4 files changed, 29 insertions(+), 7 deletions(-) diff --git a/app/views/programs/index.html.haml b/app/views/programs/index.html.haml index da9aafb3..702cc584 100644 --- a/app/views/programs/index.html.haml +++ b/app/views/programs/index.html.haml @@ -10,7 +10,7 @@ %h3 Featured .description Our favorite selection of projects. - %ul + %ul.featured_programs_list - @featured.each do |program| %li .title= program_link program @@ -22,12 +22,11 @@ %h3 All Programs .description Every program uploaded by our users! - %ul + %ul.programs_list - @programs.each do |program| %li .title= program_link program .author= author_link program.author_username, program - .description= program.description - if @user %ul.inline-menu.bottom-nav diff --git a/app/views/programs/show.html.haml b/app/views/programs/show.html.haml index 6a2441f8..b5ff2b1b 100644 --- a/app/views/programs/show.html.haml +++ b/app/views/programs/show.html.haml @@ -19,6 +19,9 @@ by = link_to @program.author_username, user_path(@program.author_username) +.description + %p= @program.description + #program %pre.prettyprint= @program.source_code diff --git a/features/programs.feature b/features/programs.feature index 48e673d4..5680b723 100644 --- a/features/programs.feature +++ b/features/programs.feature @@ -15,8 +15,15 @@ Feature: Access Programs Given a user has uploaded a program Then I should be able to view their programs + Scenario: View an individual program + Given a user has uploaded a program + And I should be able to view their programs + When I click the first program link + Then I should see the program source + Scenario: View a program with a description Given a user has uploaded a program And they have given their program a description - Then I should be able to view their programs - And I should see the description on their program + And I should be able to view their programs + When I click the first program link + Then I should see the description of their program diff --git a/features/step_definitions/program_steps.rb b/features/step_definitions/program_steps.rb index e5c898e6..f391a8de 100644 --- a/features/step_definitions/program_steps.rb +++ b/features/step_definitions/program_steps.rb @@ -15,7 +15,8 @@ def upload_program(user) @program = Program.create!(:author_username => user.username, :slug => "slug", - :title => "#{user.username}'s program") + :title => "#{user.username}'s program", + :source_code => "puts 'Hello world'") end Given /^I have uploaded a program$/ do @@ -53,6 +54,18 @@ def visit_user_programs_page visit_user_programs_page end -Then /^I should see the description on their program$/ do +When /^I click the first program link$/ do + within ".programs_list" do + find("li:first-child a").click() + end +end + +Then /^I should see the program source$/ do + within("#program") do + page.should have_content("puts 'Hello world'") + end +end + +Then /^I should see the description of their program$/ do page.should have_content("A really cool program!") end From 83f71f00e0cfbbbe611b7b54d6f1f3d04e46f46e Mon Sep 17 00:00:00 2001 From: Dominic Dagradi Date: Wed, 18 Jan 2012 17:40:13 -0500 Subject: [PATCH 037/161] Added min-width to body - Resolve some mobile display issues - Removed unnecessary classes from program lists --- app/assets/stylesheets/layout.css.scss | 1 + app/views/programs/index.html.haml | 4 ++-- features/step_definitions/program_steps.rb | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/assets/stylesheets/layout.css.scss b/app/assets/stylesheets/layout.css.scss index 54f76169..3b60e802 100644 --- a/app/assets/stylesheets/layout.css.scss +++ b/app/assets/stylesheets/layout.css.scss @@ -3,6 +3,7 @@ html { } body { + min-width: 976px; color: $text-color; background: $background url("square_bg.png") fixed; } diff --git a/app/views/programs/index.html.haml b/app/views/programs/index.html.haml index 702cc584..46f0a890 100644 --- a/app/views/programs/index.html.haml +++ b/app/views/programs/index.html.haml @@ -10,7 +10,7 @@ %h3 Featured .description Our favorite selection of projects. - %ul.featured_programs_list + %ul - @featured.each do |program| %li .title= program_link program @@ -22,7 +22,7 @@ %h3 All Programs .description Every program uploaded by our users! - %ul.programs_list + %ul - @programs.each do |program| %li .title= program_link program diff --git a/features/step_definitions/program_steps.rb b/features/step_definitions/program_steps.rb index f391a8de..0fd28f2f 100644 --- a/features/step_definitions/program_steps.rb +++ b/features/step_definitions/program_steps.rb @@ -55,7 +55,7 @@ def visit_user_programs_page end When /^I click the first program link$/ do - within ".programs_list" do + within "#all-programs ul" do find("li:first-child a").click() end end From 6b6dcb737f98a91ee96f5e33d36188f2da78ca22 Mon Sep 17 00:00:00 2001 From: Steve Klabnik Date: Wed, 25 Jan 2012 15:38:29 -0500 Subject: [PATCH 038/161] Adding first iteration of Lessons. This still needs work, including removing controls, adding images... most of that is in the depedant gem. --- Gemfile | 2 ++ Gemfile.lock | 6 ++++++ app/assets/javascripts/lessons.js.coffee | 3 +++ app/assets/stylesheets/lessons.css.scss | 3 +++ app/controllers/lessons_controller.rb | 9 +++++++++ app/helpers/lessons_helper.rb | 2 ++ app/views/lessons/index.html.haml | 9 +++++++++ app/views/lessons/show.html.haml | 4 ++++ config/routes.rb | 2 ++ 9 files changed, 40 insertions(+) create mode 100644 app/assets/javascripts/lessons.js.coffee create mode 100644 app/assets/stylesheets/lessons.css.scss create mode 100644 app/controllers/lessons_controller.rb create mode 100644 app/helpers/lessons_helper.rb create mode 100644 app/views/lessons/index.html.haml create mode 100644 app/views/lessons/show.html.haml diff --git a/Gemfile b/Gemfile index 2d7ece86..2781496e 100644 --- a/Gemfile +++ b/Gemfile @@ -3,6 +3,8 @@ source 'http://rubygems.org' gem 'rails', '3.1.0' gem 'json' +gem 'hackety_hack-lessons', :require => 'hackety_hack/lessons' + gem 'haml-rails' gem 'jquery-rails' gem 'mongo_mapper' diff --git a/Gemfile.lock b/Gemfile.lock index e6c7b046..bb2c7606 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -94,6 +94,8 @@ GEM ffi (1.0.11) gherkin (2.7.2) json (>= 1.4.6) + hackety_hack-lessons (1.0.1) + metadown haml (3.1.4) haml-rails (0.3.4) actionpack (~> 3.0) @@ -120,6 +122,8 @@ GEM mime-types (~> 1.16) treetop (~> 1.4.8) metaclass (0.0.1) + metadown (1.0.1) + redcarpet method_source (0.6.7) ruby_parser (>= 2.3.1) mime-types (1.17.2) @@ -175,6 +179,7 @@ GEM rdiscount (1.6.8) rdoc (3.12) json (~> 1.4) + redcarpet (2.1.0) responders (0.6.4) rspec (2.8.0) rspec-core (~> 2.8.0) @@ -242,6 +247,7 @@ DEPENDENCIES devise (>= 1.2) fabrication faker + hackety_hack-lessons haml-rails inherited_resources jnunemaker-validatable (>= 1.8.4) diff --git a/app/assets/javascripts/lessons.js.coffee b/app/assets/javascripts/lessons.js.coffee new file mode 100644 index 00000000..76156794 --- /dev/null +++ b/app/assets/javascripts/lessons.js.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/ diff --git a/app/assets/stylesheets/lessons.css.scss b/app/assets/stylesheets/lessons.css.scss new file mode 100644 index 00000000..e2cf8c05 --- /dev/null +++ b/app/assets/stylesheets/lessons.css.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the lessons controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/controllers/lessons_controller.rb b/app/controllers/lessons_controller.rb new file mode 100644 index 00000000..9e65571b --- /dev/null +++ b/app/controllers/lessons_controller.rb @@ -0,0 +1,9 @@ +class LessonsController < ApplicationController + def index + @lessons = HacketyHack::Lessons.titles + end + + def show + @lesson = HacketyHack::Lessons.find_by_title(params[:id]) + end +end diff --git a/app/helpers/lessons_helper.rb b/app/helpers/lessons_helper.rb new file mode 100644 index 00000000..1703883c --- /dev/null +++ b/app/helpers/lessons_helper.rb @@ -0,0 +1,2 @@ +module LessonsHelper +end diff --git a/app/views/lessons/index.html.haml b/app/views/lessons/index.html.haml new file mode 100644 index 00000000..f78a01c0 --- /dev/null +++ b/app/views/lessons/index.html.haml @@ -0,0 +1,9 @@ +%h1 Lessons + +%p Want to learn programming? Here are some lessons that we've put online. + +%ul + - @lessons.each do |title| + %li= link_to title, lesson_path(title) + + diff --git a/app/views/lessons/show.html.haml b/app/views/lessons/show.html.haml new file mode 100644 index 00000000..80530d33 --- /dev/null +++ b/app/views/lessons/show.html.haml @@ -0,0 +1,4 @@ +%h1= @lesson.metadata["title"] + +:markdown + #{@lesson.output} diff --git a/config/routes.rb b/config/routes.rb index e139c368..a0dc66e0 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,5 +1,7 @@ HacketyHackCom::Application.routes.draw do + resources :lessons, :only => [:index, :show] + resources :questions do resources :answers end From 4348fef7705c419fc3907ab3dc4959d1195be492 Mon Sep 17 00:00:00 2001 From: Steve Klabnik Date: Wed, 25 Jan 2012 15:01:34 -0500 Subject: [PATCH 039/161] added lessons link to navbar --- app/views/shared/menu/_main.html.haml | 1 + 1 file changed, 1 insertion(+) diff --git a/app/views/shared/menu/_main.html.haml b/app/views/shared/menu/_main.html.haml index 9d91c405..dfaa7bda 100644 --- a/app/views/shared/menu/_main.html.haml +++ b/app/views/shared/menu/_main.html.haml @@ -1,5 +1,6 @@ = semantic_menu :class => "nav" do |root| - root.add "Questions", questions_path + - root.add "Lessons", lessons_path - root.add "Programs", programs_path - root.add "FAQ", faq_path - root.add "Support", support_questions_path From 9f63fa8b02fc33d8e97726f43c40e44484e17ef2 Mon Sep 17 00:00:00 2001 From: Steve Klabnik Date: Wed, 25 Jan 2012 15:34:47 -0500 Subject: [PATCH 040/161] Updated lessons gem. Still need to worry about images. --- Gemfile.lock | 2 +- app/controllers/lessons_controller.rb | 4 ++-- app/views/lessons/index.html.haml | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index bb2c7606..7e264991 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -94,7 +94,7 @@ GEM ffi (1.0.11) gherkin (2.7.2) json (>= 1.4.6) - hackety_hack-lessons (1.0.1) + hackety_hack-lessons (1.0.3) metadown haml (3.1.4) haml-rails (0.3.4) diff --git a/app/controllers/lessons_controller.rb b/app/controllers/lessons_controller.rb index 9e65571b..a581c7bd 100644 --- a/app/controllers/lessons_controller.rb +++ b/app/controllers/lessons_controller.rb @@ -1,9 +1,9 @@ class LessonsController < ApplicationController def index - @lessons = HacketyHack::Lessons.titles + @lessons = HacketyHack::Lessons.all.collect{|lesson| [lesson.metadata["title"], lesson.metadata["slug"]]} end def show - @lesson = HacketyHack::Lessons.find_by_title(params[:id]) + @lesson = HacketyHack::Lessons.find_by_slug(params[:id]) end end diff --git a/app/views/lessons/index.html.haml b/app/views/lessons/index.html.haml index f78a01c0..1e832199 100644 --- a/app/views/lessons/index.html.haml +++ b/app/views/lessons/index.html.haml @@ -3,7 +3,7 @@ %p Want to learn programming? Here are some lessons that we've put online. %ul - - @lessons.each do |title| - %li= link_to title, lesson_path(title) + - @lessons.each do |title, slug| + %li= link_to title, lesson_path(slug) From 94954f97e5b295b031cd551d56e14fde0938426a Mon Sep 17 00:00:00 2001 From: Steve Klabnik Date: Wed, 25 Jan 2012 16:14:51 -0500 Subject: [PATCH 041/161] Updated lessons gem. After 1.1, it adds its images into assets. Rock. --- Gemfile | 2 +- Gemfile.lock | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Gemfile b/Gemfile index 2781496e..466ef4d0 100644 --- a/Gemfile +++ b/Gemfile @@ -3,7 +3,7 @@ source 'http://rubygems.org' gem 'rails', '3.1.0' gem 'json' -gem 'hackety_hack-lessons', :require => 'hackety_hack/lessons' +gem 'hackety_hack-lessons', '~> 1.1', :require => 'hackety_hack/lessons' gem 'haml-rails' gem 'jquery-rails' diff --git a/Gemfile.lock b/Gemfile.lock index 7e264991..a8d4a1df 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -94,7 +94,7 @@ GEM ffi (1.0.11) gherkin (2.7.2) json (>= 1.4.6) - hackety_hack-lessons (1.0.3) + hackety_hack-lessons (1.1.0) metadown haml (3.1.4) haml-rails (0.3.4) @@ -247,7 +247,7 @@ DEPENDENCIES devise (>= 1.2) fabrication faker - hackety_hack-lessons + hackety_hack-lessons (~> 1.1) haml-rails inherited_resources jnunemaker-validatable (>= 1.8.4) From 6cec36662db05b6bbbb1a0cd7310724a05e8e5a0 Mon Sep 17 00:00:00 2001 From: Dominic Dagradi Date: Wed, 25 Jan 2012 17:12:53 -0500 Subject: [PATCH 042/161] Styled lessons index and show * Added categories helper with pill styles * Added blurb to index output * Styled lessons#show markdown --- Gemfile.lock | 47 +++++------- app/assets/stylesheets/application.css.scss | 1 + app/assets/stylesheets/lessons.css.scss | 85 ++++++++++++++++++++- app/controllers/lessons_controller.rb | 2 +- app/helpers/lessons_helper.rb | 9 +++ app/views/lessons/index.html.haml | 19 ++++- app/views/lessons/show.html.haml | 16 +++- app/views/shared/_lessons.html.haml | 4 + 8 files changed, 146 insertions(+), 37 deletions(-) create mode 100644 app/views/shared/_lessons.html.haml diff --git a/Gemfile.lock b/Gemfile.lock index a8d4a1df..2f7717d0 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -59,9 +59,9 @@ GEM rack-test (>= 0.5.4) selenium-webdriver (~> 2.0) xpath (~> 0.1.4) - childprocess (0.2.6) + childprocess (0.3.0) ffi (~> 1.0.6) - coderay (0.9.8) + coderay (1.0.5) coffee-rails (3.1.1) coffee-script (>= 2.2.0) railties (~> 3.1.0) @@ -79,22 +79,22 @@ GEM capybara (>= 1.1.2) cucumber (>= 1.1.3) nokogiri (>= 1.5.0) - database_cleaner (0.7.0) + database_cleaner (0.7.1) devise (1.5.3) bcrypt-ruby (~> 3.0) orm_adapter (~> 0.0.3) warden (~> 1.1) diff-lcs (1.1.3) erubis (2.7.0) - execjs (1.2.13) + execjs (1.3.0) multi_json (~> 1.0) fabrication (1.2.0) faker (1.0.1) i18n (~> 0.4) ffi (1.0.11) - gherkin (2.7.2) + gherkin (2.7.6) json (>= 1.4.6) - hackety_hack-lessons (1.1.0) + hackety_hack-lessons (1.1.2) metadown haml (3.1.4) haml-rails (0.3.4) @@ -113,7 +113,7 @@ GEM jquery-rails (1.0.19) railties (~> 3.0) thor (~> 0.14) - json (1.6.4) + json (1.6.5) kgio (2.7.2) launchy (2.0.5) addressable (~> 2.2.6) @@ -124,13 +124,12 @@ GEM metaclass (0.0.1) metadown (1.0.1) redcarpet - method_source (0.6.7) - ruby_parser (>= 2.3.1) + method_source (0.7.0) mime-types (1.17.2) mm-devise (1.3) devise (>= 1.2) mongo_mapper (>= 0.9.0) - mocha (0.10.0) + mocha (0.10.3) metaclass (~> 0.0.1) mongo (1.5.2) bson (= 1.5.2) @@ -140,16 +139,15 @@ GEM plucky (~> 0.4.0) multi_json (1.0.4) nokogiri (1.5.0) - orm_adapter (0.0.5) + orm_adapter (0.0.6) pg (0.12.2) - plucky (0.4.3) - mongo (~> 1.3) + plucky (0.4.4) + mongo (~> 1.5) polyglot (0.3.3) - pry (0.9.7.4) - coderay (~> 0.9.8) - method_source (~> 0.6.7) - ruby_parser (>= 2.3.1) - slop (~> 2.1.0) + pry (0.9.8) + coderay (~> 1.0.5) + method_source (~> 0.7) + slop (>= 2.4.3, < 3) rack (1.3.6) rack-cache (1.0.3) rack (>= 0.4) @@ -180,7 +178,7 @@ GEM rdoc (3.12) json (~> 1.4) redcarpet (2.1.0) - responders (0.6.4) + responders (0.6.5) rspec (2.8.0) rspec-core (~> 2.8.0) rspec-expectations (~> 2.8.0) @@ -194,8 +192,6 @@ GEM activesupport (>= 3.0) railties (>= 3.0) rspec (~> 2.8.0) - ruby_parser (2.3.1) - sexp_processor (~> 3.0) rubyzip (0.9.5) sass (3.1.12) sass-rails (3.1.5) @@ -203,17 +199,16 @@ GEM railties (~> 3.1.0) sass (~> 3.1.10) tilt (~> 1.3.2) - selenium-webdriver (2.16.0) + selenium-webdriver (2.17.0) childprocess (>= 0.2.5) ffi (~> 1.0.9) multi_json (~> 1.0.4) rubyzip - sexp_processor (3.0.10) - slop (2.1.0) + slop (2.4.3) sprockets (2.0.3) hike (~> 1.2) rack (~> 1.0) - tilt (~> 1.1, != 1.3.0) + tilt (!= 1.3.0, ~> 1.1) sqlite3 (1.3.5) term-ansicolor (1.0.7) thor (0.14.6) @@ -222,7 +217,7 @@ GEM polyglot polyglot (>= 0.3.1) tzinfo (0.3.31) - uglifier (1.2.1) + uglifier (1.2.2) execjs (>= 0.3.0) multi_json (>= 1.0.2) unicorn (4.1.1) diff --git a/app/assets/stylesheets/application.css.scss b/app/assets/stylesheets/application.css.scss index e5ba7b96..e5b8adbe 100644 --- a/app/assets/stylesheets/application.css.scss +++ b/app/assets/stylesheets/application.css.scss @@ -16,4 +16,5 @@ @import "questions.css.scss"; @import "programs.css.scss"; @import "users.css.scss"; +@import "lessons.css.scss"; diff --git a/app/assets/stylesheets/lessons.css.scss b/app/assets/stylesheets/lessons.css.scss index e2cf8c05..20d8b18c 100644 --- a/app/assets/stylesheets/lessons.css.scss +++ b/app/assets/stylesheets/lessons.css.scss @@ -1,3 +1,82 @@ -// Place all the styles related to the lessons controller here. -// They will automatically be included in application.css. -// You can use Sass (SCSS) here: http://sass-lang.com/ +/* Lessons menu */ +ul#lessons { + list-style-type: none; + margin: 0; + > li { + @include clearfix; + padding-bottom: 1em; + border-bottom: 1px solid #ccc; + margin-bottom: 1em; + .info { + @include columns(7); + .title { + font-size: 1.1em; + font-weight: bold; + margin-bottom: 0.2em; + } + } + .categories { + @include columns(4, last); + li { + float: right; + } + } + } +} + +/* Lesson content styles */ +#content-wrap.lesson { + .page-title { + margin-left: 3em; + } + #lesson-content { + padding-left: 3em; + max-width: 500px; + + h2 { + margin-top: 0.75em; + border-top: 1px solid #ccc; + padding-top: 0.5em; + } + + img { + @include border-radius; + @include box-shadow; + border: 1px solid #ccc; + padding: 0.75em; + } + } +} + +/* Category pills */ +ul.lesson-categories { + @include clearfix; + list-style-type: none; + margin: 0; + font-size: 0.9em; + + li { + float: left; + @include border-radius(50px); + padding: 0.25em 0.75em; + margin-right: 0.5em; + background: #ddd; + border: 1px solid #ccc; + } + + .beginner { + background-color: $green; + border-color: darken($green, 10%); + color: white; + } + .hackety { + background-color: $blue; + border-color: darken($blue, 10%); + color: white; + } + .shoes { + background-color: $orangered; + border-color: darken($orangered, 10%); + color: white; + } +} \ No newline at end of file diff --git a/app/controllers/lessons_controller.rb b/app/controllers/lessons_controller.rb index a581c7bd..3f3ac02c 100644 --- a/app/controllers/lessons_controller.rb +++ b/app/controllers/lessons_controller.rb @@ -1,6 +1,6 @@ class LessonsController < ApplicationController def index - @lessons = HacketyHack::Lessons.all.collect{|lesson| [lesson.metadata["title"], lesson.metadata["slug"]]} + @lessons = HacketyHack::Lessons.all end def show diff --git a/app/helpers/lessons_helper.rb b/app/helpers/lessons_helper.rb index 1703883c..f024005f 100644 --- a/app/helpers/lessons_helper.rb +++ b/app/helpers/lessons_helper.rb @@ -1,2 +1,11 @@ module LessonsHelper + + def lesson_categories lesson + output = content_tag :ul, :class => "lesson-categories" do + lesson.metadata["categories"].reduce('') { |c, x| + c << content_tag(:li, x, :class => x) + }.html_safe + end + end + end diff --git a/app/views/lessons/index.html.haml b/app/views/lessons/index.html.haml index 1e832199..bb1efa39 100644 --- a/app/views/lessons/index.html.haml +++ b/app/views/lessons/index.html.haml @@ -1,9 +1,20 @@ -%h1 Lessons +- content_for :title do + Lessons + +- content_for :sidebar do + = render :partial => "shared/ask" + = render :partial => "shared/lessons" %p Want to learn programming? Here are some lessons that we've put online. -%ul - - @lessons.each do |title, slug| - %li= link_to title, lesson_path(slug) +%ul#lessons + - @lessons.each do |lesson| + %li + .info + .title + = link_to lesson.metadata["title"], lesson_path(lesson.metadata["slug"]) + = lesson.metadata["blurb"] + .categories + = lesson_categories lesson diff --git a/app/views/lessons/show.html.haml b/app/views/lessons/show.html.haml index 80530d33..0174335e 100644 --- a/app/views/lessons/show.html.haml +++ b/app/views/lessons/show.html.haml @@ -1,4 +1,14 @@ -%h1= @lesson.metadata["title"] +- @page_class = "lesson" -:markdown - #{@lesson.output} +- content_for :title do + = @lesson.metadata["title"] + +- content_for :sidebar do + = render :partial => "shared/ask" + = render :partial => "shared/lessons" + +#lesson-content + = lesson_categories @lesson + + :markdown + #{@lesson.output} diff --git a/app/views/shared/_lessons.html.haml b/app/views/shared/_lessons.html.haml new file mode 100644 index 00000000..93419a2d --- /dev/null +++ b/app/views/shared/_lessons.html.haml @@ -0,0 +1,4 @@ +%section.lessons + %h2 Want to help? + %p Help us create new lessons, or update existing ones. Check out the Lessons project on Github below: + = link_to "Hackety Hack Lessons on Github", "https://github.com/hacketyhack/hackety_hack-lessons" \ No newline at end of file From c7d261bda6ee21d5dfa4358d5309d779e38b3734 Mon Sep 17 00:00:00 2001 From: Corey Purcell Date: Sun, 29 Jan 2012 15:52:29 -0500 Subject: [PATCH 043/161] close issue #119, fix for programs without username --- app/helpers/programs_helper.rb | 7 ++++++- spec/views/programs_index.rb | 12 ++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 spec/views/programs_index.rb diff --git a/app/helpers/programs_helper.rb b/app/helpers/programs_helper.rb index f67b71e5..3ec6d832 100644 --- a/app/helpers/programs_helper.rb +++ b/app/helpers/programs_helper.rb @@ -1,9 +1,14 @@ module ProgramsHelper def program_link program - "#{link_to(program.title.titleize, user_program_path(program.author_username, program))}".html_safe + if program.author_username.present? + "#{link_to(program.title.titleize, user_program_path(program.author_username, program))}".html_safe + else + "#{link_to(program.title.titleize, url_for(:controller => '/programs', :action => 'show', :id => program.slug))}".html_safe + end end def author_link username, program = nil + return nil unless username output = "" output += link_to(username, user_path(username)) diff --git a/spec/views/programs_index.rb b/spec/views/programs_index.rb new file mode 100644 index 00000000..55029cd4 --- /dev/null +++ b/spec/views/programs_index.rb @@ -0,0 +1,12 @@ +require 'spec_helper' + +describe 'programs/index.html.haml' do + context 'programs without a username' do + it "renders the page without error" do + programs = [Fabricate(:program, author_username: nil)] + assign(:programs, programs) + render + rendered.should have_selector('div', id: 'title', contents: 'MyString') + end + end +end From 17977cd1dae0cc81f1174fb2ec1b69a05ded2b2e Mon Sep 17 00:00:00 2001 From: Abhi Rao Date: Tue, 31 Jan 2012 23:11:15 -0600 Subject: [PATCH 044/161] Adding uniqueness validation for user name Fixes #116 --- app/models/user.rb | 2 ++ config/initializers/simple_form.rb | 2 +- features/signup.feature | 6 +++- features/step_definitions/signup_steps.rb | 34 ++++++++++++++++------- 4 files changed, 32 insertions(+), 12 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index 8c43a7f7..00ffa813 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -17,6 +17,8 @@ class User :message => "Make your username from letters, numbers, underscores('_'), and dots('.')." validates_length_of :username, :in => (1..32), :message => "Your username needs at least 1 character but no more than 32." + validates_uniqueness_of :username, + :message => "User name has been taken already. Please try another" def to_param self.username diff --git a/config/initializers/simple_form.rb b/config/initializers/simple_form.rb index dc586340..7cfda7fd 100644 --- a/config/initializers/simple_form.rb +++ b/config/initializers/simple_form.rb @@ -3,7 +3,7 @@ # Components used by the form builder to generate a complete input. You can remove # any of them, change the order, or even add your own components to the stack. # config.components = [ :placeholder, :label_input, :hint, :error ] - config.components = [ :placeholder, :label_input, :hint ] + config.components = [ :placeholder, :label_input, :hint, :error ] # Default tag used on hints. # config.hint_tag = :span diff --git a/features/signup.feature b/features/signup.feature index 2cb76b84..f1123432 100644 --- a/features/signup.feature +++ b/features/signup.feature @@ -4,4 +4,8 @@ Feature: Sign up for an account Scenario: Create an account via the signup form When I register a new account - Then I should be logged in with my new account \ No newline at end of file + Then I should be logged in with my new account + + Scenario: Try to sign up using existing user name + When I register a duplicate account + Then I should see validation errors diff --git a/features/step_definitions/signup_steps.rb b/features/step_definitions/signup_steps.rb index 65c64ce4..9d1cdb15 100644 --- a/features/step_definitions/signup_steps.rb +++ b/features/step_definitions/signup_steps.rb @@ -1,17 +1,31 @@ -When /^I register a new account$/ do - @user_info = {:username => "username", :password => "password", :email => "test@example.com"} - +def register_user(user) visit new_user_registration_path - - fill_in("Username", :with => @user_info[:username]) - fill_in("Email", :with => @user_info[:email]) - fill_in("Password", :with => @user_info[:password]) - fill_in("Password confirmation", :with => @user_info[:password]) + fill_in("Username", :with => user[:username]) + fill_in("Email", :with => user[:email]) + fill_in("Password", :with => user[:password]) + fill_in("Password confirmation", :with => user[:password]) click_button "Sign up" end +When /^I register a new account$/ do + @new_user = {:username => "username", :password => "password", :email => "test@example.com"} + register_user @new_user +end + +When /^I register a duplicate account$/ do + @existing_user = User.create!(username: "existing_user", + email: "existing_user@example.com", + password: "foobar", + password_confirmation: "foobar") + register_user @existing_user +end + When /^I should be logged in with my new account$/ do page.should have_content("You have signed up successfully") - page.should have_content(@user_info[:username]) -end \ No newline at end of file + page.should have_content(@new_user[:username]) +end + +Then /^I should see validation errors$/ do + page.should have_selector(".error_notification") +end From 686e7fd96342d788229ebc2f6ffb286d567d12d6 Mon Sep 17 00:00:00 2001 From: Abhi Rao Date: Wed, 1 Feb 2012 18:57:24 -0600 Subject: [PATCH 045/161] Should only show hint on update. Fixes #123 --- app/views/users/_form.html.haml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/views/users/_form.html.haml b/app/views/users/_form.html.haml index 80976dd3..1f20859d 100644 --- a/app/views/users/_form.html.haml +++ b/app/views/users/_form.html.haml @@ -5,7 +5,8 @@ = f.input :username, :autofocus => true = f.input :email, :autofocus => true .inputs - = f.input :password, :hint => "Leave it blank if you don't want to change it", :required => false + - pwd_options = resource.new_record? ? {} : {:hint => "Leave it blank if you don't want to change it"} + = f.input :password, pwd_options.merge({:required => false}) = f.input :password_confirmation, :required => false .inputs = f.input :about, :as => :text @@ -13,4 +14,4 @@ .inputs = f.input :current_password, :required => true, :hint => "We need your password to update your account." .actions - = f.button :submit, submit_label, :class => "btn primary" \ No newline at end of file + = f.button :submit, submit_label, :class => "btn primary" From 0ad39195f56299ebeac866996740f5bee2b3b388 Mon Sep 17 00:00:00 2001 From: cyberarm Date: Thu, 2 Feb 2012 07:59:08 -0600 Subject: [PATCH 046/161] Fix links and logo on 500 page --- public/500.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/public/500.html b/public/500.html index 29660ecb..4b8b5312 100644 --- a/public/500.html +++ b/public/500.html @@ -36,8 +36,8 @@

We're sorry, but something went wrong.

From b02189e0115cde511f59db4eb41f96df9a0cb191 Mon Sep 17 00:00:00 2001 From: cyberarm Date: Thu, 2 Feb 2012 07:59:38 -0600 Subject: [PATCH 047/161] Fix links and logo on 404 page --- public/404.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/public/404.html b/public/404.html index 843e22d8..c43e389f 100644 --- a/public/404.html +++ b/public/404.html @@ -36,8 +36,8 @@

The page you were looking for doesn't exist.

From e8acec3b0227c755105b5c3afecfbeeee56a392e Mon Sep 17 00:00:00 2001 From: Corey Purcell Date: Sat, 4 Feb 2012 13:37:53 -0500 Subject: [PATCH 048/161] (#99) added features around the moderator abilities --- Gemfile.lock | 2 +- features/moderator.feature | 15 ++++++++++++ features/step_definitions/question_steps.rb | 27 +++++++++++++++++++++ 3 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 features/moderator.feature diff --git a/Gemfile.lock b/Gemfile.lock index 2f7717d0..2f91d729 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -208,7 +208,7 @@ GEM sprockets (2.0.3) hike (~> 1.2) rack (~> 1.0) - tilt (!= 1.3.0, ~> 1.1) + tilt (~> 1.1, != 1.3.0) sqlite3 (1.3.5) term-ansicolor (1.0.7) thor (0.14.6) diff --git a/features/moderator.feature b/features/moderator.feature new file mode 100644 index 00000000..2071f212 --- /dev/null +++ b/features/moderator.feature @@ -0,0 +1,15 @@ +Feature: Moderate questions + + As a moderator, I should be able to delete questions from the site. + + Background: + Given there is a question from someone else + + Scenario: Delete a question + Given I am a moderator + Then I can delete that question + + Scenario: Normal users cannot moderate + Given I am not a moderator + Then I cannot delete that question + diff --git a/features/step_definitions/question_steps.rb b/features/step_definitions/question_steps.rb index f9b3a9e5..6009c346 100644 --- a/features/step_definitions/question_steps.rb +++ b/features/step_definitions/question_steps.rb @@ -48,3 +48,30 @@ def create_question_for(user) visit user_path(@user) page.should have_content("My Question") end + +Given /^I am a moderator$/ do + step %{a logged in user} + @user.moderator = true + @user.save +end + +Given /^I am not a moderator$/ do + step %{a logged in user} + @user.moderator = false + @user.save +end + +Given /^there is a question from someone else$/ do + @question = Question.create(:title => "A question to delete", + :description => "moderator should delete me!") +end + +Then /^I can delete that question$/ do + visit question_path(@question) + page.should have_content('Delete') +end + +Then /^I cannot delete that question$/ do + visit question_path(@question) + page.should_not have_content('Delete') +end From 993dcc59d741bd4adae90385a5fc6c74bde19d4c Mon Sep 17 00:00:00 2001 From: Corey Purcell Date: Sat, 4 Feb 2012 14:05:49 -0500 Subject: [PATCH 049/161] close #95, added some programs to seeds --- db/seeds.rb | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/db/seeds.rb b/db/seeds.rb index d68bf12d..8c03291a 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -73,3 +73,23 @@ question.save! questions[i] = question end + +program_code = " +Turtle.draw do + background maroon + pencolor honeydew + 450.times do + forward 100 + turnright 70 + end +end +" + +5.times do |i| + program = Program.new(:author_username => users[i].username, + :title => Faker::Lorem.sentence, + :description => Faker::Lorem.sentences.join(" "), + :source_code => program_code) + program.save! +end + From 9f05dfe2f2c55bc1afd4ea5f9efd7b749596f6c8 Mon Sep 17 00:00:00 2001 From: Steve Klabnik Date: Mon, 5 Mar 2012 18:49:02 -0500 Subject: [PATCH 050/161] Basics of showing a blog. --- app/assets/javascripts/blog.js.coffee | 3 +++ app/assets/stylesheets/blog.css.scss | 3 +++ app/controllers/blog_controller.rb | 5 +++++ app/helpers/blog_helper.rb | 2 ++ app/models/blog_post.rb | 8 ++++++++ app/views/blog/show.html.haml | 9 +++++++++ app/views/shared/menu/_footer.html.haml | 3 ++- app/views/shared/menu/_main.html.haml | 1 + config/routes.rb | 2 ++ features/blog.feature | 9 +++++++++ features/step_definitions/blog_steps.rb | 15 +++++++++++++++ spec/controllers/blog_controller_spec.rb | 5 +++++ spec/fabricators/blog_post_fabricator.rb | 4 ++++ spec/helpers/blog_helper_spec.rb | 15 +++++++++++++++ spec/models/blog_post_spec.rb | 5 +++++ 15 files changed, 88 insertions(+), 1 deletion(-) create mode 100644 app/assets/javascripts/blog.js.coffee create mode 100644 app/assets/stylesheets/blog.css.scss create mode 100644 app/controllers/blog_controller.rb create mode 100644 app/helpers/blog_helper.rb create mode 100644 app/models/blog_post.rb create mode 100644 app/views/blog/show.html.haml create mode 100644 features/blog.feature create mode 100644 features/step_definitions/blog_steps.rb create mode 100644 spec/controllers/blog_controller_spec.rb create mode 100644 spec/fabricators/blog_post_fabricator.rb create mode 100644 spec/helpers/blog_helper_spec.rb create mode 100644 spec/models/blog_post_spec.rb diff --git a/app/assets/javascripts/blog.js.coffee b/app/assets/javascripts/blog.js.coffee new file mode 100644 index 00000000..76156794 --- /dev/null +++ b/app/assets/javascripts/blog.js.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/ diff --git a/app/assets/stylesheets/blog.css.scss b/app/assets/stylesheets/blog.css.scss new file mode 100644 index 00000000..e505f1dc --- /dev/null +++ b/app/assets/stylesheets/blog.css.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the blog controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/controllers/blog_controller.rb b/app/controllers/blog_controller.rb new file mode 100644 index 00000000..e38e11d5 --- /dev/null +++ b/app/controllers/blog_controller.rb @@ -0,0 +1,5 @@ +class BlogController < ApplicationController + def show + @posts = BlogPost.all + end +end diff --git a/app/helpers/blog_helper.rb b/app/helpers/blog_helper.rb new file mode 100644 index 00000000..77a397e9 --- /dev/null +++ b/app/helpers/blog_helper.rb @@ -0,0 +1,2 @@ +module BlogHelper +end diff --git a/app/models/blog_post.rb b/app/models/blog_post.rb new file mode 100644 index 00000000..d3471fcc --- /dev/null +++ b/app/models/blog_post.rb @@ -0,0 +1,8 @@ +class BlogPost + include MongoMapper::Document + + key :title, String + key :content, String + + timestamps! +end diff --git a/app/views/blog/show.html.haml b/app/views/blog/show.html.haml new file mode 100644 index 00000000..fec7144d --- /dev/null +++ b/app/views/blog/show.html.haml @@ -0,0 +1,9 @@ +%h1 The Hackety Blog! + +- @posts.each do |post| + %h2= post.title + %h3= post.created_at + :markdown + #{post.content} + %hr/ + diff --git a/app/views/shared/menu/_footer.html.haml b/app/views/shared/menu/_footer.html.haml index dbaef778..39cb4472 100644 --- a/app/views/shared/menu/_footer.html.haml +++ b/app/views/shared/menu/_footer.html.haml @@ -1,7 +1,8 @@ = semantic_menu :class => "pills" do |root| - root.add "Home", root_path + - root.add "Blog", blog_path - root.add "Questions", questions_path - root.add "Programs", programs_path - root.add "FAQ", faq_path - root.add "Support", support_questions_path - \ No newline at end of file + diff --git a/app/views/shared/menu/_main.html.haml b/app/views/shared/menu/_main.html.haml index dfaa7bda..69582d09 100644 --- a/app/views/shared/menu/_main.html.haml +++ b/app/views/shared/menu/_main.html.haml @@ -1,4 +1,5 @@ = semantic_menu :class => "nav" do |root| + - root.add "Blog", blog_path - root.add "Questions", questions_path - root.add "Lessons", lessons_path - root.add "Programs", programs_path diff --git a/config/routes.rb b/config/routes.rb index a0dc66e0..8995b9d5 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -6,6 +6,8 @@ resources :answers end + match "/blog", :to => "blog#show" + get "/downloads/latest/:platform", :to => "static#download", :as => 'downloads' get "/downloads/latest", :to => "static#download", :as => 'download' match "/download" => redirect("/downloads/latest") diff --git a/features/blog.feature b/features/blog.feature new file mode 100644 index 00000000..1e3953b9 --- /dev/null +++ b/features/blog.feature @@ -0,0 +1,9 @@ +Feature: Hackety Blog + + As an admin, I can post to the hackety blog. + + Scenario: Read the blog + Given a blog post exists + When I visit the blog + Then I should see the content of that post + And I should see the title of that post diff --git a/features/step_definitions/blog_steps.rb b/features/step_definitions/blog_steps.rb new file mode 100644 index 00000000..240a3532 --- /dev/null +++ b/features/step_definitions/blog_steps.rb @@ -0,0 +1,15 @@ +Given /^a blog post exists$/ do + @post = Fabricate(:blog_post) +end + +When /^I visit the blog$/ do + visit "/blog" +end + +Then /^I should see the content of that post$/ do + page.should have_content(@post.content) +end + +Then /^I should see the title of that post$/ do + page.should have_content(@post.title) +end diff --git a/spec/controllers/blog_controller_spec.rb b/spec/controllers/blog_controller_spec.rb new file mode 100644 index 00000000..2dda864e --- /dev/null +++ b/spec/controllers/blog_controller_spec.rb @@ -0,0 +1,5 @@ +require 'spec_helper' + +describe BlogController do + +end diff --git a/spec/fabricators/blog_post_fabricator.rb b/spec/fabricators/blog_post_fabricator.rb new file mode 100644 index 00000000..561914bb --- /dev/null +++ b/spec/fabricators/blog_post_fabricator.rb @@ -0,0 +1,4 @@ +Fabricator(:blog_post) do + content "Hello, world" + title "Title" +end diff --git a/spec/helpers/blog_helper_spec.rb b/spec/helpers/blog_helper_spec.rb new file mode 100644 index 00000000..bef6d821 --- /dev/null +++ b/spec/helpers/blog_helper_spec.rb @@ -0,0 +1,15 @@ +require 'spec_helper' + +# Specs in this file have access to a helper object that includes +# the BlogHelper. For example: +# +# describe BlogHelper do +# describe "string concat" do +# it "concats two strings with spaces" do +# helper.concat_strings("this","that").should == "this that" +# end +# end +# end +describe BlogHelper do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/models/blog_post_spec.rb b/spec/models/blog_post_spec.rb new file mode 100644 index 00000000..9047c6e8 --- /dev/null +++ b/spec/models/blog_post_spec.rb @@ -0,0 +1,5 @@ +require 'spec_helper' + +describe BlogPost do + pending "add some examples to (or delete) #{__FILE__}" +end From f13c64314cc4b6009c41ef9d05f6d53b6611fe1f Mon Sep 17 00:00:00 2001 From: Steve Klabnik Date: Mon, 5 Mar 2012 19:36:03 -0500 Subject: [PATCH 051/161] creating posts on the admin page --- app/controllers/blog_controller.rb | 12 ++++++++++- app/models/blog_post.rb | 4 ++-- app/models/user.rb | 1 + app/views/blog/admin.html.haml | 15 ++++++++++++++ config/routes.rb | 4 +++- features/blog.feature | 11 ++++++++-- features/step_definitions/blog_steps.rb | 27 +++++++++++++++++++++++++ 7 files changed, 68 insertions(+), 6 deletions(-) create mode 100644 app/views/blog/admin.html.haml diff --git a/app/controllers/blog_controller.rb b/app/controllers/blog_controller.rb index e38e11d5..504f80ea 100644 --- a/app/controllers/blog_controller.rb +++ b/app/controllers/blog_controller.rb @@ -1,5 +1,15 @@ class BlogController < ApplicationController def show - @posts = BlogPost.all + @posts = BlogPost.all.reverse + end + + def create + @post = BlogPost.create(params[:blog_post]) + redirect_to admin_blog_path, :notice => "Blog Post created!" + end + + def admin + @post = BlogPost.new + @posts = BlogPost.all.reverse end end diff --git a/app/models/blog_post.rb b/app/models/blog_post.rb index d3471fcc..5b50f9b6 100644 --- a/app/models/blog_post.rb +++ b/app/models/blog_post.rb @@ -1,8 +1,8 @@ class BlogPost include MongoMapper::Document - key :title, String - key :content, String + key :title, String, :required => true + key :content, String, :required => true timestamps! end diff --git a/app/models/user.rb b/app/models/user.rb index 00ffa813..5c1c686a 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -9,6 +9,7 @@ class User key :email, String key :about, String key :moderator, Boolean + key :blog_poster, Boolean many :questions many :answers diff --git a/app/views/blog/admin.html.haml b/app/views/blog/admin.html.haml new file mode 100644 index 00000000..8cb67cbf --- /dev/null +++ b/app/views/blog/admin.html.haml @@ -0,0 +1,15 @@ +%h1 Blog Admin + +%h2 New Post += form_for @post, :url => blog_path do |f| + = f.label :title + = f.text_field :title + = f.label :content + = f.text_area :content + = f.submit + +%h2 All Posts +%ul + - @posts.each do |post| + %li= post.title + diff --git a/config/routes.rb b/config/routes.rb index 8995b9d5..a8f948bb 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -6,7 +6,9 @@ resources :answers end - match "/blog", :to => "blog#show" + resource :blog, :controller => "blog" do + match "/admin", :to => "blog#admin" + end get "/downloads/latest/:platform", :to => "static#download", :as => 'downloads' get "/downloads/latest", :to => "static#download", :as => 'download' diff --git a/features/blog.feature b/features/blog.feature index 1e3953b9..ebae9f24 100644 --- a/features/blog.feature +++ b/features/blog.feature @@ -5,5 +5,12 @@ Feature: Hackety Blog Scenario: Read the blog Given a blog post exists When I visit the blog - Then I should see the content of that post - And I should see the title of that post + Then I should see the title of that post + And I should see the content of that post + + Scenario: Post to the blog + Given I'm logged in as someone who can post to the blog + When I visit the blog admin page + And I fill out the new blog form + And I press "Create Blog post" + Then I should see that my post has been created diff --git a/features/step_definitions/blog_steps.rb b/features/step_definitions/blog_steps.rb index 240a3532..d7cc435f 100644 --- a/features/step_definitions/blog_steps.rb +++ b/features/step_definitions/blog_steps.rb @@ -13,3 +13,30 @@ Then /^I should see the title of that post$/ do page.should have_content(@post.title) end + +Given /^I'm logged in as someone who can post to the blog$/ do + step %{a logged in user} + @user.blog_poster = true + @user.save +end + +When /^I visit the blog admin page$/ do + visit "/blog/admin" +end + +When /^I fill out the new blog form$/ do + #this is silly + @post = OpenStruct.new + @post.title = "A title" + + fill_in :title, :with => "A title" + fill_in :content, :with => "Some content" +end + +When /^I press "([^"]*)"$/ do |name| + click_button name +end + +Then /^I should see that my post has been created$/ do + page.should have_content("Post created!") +end From 1a129ebfe375f6ba238aa89f3c45cb6e4c24f2d5 Mon Sep 17 00:00:00 2001 From: Steve Klabnik Date: Mon, 5 Mar 2012 20:05:38 -0500 Subject: [PATCH 052/161] view individual posts --- app/controllers/blog_controller.rb | 8 ++++++-- app/views/blog/admin.html.haml | 2 +- app/views/blog/index.html.haml | 9 +++++++++ app/views/blog/show.html.haml | 13 ++++--------- app/views/shared/menu/_footer.html.haml | 2 +- app/views/shared/menu/_main.html.haml | 2 +- config/routes.rb | 4 ++-- features/blog.feature | 6 ++++++ features/step_definitions/blog_steps.rb | 5 +++++ 9 files changed, 35 insertions(+), 16 deletions(-) create mode 100644 app/views/blog/index.html.haml diff --git a/app/controllers/blog_controller.rb b/app/controllers/blog_controller.rb index 504f80ea..e851a871 100644 --- a/app/controllers/blog_controller.rb +++ b/app/controllers/blog_controller.rb @@ -1,11 +1,15 @@ class BlogController < ApplicationController - def show + def index @posts = BlogPost.all.reverse end def create @post = BlogPost.create(params[:blog_post]) - redirect_to admin_blog_path, :notice => "Blog Post created!" + redirect_to admin_blog_index_path, :notice => "Blog Post created!" + end + + def show + @post = BlogPost.find(params[:id]) end def admin diff --git a/app/views/blog/admin.html.haml b/app/views/blog/admin.html.haml index 8cb67cbf..e5f17e1a 100644 --- a/app/views/blog/admin.html.haml +++ b/app/views/blog/admin.html.haml @@ -1,7 +1,7 @@ %h1 Blog Admin %h2 New Post -= form_for @post, :url => blog_path do |f| += form_for @post, :url => blog_index_path do |f| = f.label :title = f.text_field :title = f.label :content diff --git a/app/views/blog/index.html.haml b/app/views/blog/index.html.haml new file mode 100644 index 00000000..fec7144d --- /dev/null +++ b/app/views/blog/index.html.haml @@ -0,0 +1,9 @@ +%h1 The Hackety Blog! + +- @posts.each do |post| + %h2= post.title + %h3= post.created_at + :markdown + #{post.content} + %hr/ + diff --git a/app/views/blog/show.html.haml b/app/views/blog/show.html.haml index fec7144d..912a6516 100644 --- a/app/views/blog/show.html.haml +++ b/app/views/blog/show.html.haml @@ -1,9 +1,4 @@ -%h1 The Hackety Blog! - -- @posts.each do |post| - %h2= post.title - %h3= post.created_at - :markdown - #{post.content} - %hr/ - +%h1= @post.title +%h3= @post.created_at +:markdown + #{@post.content} diff --git a/app/views/shared/menu/_footer.html.haml b/app/views/shared/menu/_footer.html.haml index 39cb4472..2cd33abe 100644 --- a/app/views/shared/menu/_footer.html.haml +++ b/app/views/shared/menu/_footer.html.haml @@ -1,6 +1,6 @@ = semantic_menu :class => "pills" do |root| - root.add "Home", root_path - - root.add "Blog", blog_path + - root.add "Blog", blog_index_path - root.add "Questions", questions_path - root.add "Programs", programs_path - root.add "FAQ", faq_path diff --git a/app/views/shared/menu/_main.html.haml b/app/views/shared/menu/_main.html.haml index 69582d09..8d010254 100644 --- a/app/views/shared/menu/_main.html.haml +++ b/app/views/shared/menu/_main.html.haml @@ -1,5 +1,5 @@ = semantic_menu :class => "nav" do |root| - - root.add "Blog", blog_path + - root.add "Blog", blog_index_path - root.add "Questions", questions_path - root.add "Lessons", lessons_path - root.add "Programs", programs_path diff --git a/config/routes.rb b/config/routes.rb index a8f948bb..410a0336 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -6,8 +6,8 @@ resources :answers end - resource :blog, :controller => "blog" do - match "/admin", :to => "blog#admin" + resources :blog, :controller => "blog" do + match "admin", :on => :collection, :controller => "blog", :action => "admin" end get "/downloads/latest/:platform", :to => "static#download", :as => 'downloads' diff --git a/features/blog.feature b/features/blog.feature index ebae9f24..4c538602 100644 --- a/features/blog.feature +++ b/features/blog.feature @@ -8,6 +8,12 @@ Feature: Hackety Blog Then I should see the title of that post And I should see the content of that post + Scenario: Read a post + Given a blog post exists + When I visit a blog post + Then I should see the title of that post + And I should see the content of that post + Scenario: Post to the blog Given I'm logged in as someone who can post to the blog When I visit the blog admin page diff --git a/features/step_definitions/blog_steps.rb b/features/step_definitions/blog_steps.rb index d7cc435f..02d8b0e6 100644 --- a/features/step_definitions/blog_steps.rb +++ b/features/step_definitions/blog_steps.rb @@ -40,3 +40,8 @@ Then /^I should see that my post has been created$/ do page.should have_content("Post created!") end + +When /^I visit a blog post$/ do + visit blog_path(@post) +end + From a829e4dba6332d6ca68bcf31974f522009101eaf Mon Sep 17 00:00:00 2001 From: Dominic Dagradi Date: Mon, 5 Mar 2012 20:55:13 -0500 Subject: [PATCH 053/161] styled blog --- app/assets/stylesheets/application.css.scss | 1 + app/assets/stylesheets/blog.css.scss | 32 +++++++++++++++++++-- app/assets/stylesheets/layout.css.scss | 23 ++++++++++++++- app/views/blog/index.html.haml | 23 ++++++++++----- app/views/blog/show.html.haml | 19 +++++++++--- app/views/shared/_recent.html.haml | 6 ++++ 6 files changed, 89 insertions(+), 15 deletions(-) create mode 100644 app/views/shared/_recent.html.haml diff --git a/app/assets/stylesheets/application.css.scss b/app/assets/stylesheets/application.css.scss index e5b8adbe..39a9a87a 100644 --- a/app/assets/stylesheets/application.css.scss +++ b/app/assets/stylesheets/application.css.scss @@ -17,4 +17,5 @@ @import "programs.css.scss"; @import "users.css.scss"; @import "lessons.css.scss"; +@import "blog.css.scss"; diff --git a/app/assets/stylesheets/blog.css.scss b/app/assets/stylesheets/blog.css.scss index e505f1dc..3b293afe 100644 --- a/app/assets/stylesheets/blog.css.scss +++ b/app/assets/stylesheets/blog.css.scss @@ -1,3 +1,29 @@ -// Place all the styles related to the blog controller here. -// They will automatically be included in application.css. -// You can use Sass (SCSS) here: http://sass-lang.com/ +.post.teaser { + h2.title { + line-height: 1; + } + + border-bottom: 1px solid #ccc; + margin-bottom: 3em; +} + +.post { + + padding-bottom: 2em; + + .created_at { + margin-bottom: 1em; + color: #888; + font-size: 1.15em; + font-style: italic; + + } + + margin-right: 3em; + .content { + p { + font-size: 1.15em; + line-height: 1.75em; + } + } +} \ No newline at end of file diff --git a/app/assets/stylesheets/layout.css.scss b/app/assets/stylesheets/layout.css.scss index 3b60e802..19350a41 100644 --- a/app/assets/stylesheets/layout.css.scss +++ b/app/assets/stylesheets/layout.css.scss @@ -73,7 +73,7 @@ header .topbar-inner { } .two-column { - #content { + .page-title, #content { @include columns(11); } @@ -87,6 +87,27 @@ header .topbar-inner { background: #f3f3f3; margin-bottom: 8px; padding: 1.5em; + + a { + color: darken($blue, 10%); + } + + a.btn { + color: white; + } + + ul { + margin: 0; + li { + list-style-type: none; + margin-bottom: 0.5em; + border-bottom: 1px solid #ddd; + padding-bottom: 0.5em; + } + li:last-child { + border: none; + } + } } } diff --git a/app/views/blog/index.html.haml b/app/views/blog/index.html.haml index fec7144d..4c501ce5 100644 --- a/app/views/blog/index.html.haml +++ b/app/views/blog/index.html.haml @@ -1,9 +1,18 @@ -%h1 The Hackety Blog! +- content_for :title do + The Hackety Blog! + +- content_for :sidebar do + = render :partial => "shared/ask" + = render :partial => "shared/lessons" - @posts.each do |post| - %h2= post.title - %h3= post.created_at - :markdown - #{post.content} - %hr/ - + .post.teaser + %h2.title= link_to post.title, blog_path(post) + + .created_at + = post.created_at.strftime("Posted %B %d, %Y at %l:%M %p") + + .content + :markdown + #{post.content} + diff --git a/app/views/blog/show.html.haml b/app/views/blog/show.html.haml index 912a6516..db5aa6e4 100644 --- a/app/views/blog/show.html.haml +++ b/app/views/blog/show.html.haml @@ -1,4 +1,15 @@ -%h1= @post.title -%h3= @post.created_at -:markdown - #{@post.content} +- content_for :title do + = @post.title + +- content_for :sidebar do + = render :partial => "shared/recent" + = render :partial => "shared/ask" + = render :partial => "shared/lessons" + +.post + .created_at + = @post.created_at.strftime("Posted %B %d, %Y at %l:%M %p") + + .content + :markdown + #{@post.content} diff --git a/app/views/shared/_recent.html.haml b/app/views/shared/_recent.html.haml new file mode 100644 index 00000000..9a7460aa --- /dev/null +++ b/app/views/shared/_recent.html.haml @@ -0,0 +1,6 @@ +%section.recent + %h2 Recent Posts + %ul + - BlogPost.sort("created_at DESC").limit(5).each do |post| + %li + = link_to post.title, blog_path(post) From 87bebf75f21a3cbf5e626e4f137d6c6de6e6faec Mon Sep 17 00:00:00 2001 From: Steve Klabnik Date: Tue, 6 Mar 2012 09:22:07 -0500 Subject: [PATCH 054/161] adding blog auth. heh --- app/controllers/blog_controller.rb | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/app/controllers/blog_controller.rb b/app/controllers/blog_controller.rb index e851a871..ae9542b4 100644 --- a/app/controllers/blog_controller.rb +++ b/app/controllers/blog_controller.rb @@ -1,19 +1,23 @@ class BlogController < ApplicationController + before_filter :authenticate_user!, :only => [:admin, :create] + def index @posts = BlogPost.all.reverse end - def create - @post = BlogPost.create(params[:blog_post]) - redirect_to admin_blog_index_path, :notice => "Blog Post created!" - end - def show @post = BlogPost.find(params[:id]) end def admin + redirect_to blog_index unless current_user.blog_poster @post = BlogPost.new @posts = BlogPost.all.reverse end + + def create + redirect_to blog_index unless current_user.blog_poster + @post = BlogPost.create(params[:blog_post]) + redirect_to admin_blog_index_path, :notice => "Blog Post created!" + end end From 0ad74ae6e60e8bef57ff8454b05bf527cf1ec2f2 Mon Sep 17 00:00:00 2001 From: Tobias Pfeiffer Date: Fri, 9 Mar 2012 20:52:32 +0100 Subject: [PATCH 055/161] Added class attributes to followers and following in order to ease the testing --- app/views/users/show.html.haml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/views/users/show.html.haml b/app/views/users/show.html.haml index 6ad5a01a..d4a79eb7 100644 --- a/app/views/users/show.html.haml +++ b/app/views/users/show.html.haml @@ -20,10 +20,10 @@ = link_to pluralize(resource.programs.count, "Program"), user_programs_path(resource), :class => "user-programs" %p Following: - =link_to resource.following.count, resource_path(resource) + "/following" + =link_to resource.following.count, resource_path(resource) + "/following", :class => 'user-following' %p Followers: - = link_to resource.followers.count, resource_path(resource) + "/followers" + = link_to resource.followers.count, resource_path(resource) + "/followers", :class => 'user-followers' %hr - if can? :update, resource = link_to "Change My Settings", edit_registration_path(resource), :class => "btn success" @@ -52,3 +52,4 @@ = answer.description.truncate(100) .meta = link_to("View Answer", answer.question) + From bc3cda677e6749b5be66c9ef61c9cdedf32b084e Mon Sep 17 00:00:00 2001 From: Tobias Pfeiffer Date: Fri, 9 Mar 2012 21:17:51 +0100 Subject: [PATCH 056/161] First version where it's fixed --- app/controllers/users_controller.rb | 9 ++++++--- features/step_definitions/user_steps.rb | 19 +++++++++++++++++++ features/users.feature | 13 +++++++++++-- 3 files changed, 36 insertions(+), 5 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 185f5ee6..ec55123b 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -23,11 +23,13 @@ def unfollow end def following - @user = User.first(:id => params[:user_id]) + puts "called" + @user = User.first(:username => params[:user_id]) + puts "@user: #{@user}" end def followers - @user = User.first(:id => params[:user_id]) + @user = User.first(:username => params[:user_id]) end ################# @@ -35,5 +37,6 @@ def followers def resource @user ||= end_of_association_chain.find_by_username(params[:id]) end - + end + diff --git a/features/step_definitions/user_steps.rb b/features/step_definitions/user_steps.rb index 671ca3ab..49473023 100644 --- a/features/step_definitions/user_steps.rb +++ b/features/step_definitions/user_steps.rb @@ -29,6 +29,24 @@ def login_user click_button "Update" end +When /^I click on the number of followers on my profile$/ do + step 'I go to look at my profile page' + first('.user-followers').click +end + +When /^I click on the number of people I am following on my profile$/ do + step 'I go to look at my profile page' + first('.user-following').click +end + +Then /^I should see a list of the people I'm following$/ do + page.should have_content "#{@user.username} is following" +end + +Then /^I should see a list of my followers$/ do + page.should have_content "#{@user.username}'s followers" +end + Then /^I should be notified that my profile was updated$/ do page.should have_content("updated your account") end @@ -37,3 +55,4 @@ def login_user visit("/users/#{@user.username}") page.should have_content("Test user likes to edit his profile") end + diff --git a/features/users.feature b/features/users.feature index 5a4f82ff..309c84bd 100644 --- a/features/users.feature +++ b/features/users.feature @@ -1,6 +1,6 @@ Feature: Manage account - As a user of this site, I can view and update my profile + As a user of this site, I can view and update my profile, see my followers Background: The user is logged in Given a logged in user @@ -12,4 +12,13 @@ Feature: Manage account Scenario: Edit my profile When I edit my profile Then I should be notified that my profile was updated - And I should see my changes reflected on my profile page \ No newline at end of file + And I should see my changes reflected on my profile page + + Scenario: See my followers + When I click on the number of followers on my profile + Then I should see a list of my followers + + Scenario: See who is following me + When I click on the number of people I am following on my profile + Then I should see a list of the people I'm following + From c60e1742425860c253568e3764fb7dcb35f641dc Mon Sep 17 00:00:00 2001 From: Tobias Pfeiffer Date: Fri, 9 Mar 2012 21:21:57 +0100 Subject: [PATCH 057/161] upps removed puts :-) --- app/controllers/users_controller.rb | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index ec55123b..ff461272 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -23,9 +23,7 @@ def unfollow end def following - puts "called" @user = User.first(:username => params[:user_id]) - puts "@user: #{@user}" end def followers From 597d083237175d37e6e26391ef2014dbae38007f Mon Sep 17 00:00:00 2001 From: Tobias Pfeiffer Date: Fri, 9 Mar 2012 21:30:12 +0100 Subject: [PATCH 058/161] Making tests more meaningful by introducing another user that can be followed/follow someone fixes #127 --- features/step_definitions/user_steps.rb | 31 +++++++++++++++++++------ features/users.feature | 12 ++++++---- 2 files changed, 31 insertions(+), 12 deletions(-) diff --git a/features/step_definitions/user_steps.rb b/features/step_definitions/user_steps.rb index 49473023..a1fea7b0 100644 --- a/features/step_definitions/user_steps.rb +++ b/features/step_definitions/user_steps.rb @@ -1,14 +1,21 @@ def login_user @user = User.create!(username: "test_user", - email: "test_user@example.com", - password: "foobar", - password_confirmation: "foobar") + email: "test_user@example.com", + password: "foobar", + password_confirmation: "foobar") visit login_path fill_in("Username", :with => @user.username) fill_in("Password", :with => @user.password) click_button("Sign in") end +def create_other_user + @other_user = User.create!(username: "other_user", + email: "other_user@example.com", + password: "123456", + password_confirmation: "123456") +end + Given /^a logged in user$/ do login_user unless @user end @@ -29,6 +36,16 @@ def login_user click_button "Update" end +When /^I have a follower$/ do + create_other_user + @other_user.follow! @user +end + +When /^I am following someone$/ do + create_other_user + @user.follow! @other_user +end + When /^I click on the number of followers on my profile$/ do step 'I go to look at my profile page' first('.user-followers').click @@ -39,12 +56,12 @@ def login_user first('.user-following').click end -Then /^I should see a list of the people I'm following$/ do - page.should have_content "#{@user.username} is following" +Then /^I should see someone I'm following$/ do + page.should have_link @other_user.username end -Then /^I should see a list of my followers$/ do - page.should have_content "#{@user.username}'s followers" +Then /^I should see my follower$/ do + page.should have_link @other_user.username end Then /^I should be notified that my profile was updated$/ do diff --git a/features/users.feature b/features/users.feature index 309c84bd..7dca8ff5 100644 --- a/features/users.feature +++ b/features/users.feature @@ -15,10 +15,12 @@ Feature: Manage account And I should see my changes reflected on my profile page Scenario: See my followers - When I click on the number of followers on my profile - Then I should see a list of my followers + When I have a follower + And I click on the number of followers on my profile + Then I should see my follower - Scenario: See who is following me - When I click on the number of people I am following on my profile - Then I should see a list of the people I'm following + Scenario: See who I am following + When I am following someone + And I click on the number of people I am following on my profile + Then I should see someone I'm following From 1786f7c23a57a869057ee7b60bf19f357e8be9dd Mon Sep 17 00:00:00 2001 From: Tobias Pfeiffer Date: Mon, 12 Mar 2012 23:14:11 +0100 Subject: [PATCH 059/161] Removed unused Scenario: something --- features/answers.feature | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/features/answers.feature b/features/answers.feature index 1cf5d852..91a42e78 100644 --- a/features/answers.feature +++ b/features/answers.feature @@ -9,5 +9,4 @@ Feature: CRUD actions for answers And an email should be sent to the author And I should be able to see my answer And my answer should show on my profile page - - Scenario: Accept an answer + From 1c0759b31b238c60acc3f6bb4a681cc1807f033a Mon Sep 17 00:00:00 2001 From: Tobias Pfeiffer Date: Tue, 13 Mar 2012 00:22:30 +0100 Subject: [PATCH 060/161] I kind of separated the handling for the quick answers and the edit in the form and thereby introduced two levels of partials, dunno how to do it better atm. Suggestions are always welcome. Also got a sip of the magic of inherited_resources - wow. Contains a little nice cucumber feature. Fixes #126 --- app/controllers/answers_controller.rb | 8 ++++++++ app/views/answers/_form.html.haml | 10 ++-------- app/views/answers/_form_content.html.haml | 9 +++++++++ app/views/answers/_short_answer.html.haml | 3 +++ app/views/questions/show.html.haml | 3 ++- features/answers.feature | 6 ++++++ features/step_definitions/answer_steps.rb | 12 ++++++++++++ 7 files changed, 42 insertions(+), 9 deletions(-) create mode 100644 app/views/answers/_form_content.html.haml create mode 100644 app/views/answers/_short_answer.html.haml diff --git a/app/controllers/answers_controller.rb b/app/controllers/answers_controller.rb index 48ed6f11..e9377081 100644 --- a/app/controllers/answers_controller.rb +++ b/app/controllers/answers_controller.rb @@ -13,5 +13,13 @@ def create create!(:notice => "Answer Posted!"){ question_url(params[:question_id]) } end + def update + # inherited resorces (gem) magic + super do |format| + format.html { redirect_to question_url(resource.question) } + end + end + end + diff --git a/app/views/answers/_form.html.haml b/app/views/answers/_form.html.haml index f15e2502..53549aa9 100644 --- a/app/views/answers/_form.html.haml +++ b/app/views/answers/_form.html.haml @@ -1,9 +1,3 @@ -= simple_form_for(@answer, :url => question_answers_path(@question)) do |f| - = f.error_notification += simple_form_for(resource, :url => @form_url) do |f| + = render 'form_content', :f => f - .inputs - = f.input :description, :as => :text, :label => "Answer", - :hint => "You can format your input with Markdown".html_safe - - .actions - = f.button :submit, :value => "Post Answer", :class => "primary btn" diff --git a/app/views/answers/_form_content.html.haml b/app/views/answers/_form_content.html.haml new file mode 100644 index 00000000..9974bd1e --- /dev/null +++ b/app/views/answers/_form_content.html.haml @@ -0,0 +1,9 @@ += f.error_notification + +.inputs + = f.input :description, :as => :text, :label => "Answer", + :hint => "You can format your input with Markdown".html_safe + +.actions + = f.button :submit, :value => "Post Answer", :class => "primary btn" + diff --git a/app/views/answers/_short_answer.html.haml b/app/views/answers/_short_answer.html.haml new file mode 100644 index 00000000..33d8b788 --- /dev/null +++ b/app/views/answers/_short_answer.html.haml @@ -0,0 +1,3 @@ += simple_form_for(@answer, :url => question_answers_path(@question)) do |f| + = render 'answers/form_content', :f => f + diff --git a/app/views/questions/show.html.haml b/app/views/questions/show.html.haml index 10e39d98..1c17aaef 100644 --- a/app/views/questions/show.html.haml +++ b/app/views/questions/show.html.haml @@ -34,4 +34,5 @@ = render :partial => "answers/list", :collection => resource.answers - if can? :create, Answer - = render :partial => "answers/form" + = render :partial => "answers/short_answer" + diff --git a/features/answers.feature b/features/answers.feature index 91a42e78..600859ff 100644 --- a/features/answers.feature +++ b/features/answers.feature @@ -10,3 +10,9 @@ Feature: CRUD actions for answers And I should be able to see my answer And my answer should show on my profile page + Scenario: Edit an answer + Given a question exists + And I answer that question + When I edit that answer + Then I should see the updated answer + diff --git a/features/step_definitions/answer_steps.rb b/features/step_definitions/answer_steps.rb index 7743488b..515e2099 100644 --- a/features/step_definitions/answer_steps.rb +++ b/features/step_definitions/answer_steps.rb @@ -28,3 +28,15 @@ ActionMailer::Base.deliveries.should_not be_empty end +When /^I edit that answer$/ do + visit question_path(@question) + page.find('.answer > .links').click_link('Edit') + fill_in 'Answer', with: 'Edit: Did you try magic?' + click_button 'Post Answer' +end + +Then /^I should see the updated answer$/ do + page.should have_content("#{@user.username} says") + page.should have_content('Edit: Did you try magic?') +end + From 6068ecc4aa802772d5a12f869403e51f90b442ed Mon Sep 17 00:00:00 2001 From: Tobias Pfeiffer Date: Tue, 13 Mar 2012 00:31:47 +0100 Subject: [PATCH 061/161] Made the message displayed when editing an answer less quirky (no object id and stuff) --- app/views/answers/edit.html.haml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/views/answers/edit.html.haml b/app/views/answers/edit.html.haml index e05dd7e9..53544a89 100644 --- a/app/views/answers/edit.html.haml +++ b/app/views/answers/edit.html.haml @@ -1,4 +1,5 @@ - content_for :title do - = "Editing #{resource}" + = "Editing your answer" = render 'form' + From 837874261779205bc66587fe3d03527ef47ec150 Mon Sep 17 00:00:00 2001 From: Arne Eilermann Date: Sat, 24 Mar 2012 22:29:43 +0100 Subject: [PATCH 062/161] Added a link to support on the homepage. --- app/views/static/root.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/static/root.html.haml b/app/views/static/root.html.haml index 3227926e..6271f045 100644 --- a/app/views/static/root.html.haml +++ b/app/views/static/root.html.haml @@ -29,5 +29,5 @@ %section#ask %h1 Help is Here .content - %p Got a question about Hackety Hack? Check out our #{link_to "FAQ", "faq"}. If that doesn't cover it ask for support here + %p Got a question about Hackety Hack? Check out our #{link_to "FAQ", "faq"}. If that doesn't cover it ask for support #{link_to "here", support_questions_path}. %p Got a question about programming in general? Ask away in the #{link_to "Questions", questions_path} section. No question to big or small, the community is here to help you out. From 35da3f1317e683b7a47229ac8e927510b6ef1a13 Mon Sep 17 00:00:00 2001 From: Jared Moody Date: Sat, 8 Dec 2012 13:50:32 -0800 Subject: [PATCH 063/161] add --color to cucumber output to make it pretty --- config/cucumber.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/cucumber.yml b/config/cucumber.yml index 19b288df..67669be1 100644 --- a/config/cucumber.yml +++ b/config/cucumber.yml @@ -1,7 +1,7 @@ <% rerun = File.file?('rerun.txt') ? IO.read('rerun.txt') : "" -rerun_opts = rerun.to_s.strip.empty? ? "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} features" : "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} #{rerun}" -std_opts = "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} --strict --tags ~@wip" +rerun_opts = rerun.to_s.strip.empty? ? "--color --format #{ENV['CUCUMBER_FORMAT'] || 'progress'} features" : "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} #{rerun}" +std_opts = "--color --format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} --strict --tags ~@wip" %> default: <%= std_opts %> features wip: --tags @wip:3 --wip features From e131b82337849a966a9f0ceb71ba6005c625af61 Mon Sep 17 00:00:00 2001 From: Jared Moody Date: Sat, 8 Dec 2012 15:04:19 -0800 Subject: [PATCH 064/161] add require: false to cucumber-rails in Gemfile to remove warning --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 466ef4d0..524a22ea 100644 --- a/Gemfile +++ b/Gemfile @@ -40,7 +40,7 @@ end group :development, :test do gem 'fabrication' gem 'rspec-rails' - gem 'cucumber-rails' + gem 'cucumber-rails', require: false gem "faker" gem 'pry' gem 'sqlite3' From db7edc6d6a2dac9e4aedc326f655df35c6439461 Mon Sep 17 00:00:00 2001 From: Jared Moody Date: Sat, 8 Dec 2012 20:58:25 -0800 Subject: [PATCH 065/161] Add Atom feed to questions --- app/controllers/questions_controller.rb | 10 ++++++---- app/views/layouts/application.html.haml | 2 ++ app/views/questions/index.atom.builder | 19 +++++++++++++++++++ app/views/questions/index.html.haml | 4 ++++ spec/controllers/questions_controller_spec.rb | 13 +++++++++++++ spec/spec_helper.rb | 2 ++ .../questions/index.atom.builder_spec.rb | 15 +++++++++++++++ spec/views/questions/index.html.haml_spec.rb | 18 ++++++++++++++++++ 8 files changed, 79 insertions(+), 4 deletions(-) create mode 100644 app/views/questions/index.atom.builder create mode 100644 spec/controllers/questions_controller_spec.rb create mode 100644 spec/views/questions/index.atom.builder_spec.rb create mode 100644 spec/views/questions/index.html.haml_spec.rb diff --git a/app/controllers/questions_controller.rb b/app/controllers/questions_controller.rb index 34483830..8038f468 100644 --- a/app/controllers/questions_controller.rb +++ b/app/controllers/questions_controller.rb @@ -3,6 +3,8 @@ class QuestionsController < InheritedController prepend_before_filter :set_presenter prepend_before_filter :set_support + respond_to :atom, :only => :index + def create @question = Question.create params[:question] @question.user = current_user @@ -37,7 +39,7 @@ def new_resource_path def resource_url(*params) resource_path(params) end - + def resource_path(*other) if other[0] @presenter.resource_path(other) @@ -45,18 +47,18 @@ def resource_path(*other) @presenter.resource_path(resource) end end - + def edit_resource_path @support ? edit_support_question_path : edit_question_path end - + def set_support @support = request.env['PATH_INFO'].include?('support') || params[:support] if @support && params[:question] params[:question][:support] = true end end - + def set_presenter if @support @presenter = SupportPresenter.new(resource) diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index b9ef0bf4..75851201 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -27,6 +27,8 @@ + = yield(:head) + %body{:class => "body-#{@page_class}"} %header.topbar .topbar-inner diff --git a/app/views/questions/index.atom.builder b/app/views/questions/index.atom.builder new file mode 100644 index 00000000..09f14748 --- /dev/null +++ b/app/views/questions/index.atom.builder @@ -0,0 +1,19 @@ +atom_feed :language => 'en-US' do |feed| + feed.title "Hackety Hack Questions" + feed.updated @updated + + @questions.each do |question| + feed.entry( question ) do |entry| + entry.url question_url(question) + entry.title question.title + entry.content question.description + + # the strftime is needed to work with Google Reader. + entry.updated(question.updated_at.strftime("%Y-%m-%dT%H:%M:%SZ")) + + entry.author do |author| + author.name question.user.username + end + end + end +end \ No newline at end of file diff --git a/app/views/questions/index.html.haml b/app/views/questions/index.html.haml index b552bace..023ee08c 100644 --- a/app/views/questions/index.html.haml +++ b/app/views/questions/index.html.haml @@ -1,3 +1,7 @@ +- content_for :head do + - unless @support + = auto_discovery_link_tag :atom, questions_url(format: :atom) + - content_for :title do -if @support Support Questions diff --git a/spec/controllers/questions_controller_spec.rb b/spec/controllers/questions_controller_spec.rb new file mode 100644 index 00000000..54222ec1 --- /dev/null +++ b/spec/controllers/questions_controller_spec.rb @@ -0,0 +1,13 @@ +require 'spec_helper' + +describe QuestionsController do + + describe "GET index" do + context "with format atom" do + it "responds with success" do + get :index, format: :atom + response.should be_success + end + end + end +end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 75b19268..79d1f541 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -26,4 +26,6 @@ config.include(MailerMacros) config.before(:each) { reset_email } + + config.include Devise::TestHelpers, :type => :controller end diff --git a/spec/views/questions/index.atom.builder_spec.rb b/spec/views/questions/index.atom.builder_spec.rb new file mode 100644 index 00000000..08d0faab --- /dev/null +++ b/spec/views/questions/index.atom.builder_spec.rb @@ -0,0 +1,15 @@ +require 'spec_helper' + +describe 'questions/index.atom.builder' do + let(:question) { Fabricate(:question) } + + before { assign(:questions, [question]) } + + it "renders the feed without error" do + render + rendered.should include(question.title) + rendered.should include(question.description) + rendered.should include(question.updated_at.strftime("%Y-%m-%dT%H:%M:%SZ")) + rendered.should include(question.user.username) + end +end diff --git a/spec/views/questions/index.html.haml_spec.rb b/spec/views/questions/index.html.haml_spec.rb new file mode 100644 index 00000000..4950a576 --- /dev/null +++ b/spec/views/questions/index.html.haml_spec.rb @@ -0,0 +1,18 @@ +require 'spec_helper' + +describe 'questions/index.html.haml' do + let(:question) { Fabricate(:question) } + + before(:each) do + # stub the partials and test them individually + stub_template "shared/_ask" => "" + stub_template "questions/_list" => "" + + view.stub! :will_paginate + end + + it "renders an autodiscovery link in for the head content" do + render :template => "questions/index.html.haml", :locals => {:collection => [question]} + view.content_for(:head).should have_selector("link", :href => questions_url(format: :atom)) + end +end From 69843da82e7b716e0014c803ea66de61261e9f50 Mon Sep 17 00:00:00 2001 From: Tobias Pfeiffer Date: Sat, 29 Dec 2012 12:15:36 +0100 Subject: [PATCH 066/161] Hopefully fixing the Travis Build. Adding the mongoDB service to the .travis.yml --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 69338f37..9d6420de 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,6 @@ script: "rake spec && rake cucumber" rvm: 1.9.2 +services: mongodb notifications: irc: "irc.freenode.org#hacketyhack" From 138f167063c41deb95ce3e7d91a3f849b59601d9 Mon Sep 17 00:00:00 2001 From: Tobias Pfeiffer Date: Sat, 29 Dec 2012 12:19:41 +0100 Subject: [PATCH 067/161] Add myself to the travis email notifications. --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index 9d6420de..13cd7a2e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,5 +2,7 @@ script: "rake spec && rake cucumber" rvm: 1.9.2 services: mongodb notifications: + email: + - tobias.pfeiffer@student.hpi.uni-potsdam.de irc: "irc.freenode.org#hacketyhack" From afbada32b884261a7396dda9e50cb989957e5960 Mon Sep 17 00:00:00 2001 From: Tobias Pfeiffer Date: Sat, 29 Dec 2012 12:21:22 +0100 Subject: [PATCH 068/161] Added language: ruby (travis-lint complained) --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 13cd7a2e..7cab9e93 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,3 +1,4 @@ +language: ruby script: "rake spec && rake cucumber" rvm: 1.9.2 services: mongodb From 823b89b3edbc902e8380003664082818515f45c0 Mon Sep 17 00:00:00 2001 From: Kalon Hinds Date: Sun, 30 Dec 2012 23:17:44 -0500 Subject: [PATCH 069/161] added an atom feed link for questions --- app/assets/images/feed_icon.png | Bin 0 -> 3221 bytes app/assets/stylesheets/layout.css.scss | 25 ++++++++++++++++++++++++ app/views/layouts/application.html.haml | 2 ++ app/views/questions/index.html.haml | 3 +++ 4 files changed, 30 insertions(+) create mode 100644 app/assets/images/feed_icon.png diff --git a/app/assets/images/feed_icon.png b/app/assets/images/feed_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..d384eac7b59c0c150157e2c48f38216e0ae90660 GIT binary patch literal 3221 zcmV;G3~KXKLZ*U+IBfRsybQWXdwQbLP>6pAqfylh#{fb6;Z(vMMVS~$e@S=j*ftg6;Uhf59&ghTmgWD0l;*T zI709Y^p6lP1rIRMx#05C~cW=H_Aw*bJ-5DT&Z2n+x)QHX^p z00esgV8|mQcmRZ%02D^@S3L16t`O%c004NIvOKvYIYoh62rY33S640`D9%Y2D-rV&neh&#Q1i z007~1e$oCcFS8neI|hJl{-P!B1ZZ9hpmq0)X0i`JwE&>$+E?>%_LC6RbVIkUx0b+_+BaR3cnT7Zv!AJxW zizFb)h!jyGOOZ85F;a?DAXP{m@;!0_IfqH8(HlgRxt7s3}k3K`kFu>>-2Q$QMFfPW!La{h336o>X zu_CMttHv6zR;&ZNiS=X8v3CR#fknUxHUxJ0uoBa_M6WNWeqIg~6QE69c9o#eyhGvpiOA@W-aonk<7r1(?fC{oI5N*U!4 zfg=2N-7=cNnjjOr{yriy6mMFgG#l znCF=fnQv8CDz++o6_Lscl}eQ+l^ZHARH>?_s@|##Rr6KLRFA1%Q+=*RRWnoLsR`7U zt5vFIcfW3@?wFpwUVxrVZ>QdQz32KIeJ}k~{cZZE^+ya? z2D1z#2HOnI7(B%_ac?{wFUQ;QQA1tBKtrWrm0_3Rgps+?Jfqb{jYbcQX~taRB;#$y zZN{S}1|}gUOHJxc?wV3fxuz+mJ4`!F$IZ;mqRrNsHJd##*D~ju=bP7?-?v~|cv>vB zsJ6IeNwVZxrdjT`yl#bBIa#GxRa#xMMy;K#CDyyGyQdMSxlWT#tDe?p!?5wT$+oGt z8L;Kp2HUQ-ZMJ=3XJQv;x5ci*?vuTfeY$;({XGW_huIFR9a(?@3)XSs8O^N5RyOM=TTmp(3=8^+zpz2r)C z^>JO{deZfso3oq3?Wo(Y?l$ge?uXo;%ru`Vo>?<<(8I_>;8Eq#KMS9gFl*neeosSB zfoHYnBQIkwkyowPu(zdms`p{<7e4kra-ZWq<2*OsGTvEV%s0Td$hXT+!*8Bnh2KMe zBmZRodjHV?r+_5^X9J0WL4jKW`}lf%A-|44I@@LTvf1rHjG(ze6+w@Jt%Bvjts!X0 z?2xS?_ve_-kiKB_KiJlZ$9G`c^=E@oNG)mWWaNo-3TIW8)$Hg0Ub-~8?KhvJ>$ z3*&nim@mj(aCxE5!t{lw7O5^0EIO7zOo&c6l<+|iDySBWCGrz@C5{St!X3hAA}`T4 z(TLbXTq+(;@<=L8dXnssyft|w#WSTW<++3>sgS%(4NTpeI-VAqb|7ssJvzNHgOZVu zaYCvgO_R1~>SyL=cFU|~g|hy|Zi}}s9+d~lYqOB71z9Z$wnC=pR9Yz4DhIM>Wmjgu z&56o6maCpC&F##y%G;1PobR9i?GnNg;gYtchD%p19a!eQtZF&3JaKv33gZ<8D~47E ztUS1iwkmDaPpj=$m#%)jCVEY4fnLGNg2A-`YwHVD3gv};>)hAvT~AmqS>Lr``i7kw zJ{5_It`yrBmlc25DBO7E8;5VoznR>Ww5hAaxn$2~(q`%A-YuS64wkBy=9dm`4cXeX z4c}I@?e+FW+b@^RDBHV(wnMq2zdX3SWv9u`%{xC-q*U}&`cyXV(%rRT*Z6MH?i+i& z_B8C(+grT%{XWUQ+f@NoP1R=AW&26{v-dx)iK^-Nmiuj8txj!m?Z*Ss1N{dh4z}01 z)YTo*JycSU)+_5r4#yw9{+;i4Ee$peRgIj+;v;ZGdF1K$3E%e~4LaI(jC-u%2h$&R z9cLXcYC@Xwnns&bn)_Q~Te?roKGD|d-g^8;+aC{{G(1^(O7m37Y1-+6)01cN&y1aw zoqc{T`P^XJqPBbIW6s}d4{z_f5Om?vMgNQEJG?v2T=KYd^0M3I6IZxbny)%vZR&LD zJpPl@Psh8QyPB@KTx+@RdcC!KX7}kEo;S|j^u2lU7XQ}Oo;f|;z4Ll+_r>@1-xl3| zawq-H%e&ckC+@AhPrP6BKT#_XdT7&;F71j}Joy zkC~6lh7E@6o;W@^IpRNZ{ptLtL(gQ-CY~4mqW;US7Zxvm_|@yz&e53Bp_lTPlfP|z zrTyx_>lv@x#=^!PzR7qqF<$gm`|ZJZ+;<)Cqu&ot2z=0000WV@Og>004R=004l4008;_004mL004C`008P>0026e000+nl3&F} z0005NNklQnQ{vjnUS`+x?-uLPUEod!hzs!W zbxA54JA{MXj1L8k>#;L2fW@_6vrpcX697+dMO=2;Zoz5(#jH9!`}jSYo?jDy_<%oo zBOWq#fvIdI;o2Y~uCkrq`WMsA-+cZ}M)jPe-mc32-0c?y8P#)=Tm3n^Kh|~v)#piH zKCi~+A751Z{HOU^-r{|JBM&fkAppRqWjoPkVaaOflbNDSW{R?8HFSXcV_^dzySy0% zh@9;)0M@sf?Jse9!Ah;v8m!bBOfOg|fZ=d&3BcOi0U#3U`2bMw1n4By=SdD~KElCn z00O<9^q}UWf3J6iSg1Jq#EdBuGo} @content_class} = yield diff --git a/app/views/questions/index.html.haml b/app/views/questions/index.html.haml index 023ee08c..82fbbcbe 100644 --- a/app/views/questions/index.html.haml +++ b/app/views/questions/index.html.haml @@ -15,6 +15,9 @@ - else = render :partial => "shared/support_blurb" +- content_for :feed do + = link_to "Feed", questions_url(format: :atom) + %ul.questions = render :partial => "list", :collection => collection From 117277528ebe982d9f778e77f8a1fb3388cc1728 Mon Sep 17 00:00:00 2001 From: Kalon Hinds Date: Wed, 2 Jan 2013 17:20:22 -0500 Subject: [PATCH 070/161] fixed pagination formatting of disabled buttons and current page --- app/assets/stylesheets/lib/bootstrap/patterns.scss | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/assets/stylesheets/lib/bootstrap/patterns.scss b/app/assets/stylesheets/lib/bootstrap/patterns.scss index 081eab04..2a6ae7fd 100644 --- a/app/assets/stylesheets/lib/bootstrap/patterns.scss +++ b/app/assets/stylesheets/lib/bootstrap/patterns.scss @@ -603,9 +603,10 @@ input[type=submit].btn { li { display: inline; } - a { + a, em, .disabled { float: left; padding: 0 14px; + font-style: normal; line-height: ($baseline * 2) - 2; border-right: 1px solid; border-right-color: #ddd; From eb1fe059487069932eec9938e9226b97b3d11faa Mon Sep 17 00:00:00 2001 From: Steve Klabnik Date: Thu, 10 Jan 2013 13:29:45 -0500 Subject: [PATCH 071/161] Fix for CVE-2013-0156 --- config/initializers/cve_fix.rb | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 config/initializers/cve_fix.rb diff --git a/config/initializers/cve_fix.rb b/config/initializers/cve_fix.rb new file mode 100644 index 00000000..f8788d01 --- /dev/null +++ b/config/initializers/cve_fix.rb @@ -0,0 +1,2 @@ +ActionDispatch::ParamsParser::DEFAULT_PARSERS.delete(Mime::XML) + From 72af831087cd1a6aca065047d048eadccd369476 Mon Sep 17 00:00:00 2001 From: Steve Klabnik Date: Thu, 10 Jan 2013 13:46:48 -0500 Subject: [PATCH 072/161] update rails due to the two CVEs --- Gemfile | 2 +- Gemfile.lock | 265 ++++++++++++++++++++++++++------------------------- 2 files changed, 134 insertions(+), 133 deletions(-) diff --git a/Gemfile b/Gemfile index 524a22ea..6527c8a3 100644 --- a/Gemfile +++ b/Gemfile @@ -1,6 +1,6 @@ source 'http://rubygems.org' -gem 'rails', '3.1.0' +gem 'rails', '3.1.10' gem 'json' gem 'hackety_hack-lessons', '~> 1.1', :require => 'hackety_hack/lessons' diff --git a/Gemfile.lock b/Gemfile.lock index 2f91d729..79b20c75 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -15,219 +15,220 @@ GIT GEM remote: http://rubygems.org/ specs: - actionmailer (3.1.0) - actionpack (= 3.1.0) - mail (~> 2.3.0) - actionpack (3.1.0) - activemodel (= 3.1.0) - activesupport (= 3.1.0) + actionmailer (3.1.10) + actionpack (= 3.1.10) + mail (~> 2.3.3) + actionpack (3.1.10) + activemodel (= 3.1.10) + activesupport (= 3.1.10) builder (~> 3.0.0) erubis (~> 2.7.0) i18n (~> 0.6) - rack (~> 1.3.2) - rack-cache (~> 1.0.3) + rack (~> 1.3.6) + rack-cache (~> 1.2) rack-mount (~> 0.8.2) rack-test (~> 0.6.1) - sprockets (~> 2.0.0) - activemodel (3.1.0) - activesupport (= 3.1.0) - bcrypt-ruby (~> 3.0.0) + sprockets (~> 2.0.4) + activemodel (3.1.10) + activesupport (= 3.1.10) builder (~> 3.0.0) i18n (~> 0.6) - activerecord (3.1.0) - activemodel (= 3.1.0) - activesupport (= 3.1.0) - arel (~> 2.2.1) + activerecord (3.1.10) + activemodel (= 3.1.10) + activesupport (= 3.1.10) + arel (~> 2.2.3) tzinfo (~> 0.3.29) - activeresource (3.1.0) - activemodel (= 3.1.0) - activesupport (= 3.1.0) - activesupport (3.1.0) - multi_json (~> 1.0) - addressable (2.2.6) - arel (2.2.1) + activeresource (3.1.10) + activemodel (= 3.1.10) + activesupport (= 3.1.10) + activesupport (3.1.10) + multi_json (>= 1.0, < 1.3) + addressable (2.3.2) + arel (2.2.3) bcrypt-ruby (3.0.1) - bson (1.5.2) - bson_ext (1.5.2) - bson (= 1.5.2) - builder (3.0.0) - cancan (1.6.7) - capybara (1.1.2) + bson (1.8.1) + bson_ext (1.8.1) + bson (~> 1.8.1) + builder (3.0.4) + cancan (1.6.8) + capybara (2.0.2) mime-types (>= 1.16) nokogiri (>= 1.3.3) rack (>= 1.0.0) rack-test (>= 0.5.4) selenium-webdriver (~> 2.0) - xpath (~> 0.1.4) - childprocess (0.3.0) - ffi (~> 1.0.6) - coderay (1.0.5) + xpath (~> 1.0.0) + childprocess (0.3.6) + ffi (~> 1.0, >= 1.0.6) + coderay (1.0.8) coffee-rails (3.1.1) coffee-script (>= 2.2.0) railties (~> 3.1.0) coffee-script (2.2.0) coffee-script-source execjs - coffee-script-source (1.2.0) - cucumber (1.1.4) + coffee-script-source (1.4.0) + cucumber (1.2.1) builder (>= 2.1.2) - diff-lcs (>= 1.1.2) - gherkin (~> 2.7.1) + diff-lcs (>= 1.1.3) + gherkin (~> 2.11.0) json (>= 1.4.6) - term-ansicolor (>= 1.0.6) - cucumber-rails (1.2.1) + cucumber-rails (1.3.0) capybara (>= 1.1.2) - cucumber (>= 1.1.3) + cucumber (>= 1.1.8) nokogiri (>= 1.5.0) - database_cleaner (0.7.1) - devise (1.5.3) + database_cleaner (0.9.1) + devise (2.2.0) bcrypt-ruby (~> 3.0) - orm_adapter (~> 0.0.3) - warden (~> 1.1) + orm_adapter (~> 0.1) + railties (~> 3.1) + warden (~> 1.2.1) diff-lcs (1.1.3) erubis (2.7.0) - execjs (1.3.0) + execjs (1.4.0) multi_json (~> 1.0) - fabrication (1.2.0) - faker (1.0.1) - i18n (~> 0.4) - ffi (1.0.11) - gherkin (2.7.6) + fabrication (2.5.4) + faker (1.1.2) + i18n (~> 0.5) + ffi (1.3.1) + gherkin (2.11.5) json (>= 1.4.6) hackety_hack-lessons (1.1.2) metadown - haml (3.1.4) - haml-rails (0.3.4) - actionpack (~> 3.0) - activesupport (~> 3.0) - haml (~> 3.0) - railties (~> 3.0) + haml (3.1.7) + haml-rails (0.3.5) + actionpack (>= 3.1, < 4.1) + activesupport (>= 3.1, < 4.1) + haml (~> 3.1) + railties (>= 3.1, < 4.1) has_scope (0.5.1) hike (1.2.1) - i18n (0.6.0) - inherited_resources (1.3.0) + i18n (0.6.1) + inherited_resources (1.3.1) has_scope (~> 0.5.0) - responders (~> 0.6.0) + responders (~> 0.6) jnunemaker-validatable (1.8.4) activesupport (>= 2.3.4) - jquery-rails (1.0.19) - railties (~> 3.0) - thor (~> 0.14) - json (1.6.5) - kgio (2.7.2) - launchy (2.0.5) - addressable (~> 2.2.6) - mail (2.3.0) + jquery-rails (2.1.4) + railties (>= 3.0, < 5.0) + thor (>= 0.14, < 2.0) + json (1.7.6) + kgio (2.7.4) + launchy (2.1.2) + addressable (~> 2.3) + libwebsocket (0.1.7.1) + addressable + websocket + mail (2.3.3) i18n (>= 0.4.0) mime-types (~> 1.16) treetop (~> 1.4.8) metaclass (0.0.1) metadown (1.0.1) redcarpet - method_source (0.7.0) - mime-types (1.17.2) - mm-devise (1.3) + method_source (0.8.1) + mime-types (1.19) + mm-devise (2.0) devise (>= 1.2) mongo_mapper (>= 0.9.0) - mocha (0.10.3) + mocha (0.13.1) metaclass (~> 0.0.1) - mongo (1.5.2) - bson (= 1.5.2) - mongo_mapper (0.10.1) + mongo (1.8.1) + bson (~> 1.8.1) + mongo_mapper (0.12.0) activemodel (~> 3.0) activesupport (~> 3.0) - plucky (~> 0.4.0) - multi_json (1.0.4) - nokogiri (1.5.0) - orm_adapter (0.0.6) - pg (0.12.2) - plucky (0.4.4) + plucky (~> 0.5.2) + multi_json (1.2.0) + nokogiri (1.5.6) + orm_adapter (0.4.0) + pg (0.14.1) + plucky (0.5.2) mongo (~> 1.5) polyglot (0.3.3) - pry (0.9.8) + pry (0.9.10) coderay (~> 1.0.5) - method_source (~> 0.7) - slop (>= 2.4.3, < 3) - rack (1.3.6) - rack-cache (1.0.3) + method_source (~> 0.8) + slop (~> 3.3.1) + rack (1.3.8) + rack-cache (1.2) rack (>= 0.4) rack-mount (0.8.3) rack (>= 1.0.0) rack-ssl (1.3.2) rack - rack-test (0.6.1) + rack-test (0.6.2) rack (>= 1.0) - rails (3.1.0) - actionmailer (= 3.1.0) - actionpack (= 3.1.0) - activerecord (= 3.1.0) - activeresource (= 3.1.0) - activesupport (= 3.1.0) + rails (3.1.10) + actionmailer (= 3.1.10) + actionpack (= 3.1.10) + activerecord (= 3.1.10) + activeresource (= 3.1.10) + activesupport (= 3.1.10) bundler (~> 1.0) - railties (= 3.1.0) - railties (3.1.0) - actionpack (= 3.1.0) - activesupport (= 3.1.0) + railties (= 3.1.10) + railties (3.1.10) + actionpack (= 3.1.10) + activesupport (= 3.1.10) rack-ssl (~> 1.3.2) rake (>= 0.8.7) rdoc (~> 3.4) thor (~> 0.14.6) - raindrops (0.8.0) - rake (0.9.2.2) + raindrops (0.10.0) + rake (10.0.3) rdiscount (1.6.8) rdoc (3.12) json (~> 1.4) - redcarpet (2.1.0) - responders (0.6.5) - rspec (2.8.0) - rspec-core (~> 2.8.0) - rspec-expectations (~> 2.8.0) - rspec-mocks (~> 2.8.0) - rspec-core (2.8.0) - rspec-expectations (2.8.0) - diff-lcs (~> 1.1.2) - rspec-mocks (2.8.0) - rspec-rails (2.8.1) + redcarpet (2.2.2) + responders (0.9.3) + railties (~> 3.1) + rspec-core (2.12.2) + rspec-expectations (2.12.1) + diff-lcs (~> 1.1.3) + rspec-mocks (2.12.1) + rspec-rails (2.12.1) actionpack (>= 3.0) activesupport (>= 3.0) railties (>= 3.0) - rspec (~> 2.8.0) - rubyzip (0.9.5) - sass (3.1.12) - sass-rails (3.1.5) + rspec-core (~> 2.12.0) + rspec-expectations (~> 2.12.0) + rspec-mocks (~> 2.12.0) + rubyzip (0.9.9) + sass (3.2.5) + sass-rails (3.1.6) actionpack (~> 3.1.0) railties (~> 3.1.0) - sass (~> 3.1.10) + sass (>= 3.1.10) tilt (~> 1.3.2) - selenium-webdriver (2.17.0) + selenium-webdriver (2.27.2) childprocess (>= 0.2.5) - ffi (~> 1.0.9) - multi_json (~> 1.0.4) + libwebsocket (~> 0.1.3) + multi_json (~> 1.0) rubyzip - slop (2.4.3) - sprockets (2.0.3) + slop (3.3.3) + sprockets (2.0.4) hike (~> 1.2) rack (~> 1.0) tilt (~> 1.1, != 1.3.0) - sqlite3 (1.3.5) - term-ansicolor (1.0.7) + sqlite3 (1.3.6) thor (0.14.6) tilt (1.3.3) - treetop (1.4.10) + treetop (1.4.12) polyglot polyglot (>= 0.3.1) - tzinfo (0.3.31) - uglifier (1.2.2) + tzinfo (0.3.35) + uglifier (1.3.0) execjs (>= 0.3.0) - multi_json (>= 1.0.2) - unicorn (4.1.1) - kgio (~> 2.4) + multi_json (~> 1.0, >= 1.0.2) + unicorn (4.5.0) + kgio (~> 2.6) rack - raindrops (~> 0.6) - warden (1.1.0) + raindrops (~> 0.7) + warden (1.2.1) rack (>= 1.0) - will_paginate (3.0.2) - xpath (0.1.4) + websocket (1.0.6) + will_paginate (3.0.4) + xpath (1.0.0) nokogiri (~> 1.3) PLATFORMS @@ -254,7 +255,7 @@ DEPENDENCIES mongo_mapper pg pry - rails (= 3.1.0) + rails (= 3.1.10) rdiscount rspec-rails sass-rails (~> 3.1.0) From 7a84abc58f334d77d2f072e64250cddb7ee59867 Mon Sep 17 00:00:00 2001 From: James Gifford Date: Thu, 10 Jan 2013 22:12:53 -0500 Subject: [PATCH 073/161] [ci-skip] added @jrgifford to the broke build list. --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 7cab9e93..35b33f7f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,5 +5,6 @@ services: mongodb notifications: email: - tobias.pfeiffer@student.hpi.uni-potsdam.de + - james+travis-ci-broken@jamesrgifford.com irc: "irc.freenode.org#hacketyhack" From ea93dd05922e2b2d62d47df116038558bde94ad4 Mon Sep 17 00:00:00 2001 From: Kalon Hinds Date: Fri, 11 Jan 2013 11:16:40 -0500 Subject: [PATCH 074/161] added my email for travis-ci notifications --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 7cab9e93..13d26c6d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,5 +5,6 @@ services: mongodb notifications: email: - tobias.pfeiffer@student.hpi.uni-potsdam.de + - kh@kalonhinds.com irc: "irc.freenode.org#hacketyhack" From 51ed2f53e6730e8172a2c6bee6daf34af4515e8d Mon Sep 17 00:00:00 2001 From: James Gifford Date: Fri, 11 Jan 2013 15:37:07 -0500 Subject: [PATCH 075/161] Revert "update rails due to the two CVEs" This reverts commit 72af831087cd1a6aca065047d048eadccd369476. --- Gemfile | 2 +- Gemfile.lock | 265 +++++++++++++++++++++++++-------------------------- 2 files changed, 133 insertions(+), 134 deletions(-) diff --git a/Gemfile b/Gemfile index 6527c8a3..524a22ea 100644 --- a/Gemfile +++ b/Gemfile @@ -1,6 +1,6 @@ source 'http://rubygems.org' -gem 'rails', '3.1.10' +gem 'rails', '3.1.0' gem 'json' gem 'hackety_hack-lessons', '~> 1.1', :require => 'hackety_hack/lessons' diff --git a/Gemfile.lock b/Gemfile.lock index 79b20c75..2f91d729 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -15,220 +15,219 @@ GIT GEM remote: http://rubygems.org/ specs: - actionmailer (3.1.10) - actionpack (= 3.1.10) - mail (~> 2.3.3) - actionpack (3.1.10) - activemodel (= 3.1.10) - activesupport (= 3.1.10) + actionmailer (3.1.0) + actionpack (= 3.1.0) + mail (~> 2.3.0) + actionpack (3.1.0) + activemodel (= 3.1.0) + activesupport (= 3.1.0) builder (~> 3.0.0) erubis (~> 2.7.0) i18n (~> 0.6) - rack (~> 1.3.6) - rack-cache (~> 1.2) + rack (~> 1.3.2) + rack-cache (~> 1.0.3) rack-mount (~> 0.8.2) rack-test (~> 0.6.1) - sprockets (~> 2.0.4) - activemodel (3.1.10) - activesupport (= 3.1.10) + sprockets (~> 2.0.0) + activemodel (3.1.0) + activesupport (= 3.1.0) + bcrypt-ruby (~> 3.0.0) builder (~> 3.0.0) i18n (~> 0.6) - activerecord (3.1.10) - activemodel (= 3.1.10) - activesupport (= 3.1.10) - arel (~> 2.2.3) + activerecord (3.1.0) + activemodel (= 3.1.0) + activesupport (= 3.1.0) + arel (~> 2.2.1) tzinfo (~> 0.3.29) - activeresource (3.1.10) - activemodel (= 3.1.10) - activesupport (= 3.1.10) - activesupport (3.1.10) - multi_json (>= 1.0, < 1.3) - addressable (2.3.2) - arel (2.2.3) + activeresource (3.1.0) + activemodel (= 3.1.0) + activesupport (= 3.1.0) + activesupport (3.1.0) + multi_json (~> 1.0) + addressable (2.2.6) + arel (2.2.1) bcrypt-ruby (3.0.1) - bson (1.8.1) - bson_ext (1.8.1) - bson (~> 1.8.1) - builder (3.0.4) - cancan (1.6.8) - capybara (2.0.2) + bson (1.5.2) + bson_ext (1.5.2) + bson (= 1.5.2) + builder (3.0.0) + cancan (1.6.7) + capybara (1.1.2) mime-types (>= 1.16) nokogiri (>= 1.3.3) rack (>= 1.0.0) rack-test (>= 0.5.4) selenium-webdriver (~> 2.0) - xpath (~> 1.0.0) - childprocess (0.3.6) - ffi (~> 1.0, >= 1.0.6) - coderay (1.0.8) + xpath (~> 0.1.4) + childprocess (0.3.0) + ffi (~> 1.0.6) + coderay (1.0.5) coffee-rails (3.1.1) coffee-script (>= 2.2.0) railties (~> 3.1.0) coffee-script (2.2.0) coffee-script-source execjs - coffee-script-source (1.4.0) - cucumber (1.2.1) + coffee-script-source (1.2.0) + cucumber (1.1.4) builder (>= 2.1.2) - diff-lcs (>= 1.1.3) - gherkin (~> 2.11.0) + diff-lcs (>= 1.1.2) + gherkin (~> 2.7.1) json (>= 1.4.6) - cucumber-rails (1.3.0) + term-ansicolor (>= 1.0.6) + cucumber-rails (1.2.1) capybara (>= 1.1.2) - cucumber (>= 1.1.8) + cucumber (>= 1.1.3) nokogiri (>= 1.5.0) - database_cleaner (0.9.1) - devise (2.2.0) + database_cleaner (0.7.1) + devise (1.5.3) bcrypt-ruby (~> 3.0) - orm_adapter (~> 0.1) - railties (~> 3.1) - warden (~> 1.2.1) + orm_adapter (~> 0.0.3) + warden (~> 1.1) diff-lcs (1.1.3) erubis (2.7.0) - execjs (1.4.0) + execjs (1.3.0) multi_json (~> 1.0) - fabrication (2.5.4) - faker (1.1.2) - i18n (~> 0.5) - ffi (1.3.1) - gherkin (2.11.5) + fabrication (1.2.0) + faker (1.0.1) + i18n (~> 0.4) + ffi (1.0.11) + gherkin (2.7.6) json (>= 1.4.6) hackety_hack-lessons (1.1.2) metadown - haml (3.1.7) - haml-rails (0.3.5) - actionpack (>= 3.1, < 4.1) - activesupport (>= 3.1, < 4.1) - haml (~> 3.1) - railties (>= 3.1, < 4.1) + haml (3.1.4) + haml-rails (0.3.4) + actionpack (~> 3.0) + activesupport (~> 3.0) + haml (~> 3.0) + railties (~> 3.0) has_scope (0.5.1) hike (1.2.1) - i18n (0.6.1) - inherited_resources (1.3.1) + i18n (0.6.0) + inherited_resources (1.3.0) has_scope (~> 0.5.0) - responders (~> 0.6) + responders (~> 0.6.0) jnunemaker-validatable (1.8.4) activesupport (>= 2.3.4) - jquery-rails (2.1.4) - railties (>= 3.0, < 5.0) - thor (>= 0.14, < 2.0) - json (1.7.6) - kgio (2.7.4) - launchy (2.1.2) - addressable (~> 2.3) - libwebsocket (0.1.7.1) - addressable - websocket - mail (2.3.3) + jquery-rails (1.0.19) + railties (~> 3.0) + thor (~> 0.14) + json (1.6.5) + kgio (2.7.2) + launchy (2.0.5) + addressable (~> 2.2.6) + mail (2.3.0) i18n (>= 0.4.0) mime-types (~> 1.16) treetop (~> 1.4.8) metaclass (0.0.1) metadown (1.0.1) redcarpet - method_source (0.8.1) - mime-types (1.19) - mm-devise (2.0) + method_source (0.7.0) + mime-types (1.17.2) + mm-devise (1.3) devise (>= 1.2) mongo_mapper (>= 0.9.0) - mocha (0.13.1) + mocha (0.10.3) metaclass (~> 0.0.1) - mongo (1.8.1) - bson (~> 1.8.1) - mongo_mapper (0.12.0) + mongo (1.5.2) + bson (= 1.5.2) + mongo_mapper (0.10.1) activemodel (~> 3.0) activesupport (~> 3.0) - plucky (~> 0.5.2) - multi_json (1.2.0) - nokogiri (1.5.6) - orm_adapter (0.4.0) - pg (0.14.1) - plucky (0.5.2) + plucky (~> 0.4.0) + multi_json (1.0.4) + nokogiri (1.5.0) + orm_adapter (0.0.6) + pg (0.12.2) + plucky (0.4.4) mongo (~> 1.5) polyglot (0.3.3) - pry (0.9.10) + pry (0.9.8) coderay (~> 1.0.5) - method_source (~> 0.8) - slop (~> 3.3.1) - rack (1.3.8) - rack-cache (1.2) + method_source (~> 0.7) + slop (>= 2.4.3, < 3) + rack (1.3.6) + rack-cache (1.0.3) rack (>= 0.4) rack-mount (0.8.3) rack (>= 1.0.0) rack-ssl (1.3.2) rack - rack-test (0.6.2) + rack-test (0.6.1) rack (>= 1.0) - rails (3.1.10) - actionmailer (= 3.1.10) - actionpack (= 3.1.10) - activerecord (= 3.1.10) - activeresource (= 3.1.10) - activesupport (= 3.1.10) + rails (3.1.0) + actionmailer (= 3.1.0) + actionpack (= 3.1.0) + activerecord (= 3.1.0) + activeresource (= 3.1.0) + activesupport (= 3.1.0) bundler (~> 1.0) - railties (= 3.1.10) - railties (3.1.10) - actionpack (= 3.1.10) - activesupport (= 3.1.10) + railties (= 3.1.0) + railties (3.1.0) + actionpack (= 3.1.0) + activesupport (= 3.1.0) rack-ssl (~> 1.3.2) rake (>= 0.8.7) rdoc (~> 3.4) thor (~> 0.14.6) - raindrops (0.10.0) - rake (10.0.3) + raindrops (0.8.0) + rake (0.9.2.2) rdiscount (1.6.8) rdoc (3.12) json (~> 1.4) - redcarpet (2.2.2) - responders (0.9.3) - railties (~> 3.1) - rspec-core (2.12.2) - rspec-expectations (2.12.1) - diff-lcs (~> 1.1.3) - rspec-mocks (2.12.1) - rspec-rails (2.12.1) + redcarpet (2.1.0) + responders (0.6.5) + rspec (2.8.0) + rspec-core (~> 2.8.0) + rspec-expectations (~> 2.8.0) + rspec-mocks (~> 2.8.0) + rspec-core (2.8.0) + rspec-expectations (2.8.0) + diff-lcs (~> 1.1.2) + rspec-mocks (2.8.0) + rspec-rails (2.8.1) actionpack (>= 3.0) activesupport (>= 3.0) railties (>= 3.0) - rspec-core (~> 2.12.0) - rspec-expectations (~> 2.12.0) - rspec-mocks (~> 2.12.0) - rubyzip (0.9.9) - sass (3.2.5) - sass-rails (3.1.6) + rspec (~> 2.8.0) + rubyzip (0.9.5) + sass (3.1.12) + sass-rails (3.1.5) actionpack (~> 3.1.0) railties (~> 3.1.0) - sass (>= 3.1.10) + sass (~> 3.1.10) tilt (~> 1.3.2) - selenium-webdriver (2.27.2) + selenium-webdriver (2.17.0) childprocess (>= 0.2.5) - libwebsocket (~> 0.1.3) - multi_json (~> 1.0) + ffi (~> 1.0.9) + multi_json (~> 1.0.4) rubyzip - slop (3.3.3) - sprockets (2.0.4) + slop (2.4.3) + sprockets (2.0.3) hike (~> 1.2) rack (~> 1.0) tilt (~> 1.1, != 1.3.0) - sqlite3 (1.3.6) + sqlite3 (1.3.5) + term-ansicolor (1.0.7) thor (0.14.6) tilt (1.3.3) - treetop (1.4.12) + treetop (1.4.10) polyglot polyglot (>= 0.3.1) - tzinfo (0.3.35) - uglifier (1.3.0) + tzinfo (0.3.31) + uglifier (1.2.2) execjs (>= 0.3.0) - multi_json (~> 1.0, >= 1.0.2) - unicorn (4.5.0) - kgio (~> 2.6) + multi_json (>= 1.0.2) + unicorn (4.1.1) + kgio (~> 2.4) rack - raindrops (~> 0.7) - warden (1.2.1) + raindrops (~> 0.6) + warden (1.1.0) rack (>= 1.0) - websocket (1.0.6) - will_paginate (3.0.4) - xpath (1.0.0) + will_paginate (3.0.2) + xpath (0.1.4) nokogiri (~> 1.3) PLATFORMS @@ -255,7 +254,7 @@ DEPENDENCIES mongo_mapper pg pry - rails (= 3.1.10) + rails (= 3.1.0) rdiscount rspec-rails sass-rails (~> 3.1.0) From 560910859c08093b0660eb9de40d4aff0b0c3d60 Mon Sep 17 00:00:00 2001 From: James Gifford Date: Fri, 11 Jan 2013 15:41:19 -0500 Subject: [PATCH 076/161] Rolled back @steveklabnik's commit, updated rails, ran specs. YAY SECURITY UPDATES! :metal: --- Gemfile | 2 +- Gemfile.lock | 89 ++++++++++++++++++++++++++-------------------------- 2 files changed, 45 insertions(+), 46 deletions(-) diff --git a/Gemfile b/Gemfile index 524a22ea..6527c8a3 100644 --- a/Gemfile +++ b/Gemfile @@ -1,6 +1,6 @@ source 'http://rubygems.org' -gem 'rails', '3.1.0' +gem 'rails', '3.1.10' gem 'json' gem 'hackety_hack-lessons', '~> 1.1', :require => 'hackety_hack/lessons' diff --git a/Gemfile.lock b/Gemfile.lock index 2f91d729..957cd33f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -15,42 +15,41 @@ GIT GEM remote: http://rubygems.org/ specs: - actionmailer (3.1.0) - actionpack (= 3.1.0) - mail (~> 2.3.0) - actionpack (3.1.0) - activemodel (= 3.1.0) - activesupport (= 3.1.0) + actionmailer (3.1.10) + actionpack (= 3.1.10) + mail (~> 2.3.3) + actionpack (3.1.10) + activemodel (= 3.1.10) + activesupport (= 3.1.10) builder (~> 3.0.0) erubis (~> 2.7.0) i18n (~> 0.6) - rack (~> 1.3.2) - rack-cache (~> 1.0.3) + rack (~> 1.3.6) + rack-cache (~> 1.2) rack-mount (~> 0.8.2) rack-test (~> 0.6.1) - sprockets (~> 2.0.0) - activemodel (3.1.0) - activesupport (= 3.1.0) - bcrypt-ruby (~> 3.0.0) + sprockets (~> 2.0.4) + activemodel (3.1.10) + activesupport (= 3.1.10) builder (~> 3.0.0) i18n (~> 0.6) - activerecord (3.1.0) - activemodel (= 3.1.0) - activesupport (= 3.1.0) - arel (~> 2.2.1) + activerecord (3.1.10) + activemodel (= 3.1.10) + activesupport (= 3.1.10) + arel (~> 2.2.3) tzinfo (~> 0.3.29) - activeresource (3.1.0) - activemodel (= 3.1.0) - activesupport (= 3.1.0) - activesupport (3.1.0) - multi_json (~> 1.0) + activeresource (3.1.10) + activemodel (= 3.1.10) + activesupport (= 3.1.10) + activesupport (3.1.10) + multi_json (>= 1.0, < 1.3) addressable (2.2.6) - arel (2.2.1) + arel (2.2.3) bcrypt-ruby (3.0.1) bson (1.5.2) bson_ext (1.5.2) bson (= 1.5.2) - builder (3.0.0) + builder (3.0.4) cancan (1.6.7) capybara (1.1.2) mime-types (>= 1.16) @@ -104,7 +103,7 @@ GEM railties (~> 3.0) has_scope (0.5.1) hike (1.2.1) - i18n (0.6.0) + i18n (0.6.1) inherited_resources (1.3.0) has_scope (~> 0.5.0) responders (~> 0.6.0) @@ -113,11 +112,11 @@ GEM jquery-rails (1.0.19) railties (~> 3.0) thor (~> 0.14) - json (1.6.5) + json (1.7.6) kgio (2.7.2) launchy (2.0.5) addressable (~> 2.2.6) - mail (2.3.0) + mail (2.3.3) i18n (>= 0.4.0) mime-types (~> 1.16) treetop (~> 1.4.8) @@ -125,7 +124,7 @@ GEM metadown (1.0.1) redcarpet method_source (0.7.0) - mime-types (1.17.2) + mime-types (1.19) mm-devise (1.3) devise (>= 1.2) mongo_mapper (>= 0.9.0) @@ -148,32 +147,32 @@ GEM coderay (~> 1.0.5) method_source (~> 0.7) slop (>= 2.4.3, < 3) - rack (1.3.6) - rack-cache (1.0.3) + rack (1.3.8) + rack-cache (1.2) rack (>= 0.4) rack-mount (0.8.3) rack (>= 1.0.0) rack-ssl (1.3.2) rack - rack-test (0.6.1) + rack-test (0.6.2) rack (>= 1.0) - rails (3.1.0) - actionmailer (= 3.1.0) - actionpack (= 3.1.0) - activerecord (= 3.1.0) - activeresource (= 3.1.0) - activesupport (= 3.1.0) + rails (3.1.10) + actionmailer (= 3.1.10) + actionpack (= 3.1.10) + activerecord (= 3.1.10) + activeresource (= 3.1.10) + activesupport (= 3.1.10) bundler (~> 1.0) - railties (= 3.1.0) - railties (3.1.0) - actionpack (= 3.1.0) - activesupport (= 3.1.0) + railties (= 3.1.10) + railties (3.1.10) + actionpack (= 3.1.10) + activesupport (= 3.1.10) rack-ssl (~> 1.3.2) rake (>= 0.8.7) rdoc (~> 3.4) thor (~> 0.14.6) raindrops (0.8.0) - rake (0.9.2.2) + rake (10.0.3) rdiscount (1.6.8) rdoc (3.12) json (~> 1.4) @@ -205,7 +204,7 @@ GEM multi_json (~> 1.0.4) rubyzip slop (2.4.3) - sprockets (2.0.3) + sprockets (2.0.4) hike (~> 1.2) rack (~> 1.0) tilt (~> 1.1, != 1.3.0) @@ -213,10 +212,10 @@ GEM term-ansicolor (1.0.7) thor (0.14.6) tilt (1.3.3) - treetop (1.4.10) + treetop (1.4.12) polyglot polyglot (>= 0.3.1) - tzinfo (0.3.31) + tzinfo (0.3.35) uglifier (1.2.2) execjs (>= 0.3.0) multi_json (>= 1.0.2) @@ -254,7 +253,7 @@ DEPENDENCIES mongo_mapper pg pry - rails (= 3.1.0) + rails (= 3.1.10) rdiscount rspec-rails sass-rails (~> 3.1.0) From 7e01eee29c460064d08999f82a518749e8951120 Mon Sep 17 00:00:00 2001 From: Jared Moody Date: Sun, 9 Dec 2012 12:56:30 -0800 Subject: [PATCH 077/161] use ruby 1.9.3 --- .rvmrc | 2 +- .travis.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.rvmrc b/.rvmrc index 7e673dc9..db5b03c7 100644 --- a/.rvmrc +++ b/.rvmrc @@ -1 +1 @@ -rvm use --create ruby-1.9.2-p290@hackety-hack.com +rvm use --create ruby-1.9.3-p327@hackety-hack.com diff --git a/.travis.yml b/.travis.yml index acbd5537..0100b3ce 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ language: ruby script: "rake spec && rake cucumber" -rvm: 1.9.2 +rvm: 1.9.3 services: mongodb notifications: email: From a2eb88ce6f3ca611028bc2b6ee78fbc2b5a08163 Mon Sep 17 00:00:00 2001 From: jaredmoody Date: Sun, 20 Jan 2013 18:58:56 -0800 Subject: [PATCH 078/161] Upgrade devise to 2.2.2, closes #141 --- Gemfile | 13 +++++-------- Gemfile.lock | 22 ++++++++++------------ app/models/user.rb | 18 ++++++++++++++++++ config/initializers/devise.rb | 13 +------------ config/locales/devise.en.yml | 8 ++++---- config/routes.rb | 3 ++- 6 files changed, 40 insertions(+), 37 deletions(-) diff --git a/Gemfile b/Gemfile index 6527c8a3..0b1b5025 100644 --- a/Gemfile +++ b/Gemfile @@ -13,30 +13,27 @@ gem 'bson_ext' # Gems used only for assets and not required # in production environments by default. group :assets do - gem 'sass-rails', " ~> 3.1.0" + gem 'sass-rails', "~> 3.1.0" gem 'coffee-rails', "~> 3.1.0" gem 'uglifier' end -gem 'jnunemaker-validatable', '>= 1.8.4' # Required by mm-devise -gem 'devise', '>= 1.2' -gem 'mm-devise', '>= 1.2' +gem "devise", "~> 2.2.2" +gem 'mm-devise', '~> 2.0' gem 'cancan' gem 'inherited_resources' -gem 'simple_form', :git => "https://github.com/bitzesty/bootstrap_form.git" -gem "semantic_menu", :git => "git://github.com/michaek/semantic_menu.git" +gem 'simple_form', git: "https://github.com/bitzesty/bootstrap_form.git" +gem "semantic_menu", git: "git://github.com/michaek/semantic_menu.git" gem 'will_paginate' # Pagination gem 'rdiscount' # Markdown - group :development do # Use unicorn as the web server gem 'unicorn' end - group :development, :test do gem 'fabrication' gem 'rspec-rails' diff --git a/Gemfile.lock b/Gemfile.lock index 957cd33f..859b21ac 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -79,10 +79,11 @@ GEM cucumber (>= 1.1.3) nokogiri (>= 1.5.0) database_cleaner (0.7.1) - devise (1.5.3) + devise (2.2.2) bcrypt-ruby (~> 3.0) - orm_adapter (~> 0.0.3) - warden (~> 1.1) + orm_adapter (~> 0.1) + railties (~> 3.1) + warden (~> 1.2.1) diff-lcs (1.1.3) erubis (2.7.0) execjs (1.3.0) @@ -107,8 +108,6 @@ GEM inherited_resources (1.3.0) has_scope (~> 0.5.0) responders (~> 0.6.0) - jnunemaker-validatable (1.8.4) - activesupport (>= 2.3.4) jquery-rails (1.0.19) railties (~> 3.0) thor (~> 0.14) @@ -125,7 +124,7 @@ GEM redcarpet method_source (0.7.0) mime-types (1.19) - mm-devise (1.3) + mm-devise (2.0) devise (>= 1.2) mongo_mapper (>= 0.9.0) mocha (0.10.3) @@ -138,7 +137,7 @@ GEM plucky (~> 0.4.0) multi_json (1.0.4) nokogiri (1.5.0) - orm_adapter (0.0.6) + orm_adapter (0.4.0) pg (0.12.2) plucky (0.4.4) mongo (~> 1.5) @@ -147,7 +146,7 @@ GEM coderay (~> 1.0.5) method_source (~> 0.7) slop (>= 2.4.3, < 3) - rack (1.3.8) + rack (1.3.9) rack-cache (1.2) rack (>= 0.4) rack-mount (0.8.3) @@ -223,7 +222,7 @@ GEM kgio (~> 2.4) rack raindrops (~> 0.6) - warden (1.1.0) + warden (1.2.1) rack (>= 1.0) will_paginate (3.0.2) xpath (0.1.4) @@ -238,17 +237,16 @@ DEPENDENCIES coffee-rails (~> 3.1.0) cucumber-rails database_cleaner - devise (>= 1.2) + devise (~> 2.2.2) fabrication faker hackety_hack-lessons (~> 1.1) haml-rails inherited_resources - jnunemaker-validatable (>= 1.8.4) jquery-rails json launchy - mm-devise (>= 1.2) + mm-devise (~> 2.0) mocha mongo_mapper pg diff --git a/app/models/user.rb b/app/models/user.rb index 5c1c686a..d03c5668 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -11,6 +11,24 @@ class User key :moderator, Boolean key :blog_poster, Boolean + ## Database authenticatable + key :email, :type => String, :null => false + key :encrypted_password, :type => String, :null => false + + ## Recoverable + key :reset_password_token, :type => String + key :reset_password_sent_at, :type => Time + + ## Rememberable + key :remember_created_at, :type => Time + + ## Trackable + key :sign_in_count, :type => Integer + key :current_sign_in_at, :type => Time + key :last_sign_in_at, :type => Time + key :current_sign_in_ip, :type => String + key :last_sign_in_ip, :type => String + many :questions many :answers diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb index dfb39d99..0b2e519b 100644 --- a/config/initializers/devise.rb +++ b/config/initializers/devise.rb @@ -73,7 +73,7 @@ # You can use this to let your user access some features of your application # without confirming the account, but blocking it after a certain period # (ie 2 days). - # config.confirm_within = 2.days + # config.allow_unconfirmed_access_for = 2.days # Defines which key will be used when confirming an account # config.confirmation_keys = [ :email ] @@ -82,16 +82,9 @@ # The time the user will be remembered without asking for credentials again. # config.remember_for = 2.weeks - # If true, a valid remember token can be re-used between multiple browsers. - # config.remember_across_browsers = true - # If true, extends the user's remember period when remembered via cookie. # config.extend_remember_period = false - # If true, uses the password salt as remember token. This should be turned - # to false if you are not using database authenticatable. - config.use_salt_as_remember_token = true - # Options to be passed to the created cookie. For instance, you can set # :secure => true in order to force SSL only cookies. # config.cookie_options = {} @@ -153,10 +146,6 @@ # Defines name of the authentication token params key # config.token_authentication_key = :auth_token - # If true, authentication through token does not store user in session and needs - # to be supplied on each request. Useful if you are using the token as API token. - # config.stateless_token = false - # ==> Scopes configuration # Turn scoped views on. Before rendering "sessions/new", it will first check for # "users/sessions/new". It's turned off by default because it's slower if you diff --git a/config/locales/devise.en.yml b/config/locales/devise.en.yml index a5cf3bf6..93016092 100644 --- a/config/locales/devise.en.yml +++ b/config/locales/devise.en.yml @@ -17,6 +17,7 @@ en: unauthenticated: 'You need to sign in or sign up before continuing.' unconfirmed: 'You have to confirm your account before continuing.' locked: 'Your account is locked.' + not_found_in_database: 'Invalid email or password.' invalid: 'Invalid email or password.' invalid_token: 'Invalid authentication token.' timeout: 'Your session expired, please sign in again to continue.' @@ -33,10 +34,9 @@ en: send_paranoid_instructions: 'If your e-mail exists on our database, you will receive an email with instructions about how to confirm your account in a few minutes.' confirmed: 'Your account was successfully confirmed. You are now signed in.' registrations: - signed_up: 'Welcome! You have signed up successfully.' - inactive_signed_up: 'You have signed up successfully. However, we could not sign you in because your account is %{reason}.' - updated: 'You updated your account successfully.' - destroyed: 'Bye! Your account was successfully cancelled. We hope to see you again soon.' + signed_up_but_unconfirmed: 'A message with a confirmation link has been sent to your email address. Please open the link to activate your account.' + signed_up_but_inactive: 'You have signed up successfully. However, we could not sign you in because your account is not yet activated.' + signed_up_but_locked: 'You have signed up successfully. However, we could not sign you in because your account is locked.' unlocks: send_instructions: 'You will receive an email with instructions about how to unlock your account in a few minutes.' unlocked: 'Your account was successfully unlocked. You are now signed in.' diff --git a/config/routes.rb b/config/routes.rb index 410a0336..08a561d8 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -31,7 +31,8 @@ resources :programs, :only => [:index, :show] - devise_for :users do + devise_for :users + devise_scope :user do get "login" => "devise/sessions#new", :as => "login" get "logout" => "devise/sessions#destroy", :as => "logout" end From 8c2e844ac3d839b222ae54a351f28215198602a9 Mon Sep 17 00:00:00 2001 From: "p.bjorklund@gmail.com" Date: Mon, 11 Feb 2013 14:43:59 +0100 Subject: [PATCH 079/161] Add another_blog_post fabricator --- spec/fabricators/blog_post_fabricator.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/spec/fabricators/blog_post_fabricator.rb b/spec/fabricators/blog_post_fabricator.rb index 561914bb..ff271066 100644 --- a/spec/fabricators/blog_post_fabricator.rb +++ b/spec/fabricators/blog_post_fabricator.rb @@ -2,3 +2,8 @@ content "Hello, world" title "Title" end + +Fabricator(:another_blog_post, from: :blog_post) do + content "World, Hello" + title "Eltit" +end From 6bf8669045b7f47b59df33e65a27fed63942c39a Mon Sep 17 00:00:00 2001 From: "p.bjorklund@gmail.com" Date: Mon, 11 Feb 2013 14:45:41 +0100 Subject: [PATCH 080/161] Use blog_index_path since blog_index does not exist --- app/controllers/blog_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/blog_controller.rb b/app/controllers/blog_controller.rb index ae9542b4..7f06d3be 100644 --- a/app/controllers/blog_controller.rb +++ b/app/controllers/blog_controller.rb @@ -10,13 +10,13 @@ def show end def admin - redirect_to blog_index unless current_user.blog_poster + redirect_to blog_index_path unless current_user.blog_poster @post = BlogPost.new @posts = BlogPost.all.reverse end def create - redirect_to blog_index unless current_user.blog_poster + redirect_to blog_index_path and return unless current_user.blog_poster @post = BlogPost.create(params[:blog_post]) redirect_to admin_blog_index_path, :notice => "Blog Post created!" end From ffe7a76c09e0150f79ebc4749f08e93d0d12ce11 Mon Sep 17 00:00:00 2001 From: "p.bjorklund@gmail.com" Date: Mon, 11 Feb 2013 14:45:51 +0100 Subject: [PATCH 081/161] Specs for BlogController --- spec/controllers/blog_controller_spec.rb | 99 ++++++++++++++++++++++++ 1 file changed, 99 insertions(+) diff --git a/spec/controllers/blog_controller_spec.rb b/spec/controllers/blog_controller_spec.rb index 2dda864e..8da8d9df 100644 --- a/spec/controllers/blog_controller_spec.rb +++ b/spec/controllers/blog_controller_spec.rb @@ -1,5 +1,104 @@ require 'spec_helper' describe BlogController do + let(:blog_post) { Fabricate(:blog_post) } + let(:another_blog_post) { Fabricate(:another_blog_post) } + describe('#index') do + it "gets index successfully" do + get :index + response.should be_successful + end + + describe("handles posts by") do + before(:each) do + blog_post + another_blog_post + get :index + @posts = assigns(:posts) + end + it "fetching posts" do + @posts.size.should == 2 + end + it "sorting them in reverse order" do + @posts.first.content[0].should > @posts.last.content[0] + end + end + end + + describe "#show" do + before(:each) do + blog_post + get :show, id: blog_post + end + it { response.should be_successful } + it { assigns(:post).should == blog_post } + end + + describe "#admin" do + context "when user is not signed in" do + before(:each) do + get :create + end + #TODO Should it not use signin_path? + it { response.should redirect_to(new_user_session_path) } + end + + context "when user is not an blog_poster" do + before(:each) do + blog_post + get :admin + end + it { response.should be_redirect } + it { assigns(:post).should be_nil } + it { assigns(:posts).should be_nil } + end + context "when user is a blog_poster" do + before(:each) do + sign_in Fabricate(:user, blog_poster: true) + blog_post + get :admin + end + it { response.should be_successful } + it { assigns(:post).should be_a_new(BlogPost) } + it { assigns(:posts).size.should == 1 } + end + end + + describe "#create" do + context "when user is not signed in" do + before(:each) do + get :create + end + #TODO Should it not use signin_path? + it { response.should redirect_to(new_user_session_path) } + end + + context "when user is not an blog_poster" do + before(:each) do + sign_in Fabricate(:user) + get :create + end + + it { response.should redirect_to(blog_index_path) } + + it { assigns(:post).should be_nil } + end + + context "when user is a blog_poster" do + before(:each) do + sign_in Fabricate(:user, blog_poster: true) + end + + it "redirects to admin_blog_index_path when user is blog_poster" do + post :create + response.should redirect_to(admin_blog_index_path) + end + + it "creates a new blogpost" do + ->{ post :create, blog_post: Fabricate.build(:blog_post).attributes } + .should change(BlogPost, :count).by(1) + end + end + end end From bb7ab0bfdfb323ff8bc8d1a0e78d2743dd7874b7 Mon Sep 17 00:00:00 2001 From: James Gifford Date: Mon, 11 Feb 2013 15:42:14 -0500 Subject: [PATCH 082/161] Updated rails --- .rvmrc | 2 +- Gemfile | 2 +- Gemfile.lock | 62 ++++++++++++++++++++++++++-------------------------- 3 files changed, 33 insertions(+), 33 deletions(-) diff --git a/.rvmrc b/.rvmrc index db5b03c7..751e0242 100644 --- a/.rvmrc +++ b/.rvmrc @@ -1 +1 @@ -rvm use --create ruby-1.9.3-p327@hackety-hack.com +rvm use --create ruby-1.9.3@hackety-hack.com diff --git a/Gemfile b/Gemfile index 0b1b5025..343d656d 100644 --- a/Gemfile +++ b/Gemfile @@ -1,6 +1,6 @@ source 'http://rubygems.org' -gem 'rails', '3.1.10' +gem 'rails', '3.1.11' gem 'json' gem 'hackety_hack-lessons', '~> 1.1', :require => 'hackety_hack/lessons' diff --git a/Gemfile.lock b/Gemfile.lock index 859b21ac..7ffccfa5 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -15,12 +15,12 @@ GIT GEM remote: http://rubygems.org/ specs: - actionmailer (3.1.10) - actionpack (= 3.1.10) + actionmailer (3.1.11) + actionpack (= 3.1.11) mail (~> 2.3.3) - actionpack (3.1.10) - activemodel (= 3.1.10) - activesupport (= 3.1.10) + actionpack (3.1.11) + activemodel (= 3.1.11) + activesupport (= 3.1.11) builder (~> 3.0.0) erubis (~> 2.7.0) i18n (~> 0.6) @@ -29,20 +29,20 @@ GEM rack-mount (~> 0.8.2) rack-test (~> 0.6.1) sprockets (~> 2.0.4) - activemodel (3.1.10) - activesupport (= 3.1.10) + activemodel (3.1.11) + activesupport (= 3.1.11) builder (~> 3.0.0) i18n (~> 0.6) - activerecord (3.1.10) - activemodel (= 3.1.10) - activesupport (= 3.1.10) + activerecord (3.1.11) + activemodel (= 3.1.11) + activesupport (= 3.1.11) arel (~> 2.2.3) tzinfo (~> 0.3.29) - activeresource (3.1.10) - activemodel (= 3.1.10) - activesupport (= 3.1.10) - activesupport (3.1.10) - multi_json (>= 1.0, < 1.3) + activeresource (3.1.11) + activemodel (= 3.1.11) + activesupport (= 3.1.11) + activesupport (3.1.11) + multi_json (~> 1.0) addressable (2.2.6) arel (2.2.3) bcrypt-ruby (3.0.1) @@ -111,7 +111,7 @@ GEM jquery-rails (1.0.19) railties (~> 3.0) thor (~> 0.14) - json (1.7.6) + json (1.7.7) kgio (2.7.2) launchy (2.0.5) addressable (~> 2.2.6) @@ -123,7 +123,7 @@ GEM metadown (1.0.1) redcarpet method_source (0.7.0) - mime-types (1.19) + mime-types (1.21) mm-devise (2.0) devise (>= 1.2) mongo_mapper (>= 0.9.0) @@ -146,26 +146,26 @@ GEM coderay (~> 1.0.5) method_source (~> 0.7) slop (>= 2.4.3, < 3) - rack (1.3.9) + rack (1.3.10) rack-cache (1.2) rack (>= 0.4) rack-mount (0.8.3) rack (>= 1.0.0) - rack-ssl (1.3.2) + rack-ssl (1.3.3) rack rack-test (0.6.2) rack (>= 1.0) - rails (3.1.10) - actionmailer (= 3.1.10) - actionpack (= 3.1.10) - activerecord (= 3.1.10) - activeresource (= 3.1.10) - activesupport (= 3.1.10) + rails (3.1.11) + actionmailer (= 3.1.11) + actionpack (= 3.1.11) + activerecord (= 3.1.11) + activeresource (= 3.1.11) + activesupport (= 3.1.11) bundler (~> 1.0) - railties (= 3.1.10) - railties (3.1.10) - actionpack (= 3.1.10) - activesupport (= 3.1.10) + railties (= 3.1.11) + railties (3.1.11) + actionpack (= 3.1.11) + activesupport (= 3.1.11) rack-ssl (~> 1.3.2) rake (>= 0.8.7) rdoc (~> 3.4) @@ -173,7 +173,7 @@ GEM raindrops (0.8.0) rake (10.0.3) rdiscount (1.6.8) - rdoc (3.12) + rdoc (3.12.1) json (~> 1.4) redcarpet (2.1.0) responders (0.6.5) @@ -251,7 +251,7 @@ DEPENDENCIES mongo_mapper pg pry - rails (= 3.1.10) + rails (= 3.1.11) rdiscount rspec-rails sass-rails (~> 3.1.0) From 3b297a9c1e43dcec3dcd14b047f3971422c76bc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steven!=20Ragnaro=CC=88k?= Date: Fri, 19 Apr 2013 19:24:52 -0700 Subject: [PATCH 083/161] Make contributing easier and more awesome. This pull request adds the following: Script Bootstrap ---------------- `script/bootstrap`, conventionally used to get new clones up and running in a single command. This one checks for Ruby and Mongo and then, assuming both are present, installs (if necessary) and runs bundler. The idea is that there are only two things new contributors ever need to do. 1. git clone 2. script/bootstrap If we really like it, we can make it smart enough to recommend ways to *get* MongoDB and Ruby based on the OS, but I feel like that's a bit overkill for a v1. The idea is that contribution should be as smooth as possible so would-be helpers can start helping immediately. The script should remain idempotent so if changes are made to the application, existing contributors can pull, run script/bootstrap, and be ready to go without borking their existing dev instance. One thing this does as a side effect is specify a path for vendored gems and binstubs, this is why the .gitignore changes were made. .ruby-version ------------- Specify a Ruby version using the ruby manager agnostic version of an rvmrc. CONTRIBUTING.md --------------- When you create a new Pull Request or Issue, GitHub will highlight a block above the new issue/PR title calling attention to the repository's CONTRIBUTING.md file, should one exist. This is an expanded version of the Helping Out section from the README. --- .gitignore | 1 + .ruby-version | 1 + CONTRIBUTING.md | 24 ++++++++++++++++++++ README.md | 20 +++++++++++++++-- script/bootstrap | 58 ++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 102 insertions(+), 2 deletions(-) create mode 100644 .ruby-version create mode 100644 CONTRIBUTING.md create mode 100755 script/bootstrap diff --git a/.gitignore b/.gitignore index 4f06bb9b..8af1da5b 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ tmp/ .DS_Store *.swp .redcar +bin/ diff --git a/.ruby-version b/.ruby-version new file mode 100644 index 00000000..2a790876 --- /dev/null +++ b/.ruby-version @@ -0,0 +1 @@ + ruby-1.9.3-p392 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000..049e26d1 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,24 @@ +# Thanks for helping! # + +## Questions ## + +If you're asking a question about Hackety Hack itself, check out the [Hackety +Hack repository][hh]. +Otherwise, go ahead and open an [issue][issues] and let us know! + +## Bugs ## + +If you notice a bug in Hackety-Hack.com, this is the place to let us know. +Please tell us: + +- Which url the bug occurred at +- What steps we can take to reproduce this bug +- If the bug is visual, including a screenshot is really helpful. + +## Pull Requests ## + +We :heart: pull requests; We :heart::blue_heart::green_heart: Pull Requests with tests. In fact, we don't want to accept pull requests without relevant tests. If you're not sure if the feature you want is welcome and you want to check with us, feel free to create [an issue][issues] or if you're just totally driven to make it happen, spike it out and open a pull request, but we'll ask you to add tests before it's merged. + + +[hh]: https://github.com/hacketyhack/hacketyhack +[issues]: https://github.com/hacketyhack/hackety-hack.com/issues diff --git a/README.md b/README.md index 877b1272..d89618b1 100644 --- a/README.md +++ b/README.md @@ -11,8 +11,24 @@ If you have any experience writing Rails apps, feel free to help out, we're open + **Test your code**, we really can't stress this enough, ideally you should be practicing [TDD][tdd] and writing tests before you even write your code. If you don't test your code, we have no way of knowing if it works properly so please do test. + **If it's a major feature, file an issue**, if you file an issue we can discuss certain aspects of the new feature with you and ensure it's a good fit for hackety-hack.com. -Additionally, if you're _not_ a developer and you have a feature you'd really like to see on the site, file an issue and we'll be sure to look into it on your behalf. +## Getting Started ## + +Once you've cloned this repository, running `script/bootstrap` should tell you everything you need to know. + +Dependencies for the curious: + +- Ruby: 1.9.3 is preferred. +- MongoDB: 2.2.x or 2.4.x + +As long as you have those things, the script will handle the rest as best it can, including installing the gem dependencies with Bundler. + +If the tests aren't passing when you clone, open [an issue][issues] or drop into +[#hacketyhack on freenode][irc]. + +Additionally, if you're _not_ a developer and you have a feature you'd really like to see on the site, file [an issue][issues] and we'll be sure to look into it on your behalf. [hh.com]: http://hackety-hack.com/ [hh]: https://github.com/hacketyhack/hacketyhack -[tdd]: http://en.wikipedia.org/wiki/Test-driven_development \ No newline at end of file +[irc]: http://webchat.freenode.net/#hacketyhack +[issues]: https://github.com/hacketyhack/hackety-hack.com/issues +[tdd]: http://en.wikipedia.org/wiki/Test-driven_development diff --git a/script/bootstrap b/script/bootstrap new file mode 100755 index 00000000..f4cb94b6 --- /dev/null +++ b/script/bootstrap @@ -0,0 +1,58 @@ +#!/bin/dash + +go_go_gadget_bootstrap() { + check_ruby + check_mongo + check_bundler + bail_unless_chill + good_luck_have_fun +} + +check_mongo() { + which mongo > /dev/null 2>&1 + if [ $? -ne 0 ]; then + NOMONGO="Hey, in order to remember stuff I need MongoDB" + fi +} + +check_bundler() { + if [ -z "$NORUBY" ]; then + which bundle > /dev/null 2>&1 + if [ $? -ne 0 ]; then + gem install bundler || exit 2 + fi + fi +} + +good_luck_have_fun() { + bundle install --path .bundle --binstubs bin + bin/rake spec cucumber +} + +check_ruby() { + which ruby > /dev/null 2>&1 + if [ $? -ne 0 ]; then + NORUBY="Whoa there, looks like you're missing Ruby!" + else + ruby -v | grep '^ruby 1.9.3' > /dev/null 2>&1 + if [ $? -ne 0 ]; then + NORUBY="Hrmm, your Ruby version isn't Ruby 1.9.3, that's really what I prefer." + fi + fi +} + +bail_unless_chill() { + if [ "$NORUBY" -a "$NOMONGO" ]; then + echo "$NORUBY" + echo "$NOMONGO" + exit 1 + elif [ "$NORUBY" ]; then + echo "$NORUBY" + exit 1 + elif [ "$NOMONGO" ]; then + echo "$NOMONGO" + exit 1 + fi +} + +go_go_gadget_bootstrap From f0ff6bf28f02050f3f45e93f1c40ea5c4a10b6a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steven!=20Ragnaro=CC=88k?= Date: Sun, 21 Apr 2013 20:22:22 -0700 Subject: [PATCH 084/161] Move ruby version nonsense into Gemfile. --- .ruby-version | 1 - .rvmrc | 1 - Gemfile | 5 +++++ 3 files changed, 5 insertions(+), 2 deletions(-) delete mode 100644 .ruby-version delete mode 100644 .rvmrc diff --git a/.ruby-version b/.ruby-version deleted file mode 100644 index 2a790876..00000000 --- a/.ruby-version +++ /dev/null @@ -1 +0,0 @@ - ruby-1.9.3-p392 diff --git a/.rvmrc b/.rvmrc deleted file mode 100644 index 751e0242..00000000 --- a/.rvmrc +++ /dev/null @@ -1 +0,0 @@ -rvm use --create ruby-1.9.3@hackety-hack.com diff --git a/Gemfile b/Gemfile index 343d656d..50f8b79d 100644 --- a/Gemfile +++ b/Gemfile @@ -1,5 +1,10 @@ source 'http://rubygems.org' +#ruby=1.9.3-p392 +#ruby-gemset=hackety-hack.com + +ruby '1.9.3' + gem 'rails', '3.1.11' gem 'json' From 9d602e863f33be2a92e5512351a1b1161cfbbfec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steven!=20Ragnaro=CC=88k?= Date: Mon, 22 Apr 2013 22:58:12 -0700 Subject: [PATCH 085/161] Steven! joins club Travis. :crystal_ball::mailbox_with_mail: --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 0100b3ce..cdc86e9a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,5 +7,6 @@ notifications: - tobias.pfeiffer@student.hpi.uni-potsdam.de - james+travis-ci-broken@jamesrgifford.com - kh@kalonhinds.com + - steven+travis-ci@nuclearsandwich.com irc: "irc.freenode.org#hacketyhack" From 8e2493cde0bdcc6b0d8c420b739a60a66413ca42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steven!=20Ragnaro=CC=88k?= Date: Mon, 22 Apr 2013 23:04:33 -0700 Subject: [PATCH 086/161] Fix freenode link in README. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d89618b1..28e42aae 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,6 @@ Additionally, if you're _not_ a developer and you have a feature you'd really li [hh.com]: http://hackety-hack.com/ [hh]: https://github.com/hacketyhack/hacketyhack -[irc]: http://webchat.freenode.net/#hacketyhack +[irc]: http://webchat.freenode.net/?channels=#hacketyhack [issues]: https://github.com/hacketyhack/hackety-hack.com/issues [tdd]: http://en.wikipedia.org/wiki/Test-driven_development From af1d97a4593ec89d9c8187e0180898106d84e09b Mon Sep 17 00:00:00 2001 From: cyberarm Date: Tue, 23 Jul 2013 08:40:18 -0500 Subject: [PATCH 087/161] Fixed atom feed url --- app/views/questions/index.html.haml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app/views/questions/index.html.haml b/app/views/questions/index.html.haml index 82fbbcbe..0c46b2ff 100644 --- a/app/views/questions/index.html.haml +++ b/app/views/questions/index.html.haml @@ -1,5 +1,7 @@ - content_for :head do - - unless @support + - if @support + = auto_discovery_link_tag :atom, support_questions_url(format: :atom) + - else = auto_discovery_link_tag :atom, questions_url(format: :atom) - content_for :title do @@ -16,7 +18,10 @@ = render :partial => "shared/support_blurb" - content_for :feed do - = link_to "Feed", questions_url(format: :atom) + - if @support + = link_to "Feed", support_questions_url(format: :atom) + - else + = link_to "Feed", questions_url(format: :atom) %ul.questions = render :partial => "list", :collection => collection From 3a05264ae5721103906fbf88ec061b47b4256e0d Mon Sep 17 00:00:00 2001 From: cyberarm Date: Tue, 23 Jul 2013 09:25:23 -0500 Subject: [PATCH 088/161] Fixed autofocus skipping username --- app/views/users/_form.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/users/_form.html.haml b/app/views/users/_form.html.haml index 1f20859d..49e9154b 100644 --- a/app/views/users/_form.html.haml +++ b/app/views/users/_form.html.haml @@ -3,7 +3,7 @@ = f.error_notification .inputs = f.input :username, :autofocus => true - = f.input :email, :autofocus => true + = f.input :email .inputs - pwd_options = resource.new_record? ? {} : {:hint => "Leave it blank if you don't want to change it"} = f.input :password, pwd_options.merge({:required => false}) From c2bf32984da715228a10b3e941aa044336a1d055 Mon Sep 17 00:00:00 2001 From: Michal Papis Date: Fri, 2 Aug 2013 04:26:07 +0200 Subject: [PATCH 089/161] do not force bundler flags, this should be personal choice --- README.md | 8 ++++++++ script/bootstrap | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 28e42aae..43fb7094 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,14 @@ If you have any experience writing Rails apps, feel free to help out, we're open Once you've cloned this repository, running `script/bootstrap` should tell you everything you need to know. +In case you prefer gems to be managed entirely by bundler run this before bootstrapping: + + bundle config --global path .bundle + bundle config --global binstubs bin + export PATH="$PWD/bin:$PATH" + +Be careful with using `bin` in `$PATH` it is very risky when used with public projects. + Dependencies for the curious: - Ruby: 1.9.3 is preferred. diff --git a/script/bootstrap b/script/bootstrap index f4cb94b6..b2daad6e 100755 --- a/script/bootstrap +++ b/script/bootstrap @@ -25,8 +25,8 @@ check_bundler() { } good_luck_have_fun() { - bundle install --path .bundle --binstubs bin - bin/rake spec cucumber + bundle install + rake spec cucumber } check_ruby() { From 50cf3ee3ba3241088ab8956243a91e62d9a95e58 Mon Sep 17 00:00:00 2001 From: Angela Ebirim Date: Wed, 31 Jul 2013 08:56:23 +0200 Subject: [PATCH 090/161] Added simplecov to the project * included in Gemfile * added filters for both cucumber and RSpec --- Gemfile | 4 ++++ features/support/env.rb | 13 +++++++++++++ spec/spec_helper.rb | 12 ++++++++++++ 3 files changed, 29 insertions(+) diff --git a/Gemfile b/Gemfile index 50f8b79d..75c53643 100644 --- a/Gemfile +++ b/Gemfile @@ -42,10 +42,13 @@ end group :development, :test do gem 'fabrication' gem 'rspec-rails' + gem 'capybara' gem 'cucumber-rails', require: false gem "faker" gem 'pry' gem 'sqlite3' + + end group :production do @@ -53,6 +56,7 @@ group :production do end group :test do + gem "simplecov", :require => false gem "mocha" gem "database_cleaner" gem "launchy" diff --git a/features/support/env.rb b/features/support/env.rb index 07737733..a348b10b 100644 --- a/features/support/env.rb +++ b/features/support/env.rb @@ -3,6 +3,19 @@ # newer version of cucumber-rails. Consider adding your own code to a new file # instead of editing this one. Cucumber will automatically load all features/**/*.rb # files. +# + +require 'simplecov' +SimpleCov.start do +coverage_dir ('public/publix') + #add_filter '/features/' + add_filter '/spec/' + add_filter '/config/' + add_filter '/lib/' + add_filter '/vendor/' + #add_filter '/app/' + +end require 'cucumber/rails' diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 79d1f541..629dc4e5 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,7 +1,18 @@ +require 'simplecov' +SimpleCov.start do + coverage_dir('public/publix') +#add_filter '/spec/' + add_filter '/config/' + add_filter '/lib/' + add_filter '/vendor/' + add_filter '/features/' +end + ENV["RAILS_ENV"] ||= 'test' require File.expand_path("../../config/environment", __FILE__) require 'rspec/rails' require 'database_cleaner' +require 'capybara/rspec' # Requires supporting ruby files with custom matchers and macros, etc, # in spec/support/ and its subdirectories. @@ -28,4 +39,5 @@ config.before(:each) { reset_email } config.include Devise::TestHelpers, :type => :controller + config.include Capybara::DSL end From 273a1a7c91d637ef7b8f270941484ca229807fae Mon Sep 17 00:00:00 2001 From: Tobias Pfeiffer Date: Sun, 4 Aug 2013 14:15:07 +0200 Subject: [PATCH 091/161] Finished up simplecov integration * new updated Gemfile.lock * removed lib from the filtered dirs as imo it should be covered * using the standard coverage directory --- .gitignore | 1 + Gemfile.lock | 6 ++++++ features/support/env.rb | 11 +++-------- spec/spec_helper.rb | 9 +++------ 4 files changed, 13 insertions(+), 14 deletions(-) diff --git a/.gitignore b/.gitignore index 8af1da5b..f3bc277a 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ tmp/ *.swp .redcar bin/ +coverage diff --git a/Gemfile.lock b/Gemfile.lock index 7ffccfa5..8424216a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -202,6 +202,10 @@ GEM ffi (~> 1.0.9) multi_json (~> 1.0.4) rubyzip + simplecov (0.7.1) + multi_json (~> 1.0) + simplecov-html (~> 0.7.1) + simplecov-html (0.7.1) slop (2.4.3) sprockets (2.0.4) hike (~> 1.2) @@ -234,6 +238,7 @@ PLATFORMS DEPENDENCIES bson_ext cancan + capybara coffee-rails (~> 3.1.0) cucumber-rails database_cleaner @@ -257,6 +262,7 @@ DEPENDENCIES sass-rails (~> 3.1.0) semantic_menu! simple_form! + simplecov sqlite3 uglifier unicorn diff --git a/features/support/env.rb b/features/support/env.rb index a348b10b..78880136 100644 --- a/features/support/env.rb +++ b/features/support/env.rb @@ -7,14 +7,9 @@ require 'simplecov' SimpleCov.start do -coverage_dir ('public/publix') - #add_filter '/features/' - add_filter '/spec/' - add_filter '/config/' - add_filter '/lib/' - add_filter '/vendor/' - #add_filter '/app/' - + add_filter '/spec/' + add_filter '/config/' + add_filter '/vendor/' end require 'cucumber/rails' diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 629dc4e5..9a181a89 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,11 +1,8 @@ require 'simplecov' SimpleCov.start do - coverage_dir('public/publix') -#add_filter '/spec/' - add_filter '/config/' - add_filter '/lib/' - add_filter '/vendor/' - add_filter '/features/' + add_filter '/config/' + add_filter '/vendor/' + add_filter '/features/' end ENV["RAILS_ENV"] ||= 'test' From b08ef47eb2a167608e09f723c30ae07263389471 Mon Sep 17 00:00:00 2001 From: Tobias Pfeiffer Date: Sun, 4 Aug 2013 14:46:58 +0200 Subject: [PATCH 092/161] Added coveralls gem and formatter --- Gemfile | 1 + Gemfile.lock | 10 ++++++++++ features/support/env.rb | 7 +++++++ spec/spec_helper.rb | 6 ++++++ 4 files changed, 24 insertions(+) diff --git a/Gemfile b/Gemfile index 75c53643..2da394ff 100644 --- a/Gemfile +++ b/Gemfile @@ -57,6 +57,7 @@ end group :test do gem "simplecov", :require => false + gem "coveralls" gem "mocha" gem "database_cleaner" gem "launchy" diff --git a/Gemfile.lock b/Gemfile.lock index 8424216a..30114443 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -68,6 +68,13 @@ GEM coffee-script-source execjs coffee-script-source (1.2.0) + colorize (0.5.8) + coveralls (0.5.8) + colorize + json + rest-client + simplecov (>= 0.7) + thor cucumber (1.1.4) builder (>= 2.1.2) diff-lcs (>= 1.1.2) @@ -177,6 +184,8 @@ GEM json (~> 1.4) redcarpet (2.1.0) responders (0.6.5) + rest-client (1.6.7) + mime-types (>= 1.16) rspec (2.8.0) rspec-core (~> 2.8.0) rspec-expectations (~> 2.8.0) @@ -240,6 +249,7 @@ DEPENDENCIES cancan capybara coffee-rails (~> 3.1.0) + coveralls cucumber-rails database_cleaner devise (~> 2.2.2) diff --git a/features/support/env.rb b/features/support/env.rb index 78880136..3100ba3e 100644 --- a/features/support/env.rb +++ b/features/support/env.rb @@ -6,6 +6,13 @@ # require 'simplecov' +require 'coveralls' + +SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[ + Coveralls::SimpleCov::Formatter, + SimpleCov::Formatter::HTMLFormatter +] + SimpleCov.start do add_filter '/spec/' add_filter '/config/' diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 9a181a89..af24fb25 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,4 +1,10 @@ require 'simplecov' +require 'coveralls' + +SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[ + Coveralls::SimpleCov::Formatter, + SimpleCov::Formatter::HTMLFormatter +] SimpleCov.start do add_filter '/config/' add_filter '/vendor/' From 2c16a7e2b92041cb0378296aae14f47e5d44c236 Mon Sep 17 00:00:00 2001 From: Tobias Pfeiffer Date: Sun, 4 Aug 2013 14:52:09 +0200 Subject: [PATCH 093/161] I hate duplication so there now is unified code_coverage file that cucumber and rspec load --- features/support/env.rb | 14 +------------- spec/code_coverage.rb | 11 +++++++++++ spec/spec_helper.rb | 13 +------------ 3 files changed, 13 insertions(+), 25 deletions(-) create mode 100644 spec/code_coverage.rb diff --git a/features/support/env.rb b/features/support/env.rb index 3100ba3e..ee6880e7 100644 --- a/features/support/env.rb +++ b/features/support/env.rb @@ -5,19 +5,7 @@ # files. # -require 'simplecov' -require 'coveralls' - -SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[ - Coveralls::SimpleCov::Formatter, - SimpleCov::Formatter::HTMLFormatter -] - -SimpleCov.start do - add_filter '/spec/' - add_filter '/config/' - add_filter '/vendor/' -end +require_relative '../../spec/code_coverage' require 'cucumber/rails' diff --git a/spec/code_coverage.rb b/spec/code_coverage.rb new file mode 100644 index 00000000..170631c4 --- /dev/null +++ b/spec/code_coverage.rb @@ -0,0 +1,11 @@ +require 'simplecov' +require 'coveralls' + +SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[ + Coveralls::SimpleCov::Formatter, + SimpleCov::Formatter::HTMLFormatter +] +SimpleCov.start do + add_filter '/config/' + add_filter '/vendor/' +end \ No newline at end of file diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index af24fb25..d80bdb02 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,15 +1,4 @@ -require 'simplecov' -require 'coveralls' - -SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[ - Coveralls::SimpleCov::Formatter, - SimpleCov::Formatter::HTMLFormatter -] -SimpleCov.start do - add_filter '/config/' - add_filter '/vendor/' - add_filter '/features/' -end +require 'code_coverage' ENV["RAILS_ENV"] ||= 'test' require File.expand_path("../../config/environment", __FILE__) From d373036be39659c338ca3a03a0ecbe29a0989610 Mon Sep 17 00:00:00 2001 From: Tobias Pfeiffer Date: Sun, 4 Aug 2013 15:09:19 +0200 Subject: [PATCH 094/161] Added coveralls badge * [skpi ci] --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 28e42aae..c0b121a7 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # hackety-hack.com # -[![Build status](https://secure.travis-ci.org/hacketyhack/hackety-hack.com.png)](http://travis-ci.org/#!/hacketyhack/hackety-hack.com) +[![Build status](https://secure.travis-ci.org/hacketyhack/hackety-hack.com.png)](http://travis-ci.org/#!/hacketyhack/hackety-hack.com)[![Coverage Status](https://coveralls.io/repos/hacketyhack/hackety-hack.com/badge.png?branch=master)](https://coveralls.io/r/hacketyhack/hackety-hack.com?branch=master) [hackety-hack.com][hh.com] is the web backend powering the collaborative features of [Hackety Hack][hh]. It is written in Rails 3 and continues to be under active development (see 'Helping Out'), the switch to Rails 3 happened quite recently so there's still lots to be done. From 038caed36d3893d5ce6f9cd77c1564aea0f99c5a Mon Sep 17 00:00:00 2001 From: Tobias Pfeiffer Date: Sun, 4 Aug 2013 15:13:48 +0200 Subject: [PATCH 095/161] Code Climate Badge added * [skip ci] --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c0b121a7..c642f048 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # hackety-hack.com # -[![Build status](https://secure.travis-ci.org/hacketyhack/hackety-hack.com.png)](http://travis-ci.org/#!/hacketyhack/hackety-hack.com)[![Coverage Status](https://coveralls.io/repos/hacketyhack/hackety-hack.com/badge.png?branch=master)](https://coveralls.io/r/hacketyhack/hackety-hack.com?branch=master) +[![Build status](https://secure.travis-ci.org/hacketyhack/hackety-hack.com.png)](http://travis-ci.org/#!/hacketyhack/hackety-hack.com)[![Code Climate](https://codeclimate.com/github/hacketyhack/hackety-hack.com.png)](https://codeclimate.com/github/hacketyhack/hackety-hack.com)[![Coverage Status](https://coveralls.io/repos/hacketyhack/hackety-hack.com/badge.png?branch=master)](https://coveralls.io/r/hacketyhack/hackety-hack.com?branch=master) [hackety-hack.com][hh.com] is the web backend powering the collaborative features of [Hackety Hack][hh]. It is written in Rails 3 and continues to be under active development (see 'Helping Out'), the switch to Rails 3 happened quite recently so there's still lots to be done. From 804beaf14e16459d4c8c82250169c82bb9d41b71 Mon Sep 17 00:00:00 2001 From: Tobias Pfeiffer Date: Sun, 4 Aug 2013 16:03:24 +0200 Subject: [PATCH 096/161] Use the most recent ruby 1.9.3 version --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 2da394ff..e6845bd6 100644 --- a/Gemfile +++ b/Gemfile @@ -1,6 +1,6 @@ source 'http://rubygems.org' -#ruby=1.9.3-p392 +#ruby=1.9.3-p448 #ruby-gemset=hackety-hack.com ruby '1.9.3' From 9aedb9634e2380dbfcae094829e5d63174fe3c5e Mon Sep 17 00:00:00 2001 From: Tobias Pfeiffer Date: Mon, 5 Aug 2013 19:47:16 +0200 Subject: [PATCH 097/161] Added rspec filters back in as suggested by @trekr5 in #160 --- spec/code_coverage.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/spec/code_coverage.rb b/spec/code_coverage.rb index 170631c4..605db4e3 100644 --- a/spec/code_coverage.rb +++ b/spec/code_coverage.rb @@ -8,4 +8,6 @@ SimpleCov.start do add_filter '/config/' add_filter '/vendor/' + add_filter '/spec/' + add_filter '/features/' end \ No newline at end of file From 0af45e19a99cf35a07f6c0e8119e46fb79f522d8 Mon Sep 17 00:00:00 2001 From: Hari Carreras Date: Sun, 11 Aug 2013 17:40:10 +0200 Subject: [PATCH 098/161] User mailer --- Gemfile | 3 +++ Gemfile.lock | 3 +++ app/assets/javascripts/mailer.js.coffee | 3 +++ app/assets/stylesheets/mailer.css.scss | 3 +++ app/controllers/mailer_controller.rb | 19 +++++++++++++++++++ app/controllers/users_controller.rb | 9 +++++++++ app/helpers/mailer_helper.rb | 2 ++ app/mailers/message_mailer.rb | 8 ++++++++ app/models/message.rb | 7 +++++++ app/views/mailer/_form.html.haml | 8 ++++++++ app/views/mailer/new.html.haml | 7 +++++++ .../message_mailer/new_message.html.haml | 1 + app/views/users/index.html.haml | 8 ++++++++ config/environments/development.rb | 1 + config/routes.rb | 9 +++++++++ spec/controllers/mailer_controller_spec.rb | 18 ++++++++++++++++++ spec/fabricators/message_fabricator.rb | 5 +++++ spec/helpers/mailer_helper_spec.rb | 15 +++++++++++++++ spec/mailers/message_mailer_spec.rb | 9 +++++++++ spec/views/mailer/create.html.haml_spec.rb | 5 +++++ spec/views/mailer/index.html.haml_spec.rb | 5 +++++ spec/views/mailer/new.html.haml_spec.rb | 5 +++++ 22 files changed, 153 insertions(+) create mode 100644 app/assets/javascripts/mailer.js.coffee create mode 100644 app/assets/stylesheets/mailer.css.scss create mode 100644 app/controllers/mailer_controller.rb create mode 100644 app/helpers/mailer_helper.rb create mode 100644 app/mailers/message_mailer.rb create mode 100644 app/models/message.rb create mode 100644 app/views/mailer/_form.html.haml create mode 100644 app/views/mailer/new.html.haml create mode 100644 app/views/message_mailer/new_message.html.haml create mode 100644 app/views/users/index.html.haml create mode 100644 spec/controllers/mailer_controller_spec.rb create mode 100644 spec/fabricators/message_fabricator.rb create mode 100644 spec/helpers/mailer_helper_spec.rb create mode 100644 spec/mailers/message_mailer_spec.rb create mode 100644 spec/views/mailer/create.html.haml_spec.rb create mode 100644 spec/views/mailer/index.html.haml_spec.rb create mode 100644 spec/views/mailer/new.html.haml_spec.rb diff --git a/Gemfile b/Gemfile index 50f8b79d..7182be4e 100644 --- a/Gemfile +++ b/Gemfile @@ -15,6 +15,9 @@ gem 'jquery-rails' gem 'mongo_mapper' gem 'bson_ext' +gem "letter_opener", group: :development + + # Gems used only for assets and not required # in production environments by default. group :assets do diff --git a/Gemfile.lock b/Gemfile.lock index 7ffccfa5..71b3aa2f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -115,6 +115,8 @@ GEM kgio (2.7.2) launchy (2.0.5) addressable (~> 2.2.6) + letter_opener (1.0.0) + launchy (>= 2.0.4) mail (2.3.3) i18n (>= 0.4.0) mime-types (~> 1.16) @@ -246,6 +248,7 @@ DEPENDENCIES jquery-rails json launchy + letter_opener mm-devise (~> 2.0) mocha mongo_mapper diff --git a/app/assets/javascripts/mailer.js.coffee b/app/assets/javascripts/mailer.js.coffee new file mode 100644 index 00000000..76156794 --- /dev/null +++ b/app/assets/javascripts/mailer.js.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/ diff --git a/app/assets/stylesheets/mailer.css.scss b/app/assets/stylesheets/mailer.css.scss new file mode 100644 index 00000000..daea0ab6 --- /dev/null +++ b/app/assets/stylesheets/mailer.css.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the Mailer controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/controllers/mailer_controller.rb b/app/controllers/mailer_controller.rb new file mode 100644 index 00000000..e0ae6440 --- /dev/null +++ b/app/controllers/mailer_controller.rb @@ -0,0 +1,19 @@ +class MailerController < ApplicationController + def new + @user = User.find_by_username(params[:user]) + @message = Message.new + end + + def create + @message = Message.new(params[:message]) + # @message.email = params[:email] + + if @message.valid? + MessageMailer.new_message(@message).deliver + redirect_to users_index_path, :notice => "Email sent correctly" + else + notice = "There was an error" + reder :new + end + end +end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index ff461272..346ab564 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -1,6 +1,15 @@ class UsersController < InheritedController load_and_authorize_resource skip_authorize_resource :only => [:following, :followers] #anyone can perform these read-only actions + #Index pagination + require 'will_paginate/array' + + def index + @users = User.all.paginate(:page => params[:page], :per_page => 10) + respond_to do |format| + format.html + end + end def follow followee = User.first(:id => params[:user][:followee]) diff --git a/app/helpers/mailer_helper.rb b/app/helpers/mailer_helper.rb new file mode 100644 index 00000000..6156b950 --- /dev/null +++ b/app/helpers/mailer_helper.rb @@ -0,0 +1,2 @@ +module MailerHelper +end diff --git a/app/mailers/message_mailer.rb b/app/mailers/message_mailer.rb new file mode 100644 index 00000000..faecf444 --- /dev/null +++ b/app/mailers/message_mailer.rb @@ -0,0 +1,8 @@ +class MessageMailer < ActionMailer::Base + default from: "steve@hackety.com" + + def new_message message + @message = message + mail(:to => @message.email, :subject => @message.subject) + end +end diff --git a/app/models/message.rb b/app/models/message.rb new file mode 100644 index 00000000..105570df --- /dev/null +++ b/app/models/message.rb @@ -0,0 +1,7 @@ +class Message + include MongoMapper::Document + key :email, String + key :subject, String + key :body, String + validates_presence_of :email, :body +end \ No newline at end of file diff --git a/app/views/mailer/_form.html.haml b/app/views/mailer/_form.html.haml new file mode 100644 index 00000000..fdbf31c3 --- /dev/null +++ b/app/views/mailer/_form.html.haml @@ -0,0 +1,8 @@ +=simple_form_for(@message, :url => mailer_path) do |f| + =f.error_notification + .inputs + =f.input :subject, :hint => "Write the subject here!" + =f.input :body, :as => :text + =f.input :email, :as => :hidden, :input_html => { :value => @user.email } + .actions + =f.button :submit , 'Send Email', :class => "primary btn" \ No newline at end of file diff --git a/app/views/mailer/new.html.haml b/app/views/mailer/new.html.haml new file mode 100644 index 00000000..284d4fbf --- /dev/null +++ b/app/views/mailer/new.html.haml @@ -0,0 +1,7 @@ +%h1 Send an Email! += render "form" + +%p El nombre del usuario al que se le mandarรก el email es: +=@user.username +%p con email +=@user.email \ No newline at end of file diff --git a/app/views/message_mailer/new_message.html.haml b/app/views/message_mailer/new_message.html.haml new file mode 100644 index 00000000..df3f577a --- /dev/null +++ b/app/views/message_mailer/new_message.html.haml @@ -0,0 +1 @@ +=@message.body \ No newline at end of file diff --git a/app/views/users/index.html.haml b/app/views/users/index.html.haml new file mode 100644 index 00000000..5b5e7453 --- /dev/null +++ b/app/views/users/index.html.haml @@ -0,0 +1,8 @@ +%ul + - @users.each do |user| + %li + .info + .title= user.username + .categories + .btn.success= link_to "Email him", mailer_path(:user => user) += will_paginate @users \ No newline at end of file diff --git a/config/environments/development.rb b/config/environments/development.rb index 07b0d262..e1189b93 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -26,4 +26,5 @@ config.assets.compress = false config.action_mailer.default_url_options = { :host => 'localhost:3000' } + config.action_mailer.delivery_method = :letter_opener end diff --git a/config/routes.rb b/config/routes.rb index 08a561d8..c1d2df49 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,5 +1,14 @@ HacketyHackCom::Application.routes.draw do + get "users/index" + + get "mailer/new" + + get "mailer/create" + + match 'mailer' => 'mailer#new', :as => 'mailer', :via => :get + match 'mailer' => 'mailer#create', :as => 'mailer', :via => :post + resources :lessons, :only => [:index, :show] resources :questions do diff --git a/spec/controllers/mailer_controller_spec.rb b/spec/controllers/mailer_controller_spec.rb new file mode 100644 index 00000000..84ffcb4b --- /dev/null +++ b/spec/controllers/mailer_controller_spec.rb @@ -0,0 +1,18 @@ +require 'spec_helper' + +describe MailerController do + describe "GET 'new'" do + it "returns http success" do + get 'new' + response.should be_success + end + end + + describe "GET 'create'" do + it "returns http success" do + get 'create' + response.should be_success + end + end + +end diff --git a/spec/fabricators/message_fabricator.rb b/spec/fabricators/message_fabricator.rb new file mode 100644 index 00000000..0ba1bb37 --- /dev/null +++ b/spec/fabricators/message_fabricator.rb @@ -0,0 +1,5 @@ +Fabricator(:message) do + email:"justa@proof.com" + subject:"Hackety-hack email" + body:"This is an email from hackety-hack.com" +end \ No newline at end of file diff --git a/spec/helpers/mailer_helper_spec.rb b/spec/helpers/mailer_helper_spec.rb new file mode 100644 index 00000000..212c5c1d --- /dev/null +++ b/spec/helpers/mailer_helper_spec.rb @@ -0,0 +1,15 @@ +require 'spec_helper' + +# Specs in this file have access to a helper object that includes +# the MailerHelper. For example: +# +# describe MailerHelper do +# describe "string concat" do +# it "concats two strings with spaces" do +# helper.concat_strings("this","that").should == "this that" +# end +# end +# end +describe MailerHelper do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/mailers/message_mailer_spec.rb b/spec/mailers/message_mailer_spec.rb new file mode 100644 index 00000000..7582593a --- /dev/null +++ b/spec/mailers/message_mailer_spec.rb @@ -0,0 +1,9 @@ +require "spec_helper" + +describe MessageMailer do + let(:message) { Fabricate(:message)} + + it "is from Steve" do + message.from.should eq(["steve@hackety.com"]) + end +end diff --git a/spec/views/mailer/create.html.haml_spec.rb b/spec/views/mailer/create.html.haml_spec.rb new file mode 100644 index 00000000..2dc97f9f --- /dev/null +++ b/spec/views/mailer/create.html.haml_spec.rb @@ -0,0 +1,5 @@ +require 'spec_helper' + +describe "mailer/create.html.haml" do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/views/mailer/index.html.haml_spec.rb b/spec/views/mailer/index.html.haml_spec.rb new file mode 100644 index 00000000..e5516069 --- /dev/null +++ b/spec/views/mailer/index.html.haml_spec.rb @@ -0,0 +1,5 @@ +require 'spec_helper' + +describe "mailer/index.html.haml" do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/views/mailer/new.html.haml_spec.rb b/spec/views/mailer/new.html.haml_spec.rb new file mode 100644 index 00000000..58223e1a --- /dev/null +++ b/spec/views/mailer/new.html.haml_spec.rb @@ -0,0 +1,5 @@ +require 'spec_helper' + +describe "mailer/new.html.haml" do + pending "add some examples to (or delete) #{__FILE__}" +end From 665a7f03caddd9b95b1975f2e9a30f96fde90d0f Mon Sep 17 00:00:00 2001 From: Hari Carreras Date: Mon, 12 Aug 2013 18:32:17 +0200 Subject: [PATCH 099/161] User mailer with corrections --- Gemfile | 1 - app/controllers/mailer_controller.rb | 1 - app/controllers/users_controller.rb | 3 +-- app/views/mailer/new.html.haml | 6 +++--- config/routes.rb | 4 ---- spec/controllers/mailer_controller_spec.rb | 8 -------- spec/fabricators/message_fabricator.rb | 2 +- spec/mailers/message_mailer_spec.rb | 8 ++++---- 8 files changed, 9 insertions(+), 24 deletions(-) diff --git a/Gemfile b/Gemfile index 7182be4e..11e70a51 100644 --- a/Gemfile +++ b/Gemfile @@ -17,7 +17,6 @@ gem 'bson_ext' gem "letter_opener", group: :development - # Gems used only for assets and not required # in production environments by default. group :assets do diff --git a/app/controllers/mailer_controller.rb b/app/controllers/mailer_controller.rb index e0ae6440..6b1ef5ce 100644 --- a/app/controllers/mailer_controller.rb +++ b/app/controllers/mailer_controller.rb @@ -6,7 +6,6 @@ def new def create @message = Message.new(params[:message]) - # @message.email = params[:email] if @message.valid? MessageMailer.new_message(@message).deliver diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 346ab564..e3997127 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -1,11 +1,10 @@ class UsersController < InheritedController load_and_authorize_resource skip_authorize_resource :only => [:following, :followers] #anyone can perform these read-only actions - #Index pagination require 'will_paginate/array' def index - @users = User.all.paginate(:page => params[:page], :per_page => 10) + @users = User.all.paginate(:page => params[:page], :per_page => 1) respond_to do |format| format.html end diff --git a/app/views/mailer/new.html.haml b/app/views/mailer/new.html.haml index 284d4fbf..57ad5539 100644 --- a/app/views/mailer/new.html.haml +++ b/app/views/mailer/new.html.haml @@ -1,7 +1,7 @@ %h1 Send an Email! = render "form" -%p El nombre del usuario al que se le mandarรก el email es: -=@user.username -%p con email +This email will send to: +=@user.username +with email: =@user.email \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index c1d2df49..ec59e18f 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -2,10 +2,6 @@ get "users/index" - get "mailer/new" - - get "mailer/create" - match 'mailer' => 'mailer#new', :as => 'mailer', :via => :get match 'mailer' => 'mailer#create', :as => 'mailer', :via => :post diff --git a/spec/controllers/mailer_controller_spec.rb b/spec/controllers/mailer_controller_spec.rb index 84ffcb4b..09d7ad4c 100644 --- a/spec/controllers/mailer_controller_spec.rb +++ b/spec/controllers/mailer_controller_spec.rb @@ -7,12 +7,4 @@ response.should be_success end end - - describe "GET 'create'" do - it "returns http success" do - get 'create' - response.should be_success - end - end - end diff --git a/spec/fabricators/message_fabricator.rb b/spec/fabricators/message_fabricator.rb index 0ba1bb37..bee5c6e9 100644 --- a/spec/fabricators/message_fabricator.rb +++ b/spec/fabricators/message_fabricator.rb @@ -1,5 +1,5 @@ Fabricator(:message) do - email:"justa@proof.com" + email:"proof@example.com" subject:"Hackety-hack email" body:"This is an email from hackety-hack.com" end \ No newline at end of file diff --git a/spec/mailers/message_mailer_spec.rb b/spec/mailers/message_mailer_spec.rb index 7582593a..25747070 100644 --- a/spec/mailers/message_mailer_spec.rb +++ b/spec/mailers/message_mailer_spec.rb @@ -1,9 +1,9 @@ require "spec_helper" describe MessageMailer do - let(:message) { Fabricate(:message)} + let(:message) { MessageMailer.new_message(Fabricate(:message))} - it "is from Steve" do - message.from.should eq(["steve@hackety.com"]) - end + it "is from Steve" do + message.from.should eq(["steve@hackety.com"]) + end end From 3a5de0e80f8261f5d41f9d76b4657aa674c2e788 Mon Sep 17 00:00:00 2001 From: Hari Carreras Date: Mon, 12 Aug 2013 18:42:18 +0200 Subject: [PATCH 100/161] User mailer with corrections --- app/assets/javascripts/mailer.js.coffee | 3 --- app/assets/stylesheets/mailer.css.scss | 3 --- app/helpers/mailer_helper.rb | 2 -- spec/helpers/mailer_helper_spec.rb | 15 --------------- spec/views/mailer/create.html.haml_spec.rb | 5 ----- 5 files changed, 28 deletions(-) delete mode 100644 app/assets/javascripts/mailer.js.coffee delete mode 100644 app/assets/stylesheets/mailer.css.scss delete mode 100644 app/helpers/mailer_helper.rb delete mode 100644 spec/helpers/mailer_helper_spec.rb delete mode 100644 spec/views/mailer/create.html.haml_spec.rb diff --git a/app/assets/javascripts/mailer.js.coffee b/app/assets/javascripts/mailer.js.coffee deleted file mode 100644 index 76156794..00000000 --- a/app/assets/javascripts/mailer.js.coffee +++ /dev/null @@ -1,3 +0,0 @@ -# Place all the behaviors and hooks related to the matching controller here. -# All this logic will automatically be available in application.js. -# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/ diff --git a/app/assets/stylesheets/mailer.css.scss b/app/assets/stylesheets/mailer.css.scss deleted file mode 100644 index daea0ab6..00000000 --- a/app/assets/stylesheets/mailer.css.scss +++ /dev/null @@ -1,3 +0,0 @@ -// Place all the styles related to the Mailer controller here. -// They will automatically be included in application.css. -// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/helpers/mailer_helper.rb b/app/helpers/mailer_helper.rb deleted file mode 100644 index 6156b950..00000000 --- a/app/helpers/mailer_helper.rb +++ /dev/null @@ -1,2 +0,0 @@ -module MailerHelper -end diff --git a/spec/helpers/mailer_helper_spec.rb b/spec/helpers/mailer_helper_spec.rb deleted file mode 100644 index 212c5c1d..00000000 --- a/spec/helpers/mailer_helper_spec.rb +++ /dev/null @@ -1,15 +0,0 @@ -require 'spec_helper' - -# Specs in this file have access to a helper object that includes -# the MailerHelper. For example: -# -# describe MailerHelper do -# describe "string concat" do -# it "concats two strings with spaces" do -# helper.concat_strings("this","that").should == "this that" -# end -# end -# end -describe MailerHelper do - pending "add some examples to (or delete) #{__FILE__}" -end diff --git a/spec/views/mailer/create.html.haml_spec.rb b/spec/views/mailer/create.html.haml_spec.rb deleted file mode 100644 index 2dc97f9f..00000000 --- a/spec/views/mailer/create.html.haml_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'spec_helper' - -describe "mailer/create.html.haml" do - pending "add some examples to (or delete) #{__FILE__}" -end From 2ab54a40ae73fdb63d38b3756262738ccf4802e5 Mon Sep 17 00:00:00 2001 From: Tobias Pfeiffer Date: Thu, 22 Aug 2013 11:46:44 +0200 Subject: [PATCH 101/161] Deleted unused spec files with only pending specs --- spec/views/mailer/index.html.haml_spec.rb | 5 ----- spec/views/mailer/new.html.haml_spec.rb | 5 ----- 2 files changed, 10 deletions(-) delete mode 100644 spec/views/mailer/index.html.haml_spec.rb delete mode 100644 spec/views/mailer/new.html.haml_spec.rb diff --git a/spec/views/mailer/index.html.haml_spec.rb b/spec/views/mailer/index.html.haml_spec.rb deleted file mode 100644 index e5516069..00000000 --- a/spec/views/mailer/index.html.haml_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'spec_helper' - -describe "mailer/index.html.haml" do - pending "add some examples to (or delete) #{__FILE__}" -end diff --git a/spec/views/mailer/new.html.haml_spec.rb b/spec/views/mailer/new.html.haml_spec.rb deleted file mode 100644 index 58223e1a..00000000 --- a/spec/views/mailer/new.html.haml_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'spec_helper' - -describe "mailer/new.html.haml" do - pending "add some examples to (or delete) #{__FILE__}" -end From 0fa6f9352650adab08e009efdbfbd38287b9f019 Mon Sep 17 00:00:00 2001 From: Hari Carreras Date: Fri, 23 Aug 2013 00:31:05 +0200 Subject: [PATCH 102/161] User index permissions --- app/controllers/users_controller.rb | 7 +++---- app/views/shared/menu/_user.html.haml | 2 ++ 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index e3997127..8573bcc9 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -1,13 +1,12 @@ class UsersController < InheritedController load_and_authorize_resource skip_authorize_resource :only => [:following, :followers] #anyone can perform these read-only actions + require 'will_paginate/array' def index - @users = User.all.paginate(:page => params[:page], :per_page => 1) - respond_to do |format| - format.html - end + redirect_to root_path unless current_user and current_user.moderator + @users = User.all.paginate(:page => params[:page], :per_page => 10) end def follow diff --git a/app/views/shared/menu/_user.html.haml b/app/views/shared/menu/_user.html.haml index 3b507a9a..2e4de22e 100644 --- a/app/views/shared/menu/_user.html.haml +++ b/app/views/shared/menu/_user.html.haml @@ -1,5 +1,7 @@ = semantic_menu :class => "nav secondary-nav" do |root| - if current_user + - if current_user.moderator + - root.add "Send an Email", users_index_path - root.add current_user.username, user_path(current_user) - root.add "Log Out", logout_path - else From 18f448328189771bd610d5e08607a62548140699 Mon Sep 17 00:00:00 2001 From: Tobias Pfeiffer Date: Fri, 23 Aug 2013 12:03:18 +0200 Subject: [PATCH 103/161] blog post spec did not have any contents --- spec/models/blog_post_spec.rb | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 spec/models/blog_post_spec.rb diff --git a/spec/models/blog_post_spec.rb b/spec/models/blog_post_spec.rb deleted file mode 100644 index 9047c6e8..00000000 --- a/spec/models/blog_post_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'spec_helper' - -describe BlogPost do - pending "add some examples to (or delete) #{__FILE__}" -end From 59cb493bb9beadfbca58ea0a054b73baedf126b6 Mon Sep 17 00:00:00 2001 From: Tobias Pfeiffer Date: Fri, 23 Aug 2013 12:46:41 +0200 Subject: [PATCH 104/161] Use a DeletedUser object for deleted users --- app/controllers/users_controller.rb | 6 +++++- app/models/deleted_user.rb | 13 +++++++++++++ app/models/question.rb | 9 +++++++++ app/views/questions/_list.html.haml | 16 ++++++++-------- app/views/questions/index.html.haml | 2 +- app/views/users/deleted_user.html.haml | 1 + config/routes.rb | 1 + spec/models/question_spec.rb | 25 +++++++++++++++++++++++++ 8 files changed, 63 insertions(+), 10 deletions(-) create mode 100644 app/models/deleted_user.rb create mode 100644 app/views/users/deleted_user.html.haml create mode 100644 spec/models/question_spec.rb diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index e3997127..d1549068 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -1,6 +1,6 @@ class UsersController < InheritedController load_and_authorize_resource - skip_authorize_resource :only => [:following, :followers] #anyone can perform these read-only actions + skip_authorize_resource :only => [:following, :followers, :deleted_user] #anyone can perform these read-only actions require 'will_paginate/array' def index @@ -38,6 +38,10 @@ def followers @user = User.first(:username => params[:user_id]) end + def deleted_user + @user = DeletedUser.new + end + ################# def resource diff --git a/app/models/deleted_user.rb b/app/models/deleted_user.rb new file mode 100644 index 00000000..0f4f2c40 --- /dev/null +++ b/app/models/deleted_user.rb @@ -0,0 +1,13 @@ +class DeletedUser + def username + 'Deleted User' + end + + def email + 'none' + end + + def to_param + 'deleted_user' + end +end \ No newline at end of file diff --git a/app/models/question.rb b/app/models/question.rb index 9c734a52..70ea09fd 100644 --- a/app/models/question.rb +++ b/app/models/question.rb @@ -15,4 +15,13 @@ class Question scope :newest_first, sort(:created_at.desc) scope :supports, where(:support => true ) scope :no_supports, where('$or' => [{:support=> false}, {:support => nil}]) + + def user + asker = super + if asker.nil? + DeletedUser.new + else + asker + end + end end diff --git a/app/views/questions/_list.html.haml b/app/views/questions/_list.html.haml index db17c87d..fe52303d 100644 --- a/app/views/questions/_list.html.haml +++ b/app/views/questions/_list.html.haml @@ -1,15 +1,15 @@ -%li.item{:id=>list.id, :class => list.answers.count > 0 ? (list.solution_id.nil? ? "answered" : "accepted") : "unanswered"} +%li.item{:id=>question.id, :class => question.answers.count > 0 ? (question.solution_id.nil? ? "answered" : "accepted") : "unanswered"} .answer-count - %h3= list.answers.count - #{list.answers.count == 1 ? "answer" : "answers"} + %h3= question.answers.count + #{question.answers.count == 1 ? "answer" : "answers"} .summary - %h2.title= link_to list.title, resource_path(list) + %h2.title= link_to question.title, resource_path(question) .meta Asked by - %span.name= link_to list.user.username, user_path(list.user) + %span.name= link_to question.user.username, user_path(question.user) - %span.date= time_ago_in_words(list.created_at) + %span.date= time_ago_in_words(question.created_at) ago - .description= truncate(list.description, :length => 150) + .description= truncate(question.description, :length => 150) - if current_user && current_user.moderator? - %div.move_question= link_to "Move to #{list.support? ? 'Questions' : 'Support'} ยป", question_path(list, :question => { :support => (list.support? ? "false" : "true") }), :method => :put, :class => "btn small info" + %div.move_question= link_to "Move to #{question.support? ? 'Questions' : 'Support'} ยป", question_path(question, :question => { :support => (question.support? ? "false" : "true") }), :method => :put, :class => "btn small info" diff --git a/app/views/questions/index.html.haml b/app/views/questions/index.html.haml index 0c46b2ff..cc7b8d48 100644 --- a/app/views/questions/index.html.haml +++ b/app/views/questions/index.html.haml @@ -24,6 +24,6 @@ = link_to "Feed", questions_url(format: :atom) %ul.questions - = render :partial => "list", :collection => collection + = render :partial => "list", :collection => collection, :as => :question = will_paginate diff --git a/app/views/users/deleted_user.html.haml b/app/views/users/deleted_user.html.haml new file mode 100644 index 00000000..10721f64 --- /dev/null +++ b/app/views/users/deleted_user.html.haml @@ -0,0 +1 @@ +%h2 This user has been deleted, sorry \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index ec59e18f..13d1b648 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -4,6 +4,7 @@ match 'mailer' => 'mailer#new', :as => 'mailer', :via => :get match 'mailer' => 'mailer#create', :as => 'mailer', :via => :post + get 'users/deleted_user', :to => 'users#deleted_user' resources :lessons, :only => [:index, :show] diff --git a/spec/models/question_spec.rb b/spec/models/question_spec.rb new file mode 100644 index 00000000..131fdeab --- /dev/null +++ b/spec/models/question_spec.rb @@ -0,0 +1,25 @@ +require 'spec_helper' + +describe Question do + + let(:question){Fabricate(:question)} + + it 'can be created validly' do + question.should be_valid + end + + describe 'without a user' do + before :each do + question.user.destroy + @reloaded_question = Question.find question.id + end + + it 'does not respond with nil when asked for its user' do + @reloaded_question.user.should_not be_nil + end + + it 'responds with something when ask for user that respodns to username' do + @reloaded_question.user.should respond_to :username + end + end +end \ No newline at end of file From 15060c22b2af9a79ee61d549ab71d15f45a71997 Mon Sep 17 00:00:00 2001 From: Tobias Pfeiffer Date: Fri, 23 Aug 2013 12:51:50 +0200 Subject: [PATCH 105/161] Fixed cucumber spec --- features/step_definitions/question_steps.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/features/step_definitions/question_steps.rb b/features/step_definitions/question_steps.rb index 6009c346..b98c76b8 100644 --- a/features/step_definitions/question_steps.rb +++ b/features/step_definitions/question_steps.rb @@ -63,7 +63,8 @@ def create_question_for(user) Given /^there is a question from someone else$/ do @question = Question.create(:title => "A question to delete", - :description => "moderator should delete me!") + :description => "moderator should delete me!", + :user => Fabricate(:user)) end Then /^I can delete that question$/ do From a0625543f8c8ec1049231e4e69b93ac4b697f29d Mon Sep 17 00:00:00 2001 From: Hari Carreras Date: Fri, 23 Aug 2013 13:33:11 +0200 Subject: [PATCH 106/161] Diffusion (doesn't work) --- app/controllers/mailer_controller.rb | 11 ++++++++++- app/mailers/message_mailer.rb | 4 +++- app/models/message.rb | 2 +- app/views/mailer/_form.html.haml | 2 +- app/views/mailer/new.html.haml | 4 ---- app/views/users/index.html.haml | 1 + 6 files changed, 16 insertions(+), 8 deletions(-) diff --git a/app/controllers/mailer_controller.rb b/app/controllers/mailer_controller.rb index 6b1ef5ce..89573bf1 100644 --- a/app/controllers/mailer_controller.rb +++ b/app/controllers/mailer_controller.rb @@ -1,6 +1,15 @@ class MailerController < ApplicationController def new - @user = User.find_by_username(params[:user]) + #@user = User.find_by_username(params[:user]) + @users = params[:user] + if @users.is_a? Array + @emails = Array.new + @users.each do |user| + @emails << User.find_by_username(user).email + end + else + @emails = User.find_by_username(@users).email + end @message = Message.new end diff --git a/app/mailers/message_mailer.rb b/app/mailers/message_mailer.rb index faecf444..2841c31b 100644 --- a/app/mailers/message_mailer.rb +++ b/app/mailers/message_mailer.rb @@ -3,6 +3,8 @@ class MessageMailer < ActionMailer::Base def new_message message @message = message - mail(:to => @message.email, :subject => @message.subject) + @message.email.each do |email| + mail(:to => email, :subject => @message.subject) + end end end diff --git a/app/models/message.rb b/app/models/message.rb index 105570df..216b338f 100644 --- a/app/models/message.rb +++ b/app/models/message.rb @@ -1,6 +1,6 @@ class Message include MongoMapper::Document - key :email, String + key :email, Array key :subject, String key :body, String validates_presence_of :email, :body diff --git a/app/views/mailer/_form.html.haml b/app/views/mailer/_form.html.haml index fdbf31c3..8c017475 100644 --- a/app/views/mailer/_form.html.haml +++ b/app/views/mailer/_form.html.haml @@ -3,6 +3,6 @@ .inputs =f.input :subject, :hint => "Write the subject here!" =f.input :body, :as => :text - =f.input :email, :as => :hidden, :input_html => { :value => @user.email } + =f.input :email, :as => :hidden, :input_html => { :value => @emails } .actions =f.button :submit , 'Send Email', :class => "primary btn" \ No newline at end of file diff --git a/app/views/mailer/new.html.haml b/app/views/mailer/new.html.haml index 57ad5539..07e0e019 100644 --- a/app/views/mailer/new.html.haml +++ b/app/views/mailer/new.html.haml @@ -1,7 +1,3 @@ %h1 Send an Email! = render "form" -This email will send to: -=@user.username -with email: -=@user.email \ No newline at end of file diff --git a/app/views/users/index.html.haml b/app/views/users/index.html.haml index 5b5e7453..472cd073 100644 --- a/app/views/users/index.html.haml +++ b/app/views/users/index.html.haml @@ -1,3 +1,4 @@ +=link_to "Create a diffusion", mailer_path(:user => User.all) %ul - @users.each do |user| %li From 4482b7a184c950ef0f8897432ec77bfd2ed33213 Mon Sep 17 00:00:00 2001 From: Angela Ebirim Date: Fri, 23 Aug 2013 16:09:44 +0200 Subject: [PATCH 107/161] translations --- README.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 4603273d..51b5f1cd 100644 --- a/README.md +++ b/README.md @@ -4,13 +4,19 @@ [hackety-hack.com][hh.com] is the web backend powering the collaborative features of [Hackety Hack][hh]. It is written in Rails 3 and continues to be under active development (see 'Helping Out'), the switch to Rails 3 happened quite recently so there's still lots to be done. -## Helping Out ## +### Helping Out ### If you have any experience writing Rails apps, feel free to help out, we're open to pull requests as long as you follow a few conditions. + **Test your code**, we really can't stress this enough, ideally you should be practicing [TDD][tdd] and writing tests before you even write your code. If you don't test your code, we have no way of knowing if it works properly so please do test. + **If it's a major feature, file an issue**, if you file an issue we can discuss certain aspects of the new feature with you and ensure it's a good fit for hackety-hack.com. +## Translations ## + +Hello everyone! + +We are in the process of translating Hackety Hack into as many foreign languages as possible so that people around the world would be able to use the site with ease. If you are bilingual and interested in helping us make Hackety Hack a truly global phenomenon, accessible by all regardless of location or nationality, and make learning Ruby even more fun! then please sign up here http://crowdin.net/project/hackety-hackcom/invite + ## Getting Started ## Once you've cloned this repository, running `script/bootstrap` should tell you everything you need to know. From 510e2feef6ae958abc86c27b7977ef941a5dd38e Mon Sep 17 00:00:00 2001 From: Steve Klabnik Date: Fri, 23 Aug 2013 12:38:10 -0400 Subject: [PATCH 108/161] Update to remove secret token. --- config/initializers/secret_token.rb | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/config/initializers/secret_token.rb b/config/initializers/secret_token.rb index 41d098a4..87515021 100644 --- a/config/initializers/secret_token.rb +++ b/config/initializers/secret_token.rb @@ -1,7 +1,16 @@ -# Be sure to restart your server when you modify this file. +if ENV["SECRET_TOKEN"].blank? + if Rails.env.production? + raise "You must set ENV[\"SECRET_TOKEN\"] in your app's config vars" + elsif Rails.env.test? + # Generate the key and test away + ENV["SECRET_TOKEN"] = HacketyHackCom::Application.config.secret_token = SecureRandom.hex(30) + else + config_file = File.expand_path(File.join(Rails.root, '/config/config.yml')) + config = YAML.load_file(config_file) + # Generate the key, set it for the current environment, update the yaml file and move on + ENV["SECRET_TOKEN"] = config[Rails.env]['SECRET_TOKEN'] = SecureRandom.hex(30) + File.open(config_file, 'w') { |file| file.write(config.to_yaml) } + end +end -# Your secret key for verifying the integrity of signed cookies. -# If you change this key, all old signed cookies will become invalid! -# Make sure the secret is at least 30 characters and all random, -# no regular words or you'll be exposed to dictionary attacks. -HacketyHackCom::Application.config.secret_token = '855ad4d9d95703179ef4280cd14ec205cb6a1fb2477c11bdf55d80390a8ecae82e4b60a4d9e572f9a83cd4d74cedf32a0592afdf36fc86aff0da766fa866aafd' +HacketyHackCom::Application.config.secret_token = ENV["SECRET_TOKEN"] From 9833b12ddbf479229fb886e9e26bc8d85650d939 Mon Sep 17 00:00:00 2001 From: Angela Ebirim Date: Sat, 24 Aug 2013 09:35:31 +0200 Subject: [PATCH 109/161] front page with translate link --- app/views/shared/menu/_user.html.haml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/views/shared/menu/_user.html.haml b/app/views/shared/menu/_user.html.haml index 3b507a9a..396522f0 100644 --- a/app/views/shared/menu/_user.html.haml +++ b/app/views/shared/menu/_user.html.haml @@ -5,3 +5,6 @@ - else - root.add "Log In", login_path - root.add "Sign Up", new_user_registration_path + - root.add "Help Us Translate", 'http://crowdin.net/project/hackety-hackcom/invite' + + From 88aaf67e982f1f49a19a47d5dcfea77d28e2344d Mon Sep 17 00:00:00 2001 From: Angela Ebirim Date: Sat, 24 Aug 2013 12:10:33 +0200 Subject: [PATCH 110/161] amended translate file --- app/views/shared/menu/_user.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/shared/menu/_user.html.haml b/app/views/shared/menu/_user.html.haml index 396522f0..aa5b8ad8 100644 --- a/app/views/shared/menu/_user.html.haml +++ b/app/views/shared/menu/_user.html.haml @@ -5,6 +5,6 @@ - else - root.add "Log In", login_path - root.add "Sign Up", new_user_registration_path - - root.add "Help Us Translate", 'http://crowdin.net/project/hackety-hackcom/invite' + - root.add "Help Us Translate!", 'http://crowdin.net/project/hackety-hackcom/invite' From 7d31ff7c9677da500dfb9bb709560d956f054b3a Mon Sep 17 00:00:00 2001 From: Hari Carreras Date: Wed, 28 Aug 2013 17:52:32 +0200 Subject: [PATCH 111/161] Diffusion works fine --- app/controllers/mailer_controller.rb | 6 ++++-- app/mailers/message_mailer.rb | 7 +++---- app/views/mailer/_form.html.haml | 8 +++++++- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/app/controllers/mailer_controller.rb b/app/controllers/mailer_controller.rb index 89573bf1..b585c423 100644 --- a/app/controllers/mailer_controller.rb +++ b/app/controllers/mailer_controller.rb @@ -17,11 +17,13 @@ def create @message = Message.new(params[:message]) if @message.valid? - MessageMailer.new_message(@message).deliver + @message.email.each do |email| + MessageMailer.new_message(@message, email).deliver + end redirect_to users_index_path, :notice => "Email sent correctly" else notice = "There was an error" - reder :new + render :new end end end diff --git a/app/mailers/message_mailer.rb b/app/mailers/message_mailer.rb index 2841c31b..790550b3 100644 --- a/app/mailers/message_mailer.rb +++ b/app/mailers/message_mailer.rb @@ -1,10 +1,9 @@ class MessageMailer < ActionMailer::Base default from: "steve@hackety.com" - def new_message message + def new_message message, email @message = message - @message.email.each do |email| - mail(:to => email, :subject => @message.subject) - end + @email = email + mail(:to => @email, :subject => @message.subject) end end diff --git a/app/views/mailer/_form.html.haml b/app/views/mailer/_form.html.haml index 8c017475..c8381e8c 100644 --- a/app/views/mailer/_form.html.haml +++ b/app/views/mailer/_form.html.haml @@ -3,6 +3,12 @@ .inputs =f.input :subject, :hint => "Write the subject here!" =f.input :body, :as => :text - =f.input :email, :as => :hidden, :input_html => { :value => @emails } + + -if(@emails.class == Array.new.class) + -@emails.each do |email| + =f.input "email[#{email}]", :as => :text, :as => :hidden, :input_html => { :value => ""} + -else + =f.input "email[#{@emails}]", :as => :text, :as => :hidden, :input_html => { :value => ""} + .actions =f.button :submit , 'Send Email', :class => "primary btn" \ No newline at end of file From 328ba5678f5adb848c06b22303250cbd064b5cba Mon Sep 17 00:00:00 2001 From: Tobias Pfeiffer Date: Thu, 29 Aug 2013 00:26:42 +0200 Subject: [PATCH 112/161] Added a sample config.yml file * if there is no config.yml, the secret token initializer automatically copies it over so that it's easier for people to contribute to the project :-) --- .gitignore | 1 + config/config.yml.sample | 9 +++++++++ config/initializers/secret_token.rb | 4 ++++ 3 files changed, 14 insertions(+) create mode 100644 config/config.yml.sample diff --git a/.gitignore b/.gitignore index f3bc277a..bb909eb6 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ tmp/ .redcar bin/ coverage +config/config.yml diff --git a/config/config.yml.sample b/config/config.yml.sample new file mode 100644 index 00000000..2ef60a26 --- /dev/null +++ b/config/config.yml.sample @@ -0,0 +1,9 @@ +# encoding: utf-8 +development: + # Your secret key for verifying the integrity of signed cookies. + # If you change this key, all old signed cookies will become invalid! + # Make sure the secret is at least 30 characters and all random, + # no regular words or you'll be exposed to dictionary attacks. + # Used in config/initializers/secret_token.rb. + # You can generate a good value for this by running `rake secret`. + SECRET_TOKEN: \ No newline at end of file diff --git a/config/initializers/secret_token.rb b/config/initializers/secret_token.rb index 87515021..5e4aedfb 100644 --- a/config/initializers/secret_token.rb +++ b/config/initializers/secret_token.rb @@ -6,6 +6,10 @@ ENV["SECRET_TOKEN"] = HacketyHackCom::Application.config.secret_token = SecureRandom.hex(30) else config_file = File.expand_path(File.join(Rails.root, '/config/config.yml')) + unless File.exist? config_file + require 'fileutils' + FileUtils.cp config_file + '.sample', config_file + end config = YAML.load_file(config_file) # Generate the key, set it for the current environment, update the yaml file and move on ENV["SECRET_TOKEN"] = config[Rails.env]['SECRET_TOKEN'] = SecureRandom.hex(30) From 665d8e99ac655926c34fcc24c7e37ca86dee82f8 Mon Sep 17 00:00:00 2001 From: Tobias Pfeiffer Date: Thu, 29 Aug 2013 00:38:02 +0200 Subject: [PATCH 113/161] Moved link over to main navigation so it's always visible --- app/views/shared/menu/_main.html.haml | 1 + app/views/shared/menu/_user.html.haml | 5 +---- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/app/views/shared/menu/_main.html.haml b/app/views/shared/menu/_main.html.haml index 8d010254..e9b6868b 100644 --- a/app/views/shared/menu/_main.html.haml +++ b/app/views/shared/menu/_main.html.haml @@ -5,3 +5,4 @@ - root.add "Programs", programs_path - root.add "FAQ", faq_path - root.add "Support", support_questions_path + - root.add "Help Us Translate!", 'http://crowdin.net/project/hackety-hackcom/invite' diff --git a/app/views/shared/menu/_user.html.haml b/app/views/shared/menu/_user.html.haml index aa5b8ad8..75c60899 100644 --- a/app/views/shared/menu/_user.html.haml +++ b/app/views/shared/menu/_user.html.haml @@ -4,7 +4,4 @@ - root.add "Log Out", logout_path - else - root.add "Log In", login_path - - root.add "Sign Up", new_user_registration_path - - root.add "Help Us Translate!", 'http://crowdin.net/project/hackety-hackcom/invite' - - + - root.add "Sign Up", new_user_registration_path \ No newline at end of file From 78810f5e5d923be2656e698611de5084bd188b42 Mon Sep 17 00:00:00 2001 From: Hari Carreras Date: Thu, 29 Aug 2013 10:49:14 +0200 Subject: [PATCH 114/161] Mailer more elegant --- app/controllers/mailer_controller.rb | 4 ++-- app/controllers/users_controller.rb | 3 +-- app/views/mailer/_form.html.haml | 7 ++----- app/views/mailer/new.html.haml | 5 +++++ 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/app/controllers/mailer_controller.rb b/app/controllers/mailer_controller.rb index b585c423..8675f92a 100644 --- a/app/controllers/mailer_controller.rb +++ b/app/controllers/mailer_controller.rb @@ -2,13 +2,13 @@ class MailerController < ApplicationController def new #@user = User.find_by_username(params[:user]) @users = params[:user] + @emails = Array.new if @users.is_a? Array - @emails = Array.new @users.each do |user| @emails << User.find_by_username(user).email end else - @emails = User.find_by_username(@users).email + @emails << User.find_by_username(@users).email end @message = Message.new end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 8573bcc9..37be545b 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -1,11 +1,10 @@ class UsersController < InheritedController load_and_authorize_resource skip_authorize_resource :only => [:following, :followers] #anyone can perform these read-only actions - require 'will_paginate/array' def index - redirect_to root_path unless current_user and current_user.moderator + redirect_to root_path unless can? :manage, @users @users = User.all.paginate(:page => params[:page], :per_page => 10) end diff --git a/app/views/mailer/_form.html.haml b/app/views/mailer/_form.html.haml index c8381e8c..52e95c84 100644 --- a/app/views/mailer/_form.html.haml +++ b/app/views/mailer/_form.html.haml @@ -4,11 +4,8 @@ =f.input :subject, :hint => "Write the subject here!" =f.input :body, :as => :text - -if(@emails.class == Array.new.class) - -@emails.each do |email| - =f.input "email[#{email}]", :as => :text, :as => :hidden, :input_html => { :value => ""} - -else - =f.input "email[#{@emails}]", :as => :text, :as => :hidden, :input_html => { :value => ""} + -@emails.each do |email| + =f.input "email[#{email}]", :as => :text, :as => :hidden, :input_html => { :value => ""} .actions =f.button :submit , 'Send Email', :class => "primary btn" \ No newline at end of file diff --git a/app/views/mailer/new.html.haml b/app/views/mailer/new.html.haml index 07e0e019..fb4dbb7c 100644 --- a/app/views/mailer/new.html.haml +++ b/app/views/mailer/new.html.haml @@ -1,3 +1,8 @@ %h1 Send an Email! = render "form" +This email will send to: +-@emails.each do |email| + = email + = " " + \ No newline at end of file From f84c7016e33ba18996dc1a5b909f13cccb9d8a68 Mon Sep 17 00:00:00 2001 From: Hari Carreras Date: Thu, 29 Aug 2013 11:00:45 +0200 Subject: [PATCH 115/161] Mailer even more elegant --- app/controllers/mailer_controller.rb | 9 +++------ app/views/users/index.html.haml | 3 ++- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/app/controllers/mailer_controller.rb b/app/controllers/mailer_controller.rb index 8675f92a..6b3d80a5 100644 --- a/app/controllers/mailer_controller.rb +++ b/app/controllers/mailer_controller.rb @@ -3,13 +3,10 @@ def new #@user = User.find_by_username(params[:user]) @users = params[:user] @emails = Array.new - if @users.is_a? Array - @users.each do |user| - @emails << User.find_by_username(user).email - end - else - @emails << User.find_by_username(@users).email + @users.each do |user| + @emails << User.find_by_username(user).email end + @message = Message.new end diff --git a/app/views/users/index.html.haml b/app/views/users/index.html.haml index 472cd073..87a74560 100644 --- a/app/views/users/index.html.haml +++ b/app/views/users/index.html.haml @@ -5,5 +5,6 @@ .info .title= user.username .categories - .btn.success= link_to "Email him", mailer_path(:user => user) + .btn.success= link_to "Email him", mailer_path(:user => Array.new << user) + = will_paginate @users \ No newline at end of file From 32a67af7b39335914a5e5e0d2881a30c7f654891 Mon Sep 17 00:00:00 2001 From: Hari Carreras Date: Thu, 29 Aug 2013 13:03:31 +0200 Subject: [PATCH 116/161] Mailer view logic free --- app/controllers/mailer_controller.rb | 7 +++++-- app/views/users/index.html.haml | 4 ++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/app/controllers/mailer_controller.rb b/app/controllers/mailer_controller.rb index 6b3d80a5..b87dccf8 100644 --- a/app/controllers/mailer_controller.rb +++ b/app/controllers/mailer_controller.rb @@ -1,7 +1,10 @@ class MailerController < ApplicationController def new - #@user = User.find_by_username(params[:user]) - @users = params[:user] + @users = Array.new + Array(params[:user]).each do |user| + @users << user + end + @emails = Array.new @users.each do |user| @emails << User.find_by_username(user).email diff --git a/app/views/users/index.html.haml b/app/views/users/index.html.haml index 87a74560..8c9d2495 100644 --- a/app/views/users/index.html.haml +++ b/app/views/users/index.html.haml @@ -5,6 +5,6 @@ .info .title= user.username .categories - .btn.success= link_to "Email him", mailer_path(:user => Array.new << user) - + .btn.success= link_to "Email him", mailer_path(:user => user) + = will_paginate @users \ No newline at end of file From a292839da170ede316175a60ff8721e83759fb9a Mon Sep 17 00:00:00 2001 From: Hari Carreras Date: Thu, 29 Aug 2013 14:14:21 +0200 Subject: [PATCH 117/161] Some tests --- spec/controllers/mailer_controller_spec.rb | 3 ++- spec/fabricators/message_fabricator.rb | 2 +- spec/mailers/message_mailer_spec.rb | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/spec/controllers/mailer_controller_spec.rb b/spec/controllers/mailer_controller_spec.rb index 09d7ad4c..1a605806 100644 --- a/spec/controllers/mailer_controller_spec.rb +++ b/spec/controllers/mailer_controller_spec.rb @@ -1,9 +1,10 @@ require 'spec_helper' describe MailerController do + let(:user) { Fabricate(:user) } describe "GET 'new'" do it "returns http success" do - get 'new' + get 'new', user: Array(user) response.should be_success end end diff --git a/spec/fabricators/message_fabricator.rb b/spec/fabricators/message_fabricator.rb index bee5c6e9..209c8f4f 100644 --- a/spec/fabricators/message_fabricator.rb +++ b/spec/fabricators/message_fabricator.rb @@ -1,5 +1,5 @@ Fabricator(:message) do - email:"proof@example.com" + email(count: 1) {"proof@example.com" } subject:"Hackety-hack email" body:"This is an email from hackety-hack.com" end \ No newline at end of file diff --git a/spec/mailers/message_mailer_spec.rb b/spec/mailers/message_mailer_spec.rb index 25747070..1b6f3661 100644 --- a/spec/mailers/message_mailer_spec.rb +++ b/spec/mailers/message_mailer_spec.rb @@ -1,7 +1,7 @@ require "spec_helper" describe MessageMailer do - let(:message) { MessageMailer.new_message(Fabricate(:message))} + let(:message) { MessageMailer.new_message(Fabricate(:message), Array("proof@example.com"))} it "is from Steve" do message.from.should eq(["steve@hackety.com"]) From fa4a315a8b7e71f1776f6ee3acb2d65c95a655be Mon Sep 17 00:00:00 2001 From: angela ebirim Date: Mon, 2 Sep 2013 12:23:32 +0100 Subject: [PATCH 118/161] contributing page --- app/views/static/contribute.html.haml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 app/views/static/contribute.html.haml diff --git a/app/views/static/contribute.html.haml b/app/views/static/contribute.html.haml new file mode 100644 index 00000000..a2bc998c --- /dev/null +++ b/app/views/static/contribute.html.haml @@ -0,0 +1,16 @@ +- content_for :sidebar do + = render :partial => "shared/ask" + = render :partial => "shared/support_blurb" + +- content_for :title do + Contributing page + +#Contribute + :markdown + ##Want to help us translate Hackety Hack? + + Hello everyone! + + We are in the process of translating Hackety Hack into as many foreign languages as possible so that people around the world can use the site with ease. + + If you are bilingual and interested in helping us make Hackety Hack a truly global phenomenon, accessible by all regardless of location or nationality and make learning Ruby even more fun, then please [sign up here!](http://crowdin.net/project/hackety-hackcom/invite) From 3aff3bc9762cac364fc285198ccc1cd585d46863 Mon Sep 17 00:00:00 2001 From: angela ebirim Date: Mon, 2 Sep 2013 12:34:14 +0100 Subject: [PATCH 119/161] contribute link --- app/views/shared/menu/_user.html.haml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/views/shared/menu/_user.html.haml b/app/views/shared/menu/_user.html.haml index 3b507a9a..b5422b42 100644 --- a/app/views/shared/menu/_user.html.haml +++ b/app/views/shared/menu/_user.html.haml @@ -5,3 +5,5 @@ - else - root.add "Log In", login_path - root.add "Sign Up", new_user_registration_path + - root.add "Help Us Translate!", contribute_path + From 331c265bd8d4b82104f2e4db47143841184381f0 Mon Sep 17 00:00:00 2001 From: angela ebirim Date: Mon, 2 Sep 2013 12:53:43 +0100 Subject: [PATCH 120/161] route file with contributing link --- config/routes.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/config/routes.rb b/config/routes.rb index 13d1b648..e46d05dc 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -55,6 +55,7 @@ # match ':user_id/:slug', :to => "programs#show", :as => :program match 'faq' => 'static#faq' + match 'contribute' => 'static#contribute' root :to => "static#root" end From e359deebd8af9fbacffc32ec91b844cd2439f5f4 Mon Sep 17 00:00:00 2001 From: Tobias Pfeiffer Date: Fri, 6 Sep 2013 13:40:48 +0200 Subject: [PATCH 121/161] Added code contribution part to the contributing page --- app/views/static/contribute.html.haml | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/app/views/static/contribute.html.haml b/app/views/static/contribute.html.haml index a2bc998c..bac61372 100644 --- a/app/views/static/contribute.html.haml +++ b/app/views/static/contribute.html.haml @@ -3,14 +3,24 @@ = render :partial => "shared/support_blurb" - content_for :title do - Contributing page + Contribute #Contribute :markdown - ##Want to help us translate Hackety Hack? + Volunteers build Hackty Hack - want to help and join us to improve Hackety Hack? + + ## Want to help developing Hackety Hack? + + Both this web application and the Hackety Hack program itself are open source projects. This means volunteers build them, but it also means that you can jump in and help out! How cool would that be, right? + + You can help out with the development of this web application [here](https://github.com/hacketyhack/hackety-hack.com) and with the the development of the Hackety Hack program [here](https://github.com/hacketyhack/hacketyhack). + + Every contribution is very welcome! It can be a fixed typo, an issue report or an entirely new feature - that is up to you! Thanks in advance! + + ## Want to help us translate Hackety Hack? Hello everyone! - We are in the process of translating Hackety Hack into as many foreign languages as possible so that people around the world can use the site with ease. + We are in the process of translating Hackety Hack into as many foreign languages as possible so that people around the world can use the site with ease. - If you are bilingual and interested in helping us make Hackety Hack a truly global phenomenon, accessible by all regardless of location or nationality and make learning Ruby even more fun, then please [sign up here!](http://crowdin.net/project/hackety-hackcom/invite) + If you are bilingual and interested in helping us make Hackety Hack a truly global phenomenon, accessible by all regardless of location or nationality and make learning Ruby even more fun, then please [sign up here!](http://crowdin.net/project/hackety-hackcom/invite) From faf97a168bb0fcc76ef03fec0fdcee7702e76cd2 Mon Sep 17 00:00:00 2001 From: Hari Carreras Date: Mon, 16 Sep 2013 17:35:07 +0300 Subject: [PATCH 122/161] Diffusion with one query --- app/controllers/mailer_controller.rb | 9 ++------- app/views/mailer/new.html.haml | 3 +-- config/routes.rb | 1 + spec/controllers/mailer_controller_spec.rb | 4 +++- 4 files changed, 7 insertions(+), 10 deletions(-) diff --git a/app/controllers/mailer_controller.rb b/app/controllers/mailer_controller.rb index b87dccf8..cdc9cef6 100644 --- a/app/controllers/mailer_controller.rb +++ b/app/controllers/mailer_controller.rb @@ -1,14 +1,9 @@ class MailerController < ApplicationController def new - @users = Array.new - Array(params[:user]).each do |user| - @users << user - end + @users = Array(params[:user]) @emails = Array.new - @users.each do |user| - @emails << User.find_by_username(user).email - end + @emails = User.where(:username => @users).all.map(&:email); @message = Message.new end diff --git a/app/views/mailer/new.html.haml b/app/views/mailer/new.html.haml index fb4dbb7c..c9f04e11 100644 --- a/app/views/mailer/new.html.haml +++ b/app/views/mailer/new.html.haml @@ -4,5 +4,4 @@ This email will send to: -@emails.each do |email| = email - = " " - \ No newline at end of file + = " " \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index ec59e18f..a577ecae 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -4,6 +4,7 @@ match 'mailer' => 'mailer#new', :as => 'mailer', :via => :get match 'mailer' => 'mailer#create', :as => 'mailer', :via => :post + # match 'mailer' => 'mailer#diffusion', :as => 'mailer', :via => :get resources :lessons, :only => [:index, :show] diff --git a/spec/controllers/mailer_controller_spec.rb b/spec/controllers/mailer_controller_spec.rb index 1a605806..8fc87718 100644 --- a/spec/controllers/mailer_controller_spec.rb +++ b/spec/controllers/mailer_controller_spec.rb @@ -2,10 +2,12 @@ describe MailerController do let(:user) { Fabricate(:user) } - describe "GET 'new'" do + + describe "GET 'new' for a single user email" do it "returns http success" do get 'new', user: Array(user) response.should be_success end end + end From b01cf5968327fbf9ebce1c7b04196129b8c1581c Mon Sep 17 00:00:00 2001 From: Hari Carreras Date: Mon, 16 Sep 2013 17:38:18 +0300 Subject: [PATCH 123/161] Diffusion with one query --- config/routes.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/config/routes.rb b/config/routes.rb index a577ecae..ec59e18f 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -4,7 +4,6 @@ match 'mailer' => 'mailer#new', :as => 'mailer', :via => :get match 'mailer' => 'mailer#create', :as => 'mailer', :via => :post - # match 'mailer' => 'mailer#diffusion', :as => 'mailer', :via => :get resources :lessons, :only => [:index, :show] From c9cda91a9654ec4a57b4281e4b89eff5538b8489 Mon Sep 17 00:00:00 2001 From: Hari Carreras Date: Mon, 16 Sep 2013 17:55:59 +0300 Subject: [PATCH 124/161] Diffusion with one query --- app/controllers/mailer_controller.rb | 3 --- 1 file changed, 3 deletions(-) diff --git a/app/controllers/mailer_controller.rb b/app/controllers/mailer_controller.rb index cdc9cef6..8e22435e 100644 --- a/app/controllers/mailer_controller.rb +++ b/app/controllers/mailer_controller.rb @@ -1,10 +1,7 @@ class MailerController < ApplicationController def new @users = Array(params[:user]) - - @emails = Array.new @emails = User.where(:username => @users).all.map(&:email); - @message = Message.new end From 91cc7812ef2c2df14c287de3c269a8c2ecc3ce29 Mon Sep 17 00:00:00 2001 From: Hari Carreras Date: Tue, 1 Oct 2013 11:34:19 +0300 Subject: [PATCH 125/161] Added some mail specs --- spec/fabricators/message_fabricator.rb | 2 +- spec/mailers/message_mailer_spec.rb | 14 +++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/spec/fabricators/message_fabricator.rb b/spec/fabricators/message_fabricator.rb index 209c8f4f..be6b3f22 100644 --- a/spec/fabricators/message_fabricator.rb +++ b/spec/fabricators/message_fabricator.rb @@ -2,4 +2,4 @@ email(count: 1) {"proof@example.com" } subject:"Hackety-hack email" body:"This is an email from hackety-hack.com" -end \ No newline at end of file +end diff --git a/spec/mailers/message_mailer_spec.rb b/spec/mailers/message_mailer_spec.rb index 1b6f3661..b1a567fe 100644 --- a/spec/mailers/message_mailer_spec.rb +++ b/spec/mailers/message_mailer_spec.rb @@ -1,9 +1,21 @@ require "spec_helper" describe MessageMailer do - let(:message) { MessageMailer.new_message(Fabricate(:message), Array("proof@example.com"))} + let(:message) { MessageMailer.new_message(Fabricate(:message), Array("proof@example.com"))} it "is from Steve" do message.from.should eq(["steve@hackety.com"]) end + + it "Correct subject" do + message.subject.should eq("Hackety-hack email") + end + + it "Correct receiver email" do + message.to.should eq(["proof@example.com"]) + end + + it "Correct body" do + message.body.encoded.should match("This is an email from hackety-hack.com") + end end From 6bcf49abda5fd674f2bfcdd9dab1fb873a5a62bc Mon Sep 17 00:00:00 2001 From: Hari Carreras Date: Wed, 2 Oct 2013 17:54:09 +0300 Subject: [PATCH 126/161] Added more specs --- Gemfile.lock | 2 +- spec/controllers/mailer_controller_spec.rb | 21 +++++++++++++++++++++ spec/fabricators/message_fabricator.rb | 6 ++++++ 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 71b3aa2f..27ab182d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -88,7 +88,7 @@ GEM erubis (2.7.0) execjs (1.3.0) multi_json (~> 1.0) - fabrication (1.2.0) + fabrication (2.8.1) faker (1.0.1) i18n (~> 0.4) ffi (1.0.11) diff --git a/spec/controllers/mailer_controller_spec.rb b/spec/controllers/mailer_controller_spec.rb index 8fc87718..cd5a2789 100644 --- a/spec/controllers/mailer_controller_spec.rb +++ b/spec/controllers/mailer_controller_spec.rb @@ -2,6 +2,7 @@ describe MailerController do let(:user) { Fabricate(:user) } + let(:users) { Fabricate.sequence(:user, 5)} describe "GET 'new' for a single user email" do it "returns http success" do @@ -10,4 +11,24 @@ end end + describe "GET 'new' for a diffusion" do + it "returns http success" do + get 'new', user: Array(users) + response.should be_success + end + end + + describe "POST 'create' for a single user email" do + it "returns http success" do + get 'create', message: Fabricate.build(:message) + response.should be_success + end + end + + describe "POST 'create' for a diffusion" do + it "returns http success" do + post 'create', message: Fabricate.build(:diffusion) + response.should be_success + end + end end diff --git a/spec/fabricators/message_fabricator.rb b/spec/fabricators/message_fabricator.rb index be6b3f22..9ec6949e 100644 --- a/spec/fabricators/message_fabricator.rb +++ b/spec/fabricators/message_fabricator.rb @@ -3,3 +3,9 @@ subject:"Hackety-hack email" body:"This is an email from hackety-hack.com" end + +Fabricator(:diffusion, from: :message) do + email(count: 5) { |i| "proof#{i}@example.com" } + subject:"Hackety-hack email" + body:"This is an email from hackety-hack.com" +end From 4376aa0cef086c173e03ab491adbdeed2c4a7cc0 Mon Sep 17 00:00:00 2001 From: Hari Carreras Date: Wed, 2 Oct 2013 18:02:50 +0300 Subject: [PATCH 127/161] Corrected a small error, changed 'get' for 'post' in a spec controller --- spec/controllers/mailer_controller_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/controllers/mailer_controller_spec.rb b/spec/controllers/mailer_controller_spec.rb index cd5a2789..52bcdfe6 100644 --- a/spec/controllers/mailer_controller_spec.rb +++ b/spec/controllers/mailer_controller_spec.rb @@ -20,7 +20,7 @@ describe "POST 'create' for a single user email" do it "returns http success" do - get 'create', message: Fabricate.build(:message) + post 'create', message: Fabricate.build(:message) response.should be_success end end From 5d57b919b40d69af12316e5cb0f1a857da56d6fb Mon Sep 17 00:00:00 2001 From: Hari Carreras Date: Fri, 11 Oct 2013 20:22:21 +0300 Subject: [PATCH 128/161] Covered spec deliveries --- spec/controllers/mailer_controller_spec.rb | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/spec/controllers/mailer_controller_spec.rb b/spec/controllers/mailer_controller_spec.rb index 52bcdfe6..2fd17e69 100644 --- a/spec/controllers/mailer_controller_spec.rb +++ b/spec/controllers/mailer_controller_spec.rb @@ -20,15 +20,25 @@ describe "POST 'create' for a single user email" do it "returns http success" do - post 'create', message: Fabricate.build(:message) + @message = Fabricate.build(:message) + post 'create', message: @message response.should be_success + #We expect after send a message that the deliveries raise one + expect { MessageMailer.new_message(@message, @message.email).deliver }.to change { ActionMailer::Base.deliveries.size }.by(1) end end describe "POST 'create' for a diffusion" do it "returns http success" do - post 'create', message: Fabricate.build(:diffusion) + @diffusion = Fabricate.build(:diffusion) + post 'create', message: @diffusion response.should be_success + + @before_send = ActionMailer::Base.deliveries.size + @diffusion.email.each do |email| + MessageMailer.new_message(@diffusion, email).deliver + end + ActionMailer::Base.deliveries.size.should eq @before_send + @diffusion.email.size end end end From 8b300a0f3127be5d236ddfbc3601e945cc36fd59 Mon Sep 17 00:00:00 2001 From: Tobias Pfeiffer Date: Fri, 11 Oct 2013 23:19:22 +0200 Subject: [PATCH 129/161] Updated rspec --- Gemfile.lock | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index e1483f6a..13bd9db3 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -91,7 +91,7 @@ GEM orm_adapter (~> 0.1) railties (~> 3.1) warden (~> 1.2.1) - diff-lcs (1.1.3) + diff-lcs (1.2.4) erubis (2.7.0) execjs (1.3.0) multi_json (~> 1.0) @@ -110,15 +110,15 @@ GEM haml (~> 3.0) railties (~> 3.0) has_scope (0.5.1) - hike (1.2.1) - i18n (0.6.1) + hike (1.2.3) + i18n (0.6.5) inherited_resources (1.3.0) has_scope (~> 0.5.0) responders (~> 0.6.0) jquery-rails (1.0.19) railties (~> 3.0) thor (~> 0.14) - json (1.7.7) + json (1.8.0) kgio (2.7.2) launchy (2.0.5) addressable (~> 2.2.6) @@ -180,27 +180,25 @@ GEM rdoc (~> 3.4) thor (~> 0.14.6) raindrops (0.8.0) - rake (10.0.3) + rake (10.1.0) rdiscount (1.6.8) - rdoc (3.12.1) + rdoc (3.12.2) json (~> 1.4) redcarpet (2.1.0) responders (0.6.5) rest-client (1.6.7) mime-types (>= 1.16) - rspec (2.8.0) - rspec-core (~> 2.8.0) - rspec-expectations (~> 2.8.0) - rspec-mocks (~> 2.8.0) - rspec-core (2.8.0) - rspec-expectations (2.8.0) - diff-lcs (~> 1.1.2) - rspec-mocks (2.8.0) - rspec-rails (2.8.1) + rspec-core (2.14.5) + rspec-expectations (2.14.3) + diff-lcs (>= 1.1.3, < 2.0) + rspec-mocks (2.14.3) + rspec-rails (2.14.0) actionpack (>= 3.0) activesupport (>= 3.0) railties (>= 3.0) - rspec (~> 2.8.0) + rspec-core (~> 2.14.0) + rspec-expectations (~> 2.14.0) + rspec-mocks (~> 2.14.0) rubyzip (0.9.5) sass (3.1.12) sass-rails (3.1.5) @@ -225,7 +223,7 @@ GEM sqlite3 (1.3.5) term-ansicolor (1.0.7) thor (0.14.6) - tilt (1.3.3) + tilt (1.3.7) treetop (1.4.12) polyglot polyglot (>= 0.3.1) From 6c7621e6fa049f80af5d8ab9bbd6677b78c08378 Mon Sep 17 00:00:00 2001 From: Tobias Pfeiffer Date: Fri, 11 Oct 2013 23:46:04 +0200 Subject: [PATCH 130/161] extended specs and made them work --- app/controllers/mailer_controller.rb | 7 ++-- app/models/message.rb | 4 ++ spec/controllers/mailer_controller_spec.rb | 45 ++++++++++++++-------- 3 files changed, 37 insertions(+), 19 deletions(-) diff --git a/app/controllers/mailer_controller.rb b/app/controllers/mailer_controller.rb index 8e22435e..6f39a9f6 100644 --- a/app/controllers/mailer_controller.rb +++ b/app/controllers/mailer_controller.rb @@ -1,7 +1,7 @@ class MailerController < ApplicationController def new @users = Array(params[:user]) - @emails = User.where(:username => @users).all.map(&:email); + @emails = User.where(:username => @users).all.map(&:email) @message = Message.new end @@ -14,8 +14,7 @@ def create end redirect_to users_index_path, :notice => "Email sent correctly" else - notice = "There was an error" - render :new - end + render :new, notice: "There was an error" + end end end diff --git a/app/models/message.rb b/app/models/message.rb index 216b338f..2c00d8ba 100644 --- a/app/models/message.rb +++ b/app/models/message.rb @@ -4,4 +4,8 @@ class Message key :subject, String key :body, String validates_presence_of :email, :body + + def to_param + {email: email, subject: subject, body: body} + end end \ No newline at end of file diff --git a/spec/controllers/mailer_controller_spec.rb b/spec/controllers/mailer_controller_spec.rb index 2fd17e69..788e28ce 100644 --- a/spec/controllers/mailer_controller_spec.rb +++ b/spec/controllers/mailer_controller_spec.rb @@ -6,39 +6,54 @@ describe "GET 'new' for a single user email" do it "returns http success" do - get 'new', user: Array(user) + get :new, user: Array(user) response.should be_success end end describe "GET 'new' for a diffusion" do it "returns http success" do - get 'new', user: Array(users) + get :new, user: Array(users) response.should be_success end end describe "POST 'create' for a single user email" do - it "returns http success" do + before :each do @message = Fabricate.build(:message) - post 'create', message: @message - response.should be_success - #We expect after send a message that the deliveries raise one - expect { MessageMailer.new_message(@message, @message.email).deliver }.to change { ActionMailer::Base.deliveries.size }.by(1) + end + + it 'delivers the email' do + expect { + post :create, message: @message + }.to change {ActionMailer::Base.deliveries.size}.by(1) + end + + describe 'delivered message' do + before :each do + post :create, message: @message + end + + it "returns http success" do + response.should be_redirect + end + + it 'delivers the mail with the subject that we wanted to' do + ActionMailer::Base.deliveries.last.subject.should == @message.subject + end + + it 'delivers the mail with the body that we wanted to' do + ActionMailer::Base.deliveries.last.body.to_s.should match @message.body + end end end describe "POST 'create' for a diffusion" do it "returns http success" do @diffusion = Fabricate.build(:diffusion) - post 'create', message: @diffusion - response.should be_success - - @before_send = ActionMailer::Base.deliveries.size - @diffusion.email.each do |email| - MessageMailer.new_message(@diffusion, email).deliver - end - ActionMailer::Base.deliveries.size.should eq @before_send + @diffusion.email.size + expect { + post 'create', message: @diffusion + }.to change {ActionMailer::Base.deliveries.size}.by(@diffusion.email.size) end end end From 19cc35a1b681c98da3302c402a2fa62f1d0eb024 Mon Sep 17 00:00:00 2001 From: Tobias Pfeiffer Date: Fri, 11 Oct 2013 23:59:39 +0200 Subject: [PATCH 131/161] spec for Message#to_param --- spec/models/message.rb | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 spec/models/message.rb diff --git a/spec/models/message.rb b/spec/models/message.rb new file mode 100644 index 00000000..5caa4eb1 --- /dev/null +++ b/spec/models/message.rb @@ -0,0 +1,19 @@ +require 'spec_helper' + +describe Message do + subject {Fabricate.build(:message)} + + describe '#to_param' do + it 'has the email attribute' do + subject.to_param[:email].should == subject.email + end + + it'has the subject attribute' do + subject.to_param[:subject].should == subject.subject + end + + it 'has the body attribute' do + subject.to_param[:body].should == subject.body + end + end +end \ No newline at end of file From 8167d86dbec2e860aa9551afc1a655e9d14b2ca1 Mon Sep 17 00:00:00 2001 From: Tobias Pfeiffer Date: Sat, 12 Oct 2013 00:03:08 +0200 Subject: [PATCH 132/161] Removed rspec deprecations --- spec/following_policy_spec.rb | 4 ++-- spec/views/questions/index.html.haml_spec.rb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/spec/following_policy_spec.rb b/spec/following_policy_spec.rb index 67cdf8bb..ae9c2ec2 100644 --- a/spec/following_policy_spec.rb +++ b/spec/following_policy_spec.rb @@ -2,8 +2,8 @@ describe FollowingPolicy do before(:each) do - @followee = stub() - @follower = stub() + @followee = double 'followee' + @follower = double 'follower' end it 'can follow another' do diff --git a/spec/views/questions/index.html.haml_spec.rb b/spec/views/questions/index.html.haml_spec.rb index 4950a576..8bcadc85 100644 --- a/spec/views/questions/index.html.haml_spec.rb +++ b/spec/views/questions/index.html.haml_spec.rb @@ -8,7 +8,7 @@ stub_template "shared/_ask" => "" stub_template "questions/_list" => "" - view.stub! :will_paginate + view.stub :will_paginate end it "renders an autodiscovery link in for the head content" do From 36ea37d514de1fc40806ee6a954a757830ca895f Mon Sep 17 00:00:00 2001 From: cyberarm Date: Mon, 14 Oct 2013 11:22:57 -0500 Subject: [PATCH 133/161] Use Redcarpet for markdown formatting of user input. --- Gemfile | 2 +- Gemfile.lock | 7 +++---- app/helpers/application_helper.rb | 4 ++++ app/models/deleted_user.rb | 2 +- app/views/answers/_list.html.haml | 3 +-- app/views/blog/index.html.haml | 3 +-- app/views/blog/show.html.haml | 3 +-- app/views/lessons/show.html.haml | 3 +-- app/views/questions/new.html.haml | 2 +- app/views/questions/show.html.haml | 3 +-- app/views/static/faq.html.haml | 2 +- 11 files changed, 16 insertions(+), 18 deletions(-) diff --git a/Gemfile b/Gemfile index ee52de85..67a67897 100644 --- a/Gemfile +++ b/Gemfile @@ -34,7 +34,7 @@ gem 'simple_form', git: "https://github.com/bitzesty/bootstrap_form.git" gem "semantic_menu", git: "git://github.com/michaek/semantic_menu.git" gem 'will_paginate' # Pagination -gem 'rdiscount' # Markdown +gem 'redcarpet', '~> 3.0' # Markdown group :development do # Use unicorn as the web server diff --git a/Gemfile.lock b/Gemfile.lock index 13bd9db3..098507ce 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -181,10 +181,9 @@ GEM thor (~> 0.14.6) raindrops (0.8.0) rake (10.1.0) - rdiscount (1.6.8) rdoc (3.12.2) json (~> 1.4) - redcarpet (2.1.0) + redcarpet (3.0.0) responders (0.6.5) rest-client (1.6.7) mime-types (>= 1.16) @@ -215,7 +214,7 @@ GEM multi_json (~> 1.0) simplecov-html (~> 0.7.1) simplecov-html (0.7.1) - slop (2.4.3) + slop (2.4.4) sprockets (2.0.4) hike (~> 1.2) rack (~> 1.0) @@ -268,7 +267,7 @@ DEPENDENCIES pg pry rails (= 3.1.11) - rdiscount + redcarpet (~> 3.0) rspec-rails sass-rails (~> 3.1.0) semantic_menu! diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 7ad5d685..3419e0a3 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -2,4 +2,8 @@ module ApplicationHelper def program_path program "/users/#{program.author_username}/programs/#{program.slug}" end + + def markdown(text) + Redcarpet::Markdown.new(Redcarpet::Render::HTML.new(hard_wrap: true), autolink: true).render(text).html_safe + end end diff --git a/app/models/deleted_user.rb b/app/models/deleted_user.rb index 0f4f2c40..373029ed 100644 --- a/app/models/deleted_user.rb +++ b/app/models/deleted_user.rb @@ -10,4 +10,4 @@ def email def to_param 'deleted_user' end -end \ No newline at end of file +end diff --git a/app/views/answers/_list.html.haml b/app/views/answers/_list.html.haml index aa395075..41ddaea3 100644 --- a/app/views/answers/_list.html.haml +++ b/app/views/answers/_list.html.haml @@ -3,8 +3,7 @@ .meta #{link_to list.user.username, user_path(list.user)} says .description - :markdown - #{list.description} + =markdown(list.description) .links - if can? :update, list diff --git a/app/views/blog/index.html.haml b/app/views/blog/index.html.haml index 4c501ce5..aa4ebada 100644 --- a/app/views/blog/index.html.haml +++ b/app/views/blog/index.html.haml @@ -13,6 +13,5 @@ = post.created_at.strftime("Posted %B %d, %Y at %l:%M %p") .content - :markdown - #{post.content} + =markdown(post.content) diff --git a/app/views/blog/show.html.haml b/app/views/blog/show.html.haml index db5aa6e4..cd66825c 100644 --- a/app/views/blog/show.html.haml +++ b/app/views/blog/show.html.haml @@ -11,5 +11,4 @@ = @post.created_at.strftime("Posted %B %d, %Y at %l:%M %p") .content - :markdown - #{@post.content} + =markdown(@post.content) diff --git a/app/views/lessons/show.html.haml b/app/views/lessons/show.html.haml index 0174335e..27f26e1e 100644 --- a/app/views/lessons/show.html.haml +++ b/app/views/lessons/show.html.haml @@ -10,5 +10,4 @@ #lesson-content = lesson_categories @lesson - :markdown - #{@lesson.output} + =markdown(@lesson.output) diff --git a/app/views/questions/new.html.haml b/app/views/questions/new.html.haml index 12ed3887..fc5dcc8a 100644 --- a/app/views/questions/new.html.haml +++ b/app/views/questions/new.html.haml @@ -1,4 +1,4 @@ - content_for :title do New Question -= render 'form' \ No newline at end of file += render 'form' diff --git a/app/views/questions/show.html.haml b/app/views/questions/show.html.haml index 1c17aaef..b53a34b1 100644 --- a/app/views/questions/show.html.haml +++ b/app/views/questions/show.html.haml @@ -26,8 +26,7 @@ .description - :markdown - #{resource.description} + =markdown(resource.description) %h2= pluralize(resource.answers.count, "response") %ul.answers diff --git a/app/views/static/faq.html.haml b/app/views/static/faq.html.haml index f93698a7..8c2bbcb7 100644 --- a/app/views/static/faq.html.haml +++ b/app/views/static/faq.html.haml @@ -82,4 +82,4 @@ ## Thanks! - Special thanks goes out to Eric Affleck for writing this FAQ. + Special thanks goes out to Eric Affleck for writing this FAQ. \ No newline at end of file From fbd738525f49d83170195ea03f70ea11bf7d6f5c Mon Sep 17 00:00:00 2001 From: Harper Henn Date: Fri, 1 Nov 2013 12:18:03 -0400 Subject: [PATCH 134/161] Restrict access to MailerController actions --- app/controllers/mailer_controller.rb | 2 + spec/controllers/mailer_controller_spec.rb | 123 ++++++++++++++++----- 2 files changed, 99 insertions(+), 26 deletions(-) diff --git a/app/controllers/mailer_controller.rb b/app/controllers/mailer_controller.rb index 6f39a9f6..19e8eaba 100644 --- a/app/controllers/mailer_controller.rb +++ b/app/controllers/mailer_controller.rb @@ -1,4 +1,6 @@ class MailerController < ApplicationController + load_and_authorize_resource class: Message + def new @users = Array(params[:user]) @emails = User.where(:username => @users).all.map(&:email) diff --git a/spec/controllers/mailer_controller_spec.rb b/spec/controllers/mailer_controller_spec.rb index 788e28ce..c65b252a 100644 --- a/spec/controllers/mailer_controller_spec.rb +++ b/spec/controllers/mailer_controller_spec.rb @@ -3,18 +3,58 @@ describe MailerController do let(:user) { Fabricate(:user) } let(:users) { Fabricate.sequence(:user, 5)} + let(:diffusion) { Fabricate.build(:diffusion) } + + shared_examples 'unauthorized' do + it 'redirects to the login page' do + response.should redirect_to(login_path) + end + end describe "GET 'new' for a single user email" do - it "returns http success" do - get :new, user: Array(user) - response.should be_success + + context 'when user is a moderator' do + before { sign_in Fabricate(:user, moderator: true) } + it "returns http success" do + get :new, user: Array(user) + response.should be_success + end + end + + context 'when user is not a moderator' do + before do + sign_in Fabricate(:user) + get :new, user: Array(user) + end + it_behaves_like 'unauthorized' + end + + context 'when user is a guest' do + before { get :new, user: Array(user) } + it_behaves_like 'unauthorized' end end describe "GET 'new' for a diffusion" do - it "returns http success" do - get :new, user: Array(users) - response.should be_success + context 'when user is a moderator' do + before { sign_in Fabricate(:user, moderator: true) } + it "returns http success" do + get :new, user: Array(users) + response.should be_success + end + end + + context 'when user is not a moderator' do + before do + sign_in Fabricate(:user) + get :new, user: Array(users) + end + it_behaves_like 'unauthorized' + end + + context 'when user is a guest' do + before { get :new, user: Array(users) } + it_behaves_like 'unauthorized' end end @@ -23,37 +63,68 @@ @message = Fabricate.build(:message) end - it 'delivers the email' do - expect { - post :create, message: @message - }.to change {ActionMailer::Base.deliveries.size}.by(1) + context 'when user is a moderator' do + before { sign_in Fabricate(:user, moderator: true) } + it 'delivers the email' do + expect { + post :create, message: @message + }.to change {ActionMailer::Base.deliveries.size}.by(1) + end + + describe 'delivered message' do + before :each do + post :create, message: @message + end + + it "returns http success" do + response.should be_redirect + end + + it 'delivers the mail with the subject that we wanted to' do + ActionMailer::Base.deliveries.last.subject.should == @message.subject + end + + it 'delivers the mail with the body that we wanted to' do + ActionMailer::Base.deliveries.last.body.to_s.should match @message.body + end + end end - describe 'delivered message' do - before :each do + context 'when user is not a moderator' do + before do + sign_in Fabricate(:user) post :create, message: @message end + it_behaves_like 'unauthorized' + end - it "returns http success" do - response.should be_redirect - end + context 'when user is a guest' do + before { post :create, message: @message } + it_behaves_like 'unauthorized' + end + end - it 'delivers the mail with the subject that we wanted to' do - ActionMailer::Base.deliveries.last.subject.should == @message.subject + describe "POST 'create' for a diffusion" do + context 'when user is a moderator' do + before { sign_in Fabricate(:user, moderator: true) } + it "returns http success" do + expect { + post 'create', message: diffusion + }.to change {ActionMailer::Base.deliveries.size}.by(diffusion.email.size) end + end - it 'delivers the mail with the body that we wanted to' do - ActionMailer::Base.deliveries.last.body.to_s.should match @message.body + context 'when user is not a moderator' do + before do + sign_in Fabricate(:user) + post :create, message: diffusion end + it_behaves_like 'unauthorized' end - end - describe "POST 'create' for a diffusion" do - it "returns http success" do - @diffusion = Fabricate.build(:diffusion) - expect { - post 'create', message: @diffusion - }.to change {ActionMailer::Base.deliveries.size}.by(@diffusion.email.size) + context 'when user is a guest' do + before { post :create, message: diffusion } + it_behaves_like 'unauthorized' end end end From 198ae345840c544056650af1063f463af74932fd Mon Sep 17 00:00:00 2001 From: Harper Henn Date: Sun, 10 Nov 2013 10:53:50 -0500 Subject: [PATCH 135/161] Fix pagination links for support questions --- app/views/questions/index.html.haml | 2 +- features/questions_pagination.feature | 13 +++++++++++++ features/step_definitions/question_steps.rb | 16 ++++++++++++++++ lib/prefix_link_renderer.rb | 12 ++++++++++++ 4 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 features/questions_pagination.feature create mode 100644 lib/prefix_link_renderer.rb diff --git a/app/views/questions/index.html.haml b/app/views/questions/index.html.haml index cc7b8d48..41739204 100644 --- a/app/views/questions/index.html.haml +++ b/app/views/questions/index.html.haml @@ -26,4 +26,4 @@ %ul.questions = render :partial => "list", :collection => collection, :as => :question -= will_paginate += will_paginate(@questions, renderer: @support ? PrefixLinkRenderer.new('/support') : nil) diff --git a/features/questions_pagination.feature b/features/questions_pagination.feature new file mode 100644 index 00000000..3b0f35d6 --- /dev/null +++ b/features/questions_pagination.feature @@ -0,0 +1,13 @@ +Feature: Pagination for different types of questions + + As a user of the site, I can view pages of different types of questions + + Scenario: View support questions + Given support questions exist + When I visit the support questions page + Then I should see a link to the next page of support questions + + Scenario: View non-support questions + Given questions exist + When I visit the questions page + Then I should see a link to the next page of questions diff --git a/features/step_definitions/question_steps.rb b/features/step_definitions/question_steps.rb index b98c76b8..385d208e 100644 --- a/features/step_definitions/question_steps.rb +++ b/features/step_definitions/question_steps.rb @@ -76,3 +76,19 @@ def create_question_for(user) visit question_path(@question) page.should_not have_content('Delete') end + +Given /^(\w*)\s?questions exist$/ do |type| + 30.times do + Question.create(title: 'Test', description: 'Test', + support: type == 'support' ? true : false) + end +end + +When /^I visit the (\w*)\s?questions page$/ do |type| + visit(type == 'support' ? support_questions_path : questions_path) +end + +Then /^I should see a link to the next page of (\w*)\s?questions$/ do |type| + href = type == 'support' ? '/support/questions?page=2' : '/questions?page=2' + page.should have_link '2', href: href +end diff --git a/lib/prefix_link_renderer.rb b/lib/prefix_link_renderer.rb new file mode 100644 index 00000000..79efb238 --- /dev/null +++ b/lib/prefix_link_renderer.rb @@ -0,0 +1,12 @@ +class PrefixLinkRenderer < WillPaginate::ActionView::LinkRenderer + def initialize(prefix) + @prefix = prefix + super() + end + + protected + + def url(page) + @prefix + super + end +end From cd1cec8f41b7e306a3634766fae27bf947071af8 Mon Sep 17 00:00:00 2001 From: Hari Carreras Date: Sun, 17 Nov 2013 16:33:58 +0200 Subject: [PATCH 136/161] Improving css --- app/assets/stylesheets/users.css.scss | 17 ++++++++++++++++- app/views/users/index.html.haml | 8 +++----- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/app/assets/stylesheets/users.css.scss b/app/assets/stylesheets/users.css.scss index 45be3005..cd972aa5 100644 --- a/app/assets/stylesheets/users.css.scss +++ b/app/assets/stylesheets/users.css.scss @@ -20,4 +20,19 @@ } } } -} \ No newline at end of file +} + +.title { + display: inline; + margin-right: 10px; + margin: 0px; +} + +#user-list { + li { + list-style-type: none; + padding-bottom: 3px; + padding-top: 3px; + } +} + diff --git a/app/views/users/index.html.haml b/app/views/users/index.html.haml index 8c9d2495..2a365243 100644 --- a/app/views/users/index.html.haml +++ b/app/views/users/index.html.haml @@ -1,10 +1,8 @@ =link_to "Create a diffusion", mailer_path(:user => User.all) -%ul +%ul#user-list - @users.each do |user| %li - .info - .title= user.username - .categories - .btn.success= link_to "Email him", mailer_path(:user => user) + .title= user.username + = link_to "Email him", mailer_path(:user => user), :class => "btn small info" = will_paginate @users \ No newline at end of file From 5170c66917c36e6967d4e01d1b8fe45cade8f186 Mon Sep 17 00:00:00 2001 From: Hari Carreras Date: Sun, 9 Feb 2014 18:22:06 +0200 Subject: [PATCH 137/161] Added user follow testing --- app/models/user.rb | 2 +- spec/following_policy_spec.rb | 10 +++++----- spec/models/user_spec.rb | 19 +++++++++++++++++++ 3 files changed, 25 insertions(+), 6 deletions(-) create mode 100644 spec/models/user_spec.rb diff --git a/app/models/user.rb b/app/models/user.rb index d03c5668..0f5255b7 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -79,7 +79,7 @@ def unfollow! followee # this method returns true if we're following the given Hacker, and # false otherwise def following? hacker - following.include? hacker + following_ids.include? hacker.id end # Everyone should have at least one follower. And steve would like to follow diff --git a/spec/following_policy_spec.rb b/spec/following_policy_spec.rb index ae9c2ec2..0a855bbc 100644 --- a/spec/following_policy_spec.rb +++ b/spec/following_policy_spec.rb @@ -1,28 +1,28 @@ require_relative '../app/models/following_policy' describe FollowingPolicy do - before(:each) do + before(:each) do @followee = double 'followee' @follower = double 'follower' end - + it 'can follow another' do @follower.should_receive(:following?).with(@followee).and_return(false) policy = FollowingPolicy.new(@follower) policy.can_follow?(@followee).should be_true end - + it "cannot follow self" do policy = FollowingPolicy.new(@follower) policy.following_self?(@follower).should be_true policy.can_follow?(@follower).should be_false end - + it "cannot follow twice" do @follower.should_receive(:following?).twice.with(@followee).and_return(true) policy = FollowingPolicy.new(@follower) policy.already_following?(@followee).should be_true policy.can_follow?(@followee).should be_false end - + end diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb new file mode 100644 index 00000000..6f87a5b6 --- /dev/null +++ b/spec/models/user_spec.rb @@ -0,0 +1,19 @@ +require 'spec_helper' + +describe User do + + let(:bob){Fabricate(:user)} + let(:mozart){Fabricate(:user)} + + it 'can be created validly' do + bob.should be_valid + mozart.should be_valid + end + + it 'Users can follow and unfollow' do + bob.follow!(mozart) + bob.following?(mozart).should be_true + bob.unfollow!(mozart) + bob.following?(mozart).should be_false + end +end \ No newline at end of file From bd8fee2e42a87258b06653a5d8c63ad80fc4e0f6 Mon Sep 17 00:00:00 2001 From: Hari Carreras Date: Mon, 10 Feb 2014 19:08:12 +0200 Subject: [PATCH 138/161] Fixed model reload --- app/models/user.rb | 2 +- spec/models/user_spec.rb | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/app/models/user.rb b/app/models/user.rb index 0f5255b7..d03c5668 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -79,7 +79,7 @@ def unfollow! followee # this method returns true if we're following the given Hacker, and # false otherwise def following? hacker - following_ids.include? hacker.id + following.include? hacker end # Everyone should have at least one follower. And steve would like to follow diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 6f87a5b6..39a70431 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -14,6 +14,7 @@ bob.follow!(mozart) bob.following?(mozart).should be_true bob.unfollow!(mozart) + bob.reload bob.following?(mozart).should be_false end end \ No newline at end of file From aa595b5c4c1ea157dbc9d095854dd8fb6a61792d Mon Sep 17 00:00:00 2001 From: Tobias Pfeiffer Date: Wed, 12 Feb 2014 23:30:27 +0100 Subject: [PATCH 139/161] Bundle exec all the travis things --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index cdc86e9a..a9a71640 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,5 @@ language: ruby -script: "rake spec && rake cucumber" +script: "bundle exec rake spec cucumber" rvm: 1.9.3 services: mongodb notifications: From 1f7329702e13f6d696ccc533d09cb391a58767db Mon Sep 17 00:00:00 2001 From: Hari Carreras Date: Thu, 13 Feb 2014 12:48:01 +0200 Subject: [PATCH 140/161] Added User index spec --- spec/controllers/user_controller_spec.rb | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 spec/controllers/user_controller_spec.rb diff --git a/spec/controllers/user_controller_spec.rb b/spec/controllers/user_controller_spec.rb new file mode 100644 index 00000000..11ab8bc8 --- /dev/null +++ b/spec/controllers/user_controller_spec.rb @@ -0,0 +1,23 @@ +require 'spec_helper' + +describe UsersController do + let(:bob){Fabricate(:user)} + let(:mozart){Fabricate(:user)} + + describe('#index') do + context "When user is no moderator" do + it "try to get index" do + get :index + response.should redirect_to(root_path) + end + end + + context "When user is moderator" do + before { sign_in Fabricate(:user, moderator: true) } + it "gets index with authorization" do + get :index + response.should be_success + end + end + end +end From 60c2d069096c76834a5da61be484721d6ed677f8 Mon Sep 17 00:00:00 2001 From: Hari Carreras Date: Thu, 13 Feb 2014 14:13:39 +0200 Subject: [PATCH 141/161] Added User controller follow spec --- spec/controllers/user_controller_spec.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/spec/controllers/user_controller_spec.rb b/spec/controllers/user_controller_spec.rb index 11ab8bc8..2c3456e2 100644 --- a/spec/controllers/user_controller_spec.rb +++ b/spec/controllers/user_controller_spec.rb @@ -20,4 +20,12 @@ end end end + + describe 'Following actions' do + before { sign_in bob } + it('#follow') do + post :follow, user_id: bob, :user => {:followee => mozart.id} + expect(flash[:notice]).to eq("You're following #{mozart.username} now") + end + end end From 1f1f79f620f7bda0c1d7180d34cd7661e0fa4045 Mon Sep 17 00:00:00 2001 From: Hari Carreras Date: Thu, 13 Feb 2014 14:52:49 +0200 Subject: [PATCH 142/161] Added following and followers controller spec --- spec/controllers/user_controller_spec.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/spec/controllers/user_controller_spec.rb b/spec/controllers/user_controller_spec.rb index 2c3456e2..6e836352 100644 --- a/spec/controllers/user_controller_spec.rb +++ b/spec/controllers/user_controller_spec.rb @@ -27,5 +27,13 @@ post :follow, user_id: bob, :user => {:followee => mozart.id} expect(flash[:notice]).to eq("You're following #{mozart.username} now") end + it('#following?') do + get :following, user_id: bob + response.should be_success + end + it ('#followers') do + get :followers, user_id: bob + response.should be_success + end end end From e855ed0d255a7ad37bb2bb481598392aa233e47c Mon Sep 17 00:00:00 2001 From: Hari Carreras Date: Thu, 13 Feb 2014 15:25:13 +0200 Subject: [PATCH 143/161] Added spec user controller follow just once --- spec/controllers/user_controller_spec.rb | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/spec/controllers/user_controller_spec.rb b/spec/controllers/user_controller_spec.rb index 6e836352..d7b76a40 100644 --- a/spec/controllers/user_controller_spec.rb +++ b/spec/controllers/user_controller_spec.rb @@ -23,17 +23,31 @@ describe 'Following actions' do before { sign_in bob } - it('#follow') do + it('Try to follow himself') do + post :follow, user_id: bob, :user => {:followee => bob.id} + expect(flash[:notice]).to eq("You can't follow yourself silly!") + end + + it('#follow just once') do post :follow, user_id: bob, :user => {:followee => mozart.id} expect(flash[:notice]).to eq("You're following #{mozart.username} now") + post :follow, user_id: bob, :user => {:followee => mozart.id} + expect(flash[:notice]).to eq("You're already following #{mozart.username}") end + it('#following?') do get :following, user_id: bob response.should be_success end + it ('#followers') do get :followers, user_id: bob response.should be_success end + + it ('#unfollow') do + post :unfollow, user_id: bob, :user => {:followee => mozart.id} + expect(flash[:notice]).to eq("You're no longer following #{mozart.username}") + end end end From 02c1a9ea472c33e1feba236eeb68c29010e26c73 Mon Sep 17 00:00:00 2001 From: Hari Carreras Date: Fri, 14 Feb 2014 16:58:03 +0200 Subject: [PATCH 144/161] Fixed indentation --- spec/controllers/user_controller_spec.rb | 84 ++++++++++++++---------- 1 file changed, 49 insertions(+), 35 deletions(-) diff --git a/spec/controllers/user_controller_spec.rb b/spec/controllers/user_controller_spec.rb index 6e836352..b8de6eac 100644 --- a/spec/controllers/user_controller_spec.rb +++ b/spec/controllers/user_controller_spec.rb @@ -1,39 +1,53 @@ require 'spec_helper' describe UsersController do - let(:bob){Fabricate(:user)} - let(:mozart){Fabricate(:user)} - - describe('#index') do - context "When user is no moderator" do - it "try to get index" do - get :index - response.should redirect_to(root_path) - end - end - - context "When user is moderator" do - before { sign_in Fabricate(:user, moderator: true) } - it "gets index with authorization" do - get :index - response.should be_success - end - end - end - - describe 'Following actions' do - before { sign_in bob } - it('#follow') do - post :follow, user_id: bob, :user => {:followee => mozart.id} - expect(flash[:notice]).to eq("You're following #{mozart.username} now") - end - it('#following?') do - get :following, user_id: bob - response.should be_success - end - it ('#followers') do - get :followers, user_id: bob - response.should be_success - end - end + let(:bob){Fabricate(:user)} + let(:mozart){Fabricate(:user)} + + describe('#index') do + context "When user is no moderator" do + it "try to get index" do + get :index + response.should redirect_to(root_path) + end + end + + context "When user is moderator" do + before { sign_in Fabricate(:user, moderator: true) } + it "gets index with authorization" do + get :index + response.should be_success + end + end + end + + describe 'Following actions' do + before { sign_in bob } + it('Try to follow himself') do + post :follow, user_id: bob, :user => {:followee => bob.id} + expect(flash[:notice]).to eq("You can't follow yourself silly!") + end + + it('#follow just once') do + post :follow, user_id: bob, :user => {:followee => mozart.id} + expect(flash[:notice]).to eq("You're following #{mozart.username} now") + post :follow, user_id: bob, :user => {:followee => mozart.id} + expect(flash[:notice]).to eq("You're already following #{mozart.username}") + end + + it('#following?') do + get :following, user_id: bob + response.should be_success + end + + it ('#followers') do + get :followers, user_id: bob + response.should be_success + end + + it ('#unfollow') do + post :unfollow, user_id: bob, :user => {:followee => mozart.id} + expect(flash[:notice]).to eq("You're no longer following #{mozart.username}") + end + end end From 3a0eaba4274b19c3e390cea9fcf19de7fdba6a3e Mon Sep 17 00:00:00 2001 From: Hari Carreras Date: Fri, 14 Feb 2014 17:03:53 +0200 Subject: [PATCH 145/161] Added User spec controller --- spec/controllers/user_controller_spec.rb | 53 ++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 spec/controllers/user_controller_spec.rb diff --git a/spec/controllers/user_controller_spec.rb b/spec/controllers/user_controller_spec.rb new file mode 100644 index 00000000..b8de6eac --- /dev/null +++ b/spec/controllers/user_controller_spec.rb @@ -0,0 +1,53 @@ +require 'spec_helper' + +describe UsersController do + let(:bob){Fabricate(:user)} + let(:mozart){Fabricate(:user)} + + describe('#index') do + context "When user is no moderator" do + it "try to get index" do + get :index + response.should redirect_to(root_path) + end + end + + context "When user is moderator" do + before { sign_in Fabricate(:user, moderator: true) } + it "gets index with authorization" do + get :index + response.should be_success + end + end + end + + describe 'Following actions' do + before { sign_in bob } + it('Try to follow himself') do + post :follow, user_id: bob, :user => {:followee => bob.id} + expect(flash[:notice]).to eq("You can't follow yourself silly!") + end + + it('#follow just once') do + post :follow, user_id: bob, :user => {:followee => mozart.id} + expect(flash[:notice]).to eq("You're following #{mozart.username} now") + post :follow, user_id: bob, :user => {:followee => mozart.id} + expect(flash[:notice]).to eq("You're already following #{mozart.username}") + end + + it('#following?') do + get :following, user_id: bob + response.should be_success + end + + it ('#followers') do + get :followers, user_id: bob + response.should be_success + end + + it ('#unfollow') do + post :unfollow, user_id: bob, :user => {:followee => mozart.id} + expect(flash[:notice]).to eq("You're no longer following #{mozart.username}") + end + end +end From 99dbcef8333525742587b457eacc0f517dcda567 Mon Sep 17 00:00:00 2001 From: Hari Carreras Date: Fri, 14 Feb 2014 18:01:19 +0200 Subject: [PATCH 146/161] Fixed some syntax details --- spec/controllers/user_controller_spec.rb | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/spec/controllers/user_controller_spec.rb b/spec/controllers/user_controller_spec.rb index b8de6eac..be688723 100644 --- a/spec/controllers/user_controller_spec.rb +++ b/spec/controllers/user_controller_spec.rb @@ -4,11 +4,11 @@ let(:bob){Fabricate(:user)} let(:mozart){Fabricate(:user)} - describe('#index') do + describe '#index' do context "When user is no moderator" do it "try to get index" do get :index - response.should redirect_to(root_path) + expect(response).to redirect_to(root_path) end end @@ -23,29 +23,29 @@ describe 'Following actions' do before { sign_in bob } - it('Try to follow himself') do + it 'Try to follow himself' do post :follow, user_id: bob, :user => {:followee => bob.id} expect(flash[:notice]).to eq("You can't follow yourself silly!") end - it('#follow just once') do + it '#follow just once' do post :follow, user_id: bob, :user => {:followee => mozart.id} expect(flash[:notice]).to eq("You're following #{mozart.username} now") post :follow, user_id: bob, :user => {:followee => mozart.id} expect(flash[:notice]).to eq("You're already following #{mozart.username}") end - it('#following?') do + it '#following?' do get :following, user_id: bob response.should be_success end - it ('#followers') do + it '#followers' do get :followers, user_id: bob response.should be_success end - it ('#unfollow') do + it '#unfollow' do post :unfollow, user_id: bob, :user => {:followee => mozart.id} expect(flash[:notice]).to eq("You're no longer following #{mozart.username}") end From 01886c8cd0f14700b4bb4784214f5a6565eee124 Mon Sep 17 00:00:00 2001 From: Artur Gaifutdinov Date: Wed, 19 Feb 2014 18:20:04 -0500 Subject: [PATCH 147/161] Upgraded to rails 3.2.16 --- Gemfile | 22 +- Gemfile.lock | 310 +++++++++---------- app/views/layouts/application.html.haml | 2 +- features/step_definitions/blog_steps.rb | 4 +- features/step_definitions/program_steps.rb | 4 +- features/step_definitions/user_steps.rb | 2 +- script/bootstrap | 2 +- spec/helpers/blog_helper_spec.rb | 15 - spec/views/questions/index.html.haml_spec.rb | 5 +- 9 files changed, 174 insertions(+), 192 deletions(-) delete mode 100644 spec/helpers/blog_helper_spec.rb diff --git a/Gemfile b/Gemfile index 67a67897..1e301a1a 100644 --- a/Gemfile +++ b/Gemfile @@ -5,7 +5,7 @@ source 'http://rubygems.org' ruby '1.9.3' -gem 'rails', '3.1.11' +gem 'rails', '3.2.16' gem 'json' gem 'hackety_hack-lessons', '~> 1.1', :require => 'hackety_hack/lessons' @@ -16,15 +16,7 @@ gem 'mongo_mapper' gem 'bson_ext' gem "letter_opener", group: :development - -# Gems used only for assets and not required -# in production environments by default. -group :assets do - gem 'sass-rails', "~> 3.1.0" - gem 'coffee-rails', "~> 3.1.0" - gem 'uglifier' -end - + gem "devise", "~> 2.2.2" gem 'mm-devise', '~> 2.0' gem 'cancan' @@ -36,6 +28,14 @@ gem "semantic_menu", git: "git://github.com/michaek/semantic_menu.git" gem 'will_paginate' # Pagination gem 'redcarpet', '~> 3.0' # Markdown +# Gems used only for assets and not required +# in production environments by default. +group :assets do + gem 'sass-rails' + gem 'coffee-rails' + gem 'uglifier' +end + group :development do # Use unicorn as the web server gem 'unicorn' @@ -49,8 +49,6 @@ group :development, :test do gem "faker" gem 'pry' gem 'sqlite3' - - end group :production do diff --git a/Gemfile.lock b/Gemfile.lock index 098507ce..55fce1e3 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -15,229 +15,227 @@ GIT GEM remote: http://rubygems.org/ specs: - actionmailer (3.1.11) - actionpack (= 3.1.11) - mail (~> 2.3.3) - actionpack (3.1.11) - activemodel (= 3.1.11) - activesupport (= 3.1.11) + actionmailer (3.2.16) + actionpack (= 3.2.16) + mail (~> 2.5.4) + actionpack (3.2.16) + activemodel (= 3.2.16) + activesupport (= 3.2.16) builder (~> 3.0.0) erubis (~> 2.7.0) - i18n (~> 0.6) - rack (~> 1.3.6) + journey (~> 1.0.4) + rack (~> 1.4.5) rack-cache (~> 1.2) - rack-mount (~> 0.8.2) rack-test (~> 0.6.1) - sprockets (~> 2.0.4) - activemodel (3.1.11) - activesupport (= 3.1.11) + sprockets (~> 2.2.1) + activemodel (3.2.16) + activesupport (= 3.2.16) builder (~> 3.0.0) - i18n (~> 0.6) - activerecord (3.1.11) - activemodel (= 3.1.11) - activesupport (= 3.1.11) - arel (~> 2.2.3) + activerecord (3.2.16) + activemodel (= 3.2.16) + activesupport (= 3.2.16) + arel (~> 3.0.2) tzinfo (~> 0.3.29) - activeresource (3.1.11) - activemodel (= 3.1.11) - activesupport (= 3.1.11) - activesupport (3.1.11) + activeresource (3.2.16) + activemodel (= 3.2.16) + activesupport (= 3.2.16) + activesupport (3.2.16) + i18n (~> 0.6, >= 0.6.4) multi_json (~> 1.0) - addressable (2.2.6) - arel (2.2.3) - bcrypt-ruby (3.0.1) - bson (1.5.2) - bson_ext (1.5.2) - bson (= 1.5.2) + addressable (2.3.5) + arel (3.0.3) + bcrypt-ruby (3.1.2) + bson (1.9.2) + bson_ext (1.9.2) + bson (~> 1.9.2) builder (3.0.4) - cancan (1.6.7) - capybara (1.1.2) + cancan (1.6.10) + capybara (2.2.1) mime-types (>= 1.16) nokogiri (>= 1.3.3) rack (>= 1.0.0) rack-test (>= 0.5.4) - selenium-webdriver (~> 2.0) - xpath (~> 0.1.4) - childprocess (0.3.0) - ffi (~> 1.0.6) - coderay (1.0.5) - coffee-rails (3.1.1) + xpath (~> 2.0) + coderay (1.1.0) + coffee-rails (3.2.2) coffee-script (>= 2.2.0) - railties (~> 3.1.0) + railties (~> 3.2.0) coffee-script (2.2.0) coffee-script-source execjs - coffee-script-source (1.2.0) - colorize (0.5.8) - coveralls (0.5.8) - colorize - json + coffee-script-source (1.7.0) + coveralls (0.7.0) + multi_json (~> 1.3) rest-client simplecov (>= 0.7) + term-ansicolor thor - cucumber (1.1.4) + cucumber (1.3.10) builder (>= 2.1.2) - diff-lcs (>= 1.1.2) - gherkin (~> 2.7.1) - json (>= 1.4.6) - term-ansicolor (>= 1.0.6) - cucumber-rails (1.2.1) + diff-lcs (>= 1.1.3) + gherkin (~> 2.12) + multi_json (>= 1.7.5, < 2.0) + multi_test (>= 0.0.2) + cucumber-rails (1.4.0) capybara (>= 1.1.2) - cucumber (>= 1.1.3) + cucumber (>= 1.2.0) nokogiri (>= 1.5.0) - database_cleaner (0.7.1) - devise (2.2.2) + rails (>= 3.0.0) + database_cleaner (1.2.0) + devise (2.2.8) bcrypt-ruby (~> 3.0) orm_adapter (~> 0.1) railties (~> 3.1) warden (~> 1.2.1) - diff-lcs (1.2.4) + diff-lcs (1.2.5) + docile (1.1.3) erubis (2.7.0) - execjs (1.3.0) - multi_json (~> 1.0) - fabrication (2.8.1) - faker (1.0.1) - i18n (~> 0.4) - ffi (1.0.11) - gherkin (2.7.6) - json (>= 1.4.6) + execjs (2.0.2) + fabrication (2.9.8) + faker (1.2.0) + i18n (~> 0.5) + gherkin (2.12.2) + multi_json (~> 1.3) hackety_hack-lessons (1.1.2) metadown - haml (3.1.4) - haml-rails (0.3.4) - actionpack (~> 3.0) - activesupport (~> 3.0) - haml (~> 3.0) - railties (~> 3.0) - has_scope (0.5.1) + haml (4.0.5) + tilt + haml-rails (0.4) + actionpack (>= 3.1, < 4.1) + activesupport (>= 3.1, < 4.1) + haml (>= 3.1, < 4.1) + railties (>= 3.1, < 4.1) + has_scope (0.6.0.rc) + actionpack (>= 3.2, < 5) + activesupport (>= 3.2, < 5) hike (1.2.3) - i18n (0.6.5) - inherited_resources (1.3.0) - has_scope (~> 0.5.0) - responders (~> 0.6.0) - jquery-rails (1.0.19) - railties (~> 3.0) - thor (~> 0.14) - json (1.8.0) - kgio (2.7.2) - launchy (2.0.5) - addressable (~> 2.2.6) - letter_opener (1.0.0) - launchy (>= 2.0.4) - mail (2.3.3) - i18n (>= 0.4.0) + i18n (0.6.9) + inherited_resources (1.4.1) + has_scope (~> 0.6.0.rc) + responders (~> 1.0.0.rc) + journey (1.0.4) + jquery-rails (3.1.0) + railties (>= 3.0, < 5.0) + thor (>= 0.14, < 2.0) + json (1.8.1) + kgio (2.9.2) + launchy (2.4.2) + addressable (~> 2.3) + letter_opener (1.2.0) + launchy (~> 2.2) + mail (2.5.4) mime-types (~> 1.16) treetop (~> 1.4.8) - metaclass (0.0.1) + metaclass (0.0.3) metadown (1.0.1) redcarpet - method_source (0.7.0) - mime-types (1.21) + method_source (0.8.2) + mime-types (1.25.1) + mini_portile (0.5.2) mm-devise (2.0) devise (>= 1.2) mongo_mapper (>= 0.9.0) - mocha (0.10.3) + mocha (1.0.0) metaclass (~> 0.0.1) - mongo (1.5.2) - bson (= 1.5.2) - mongo_mapper (0.10.1) + mongo (1.9.2) + bson (~> 1.9.2) + mongo_mapper (0.12.0) activemodel (~> 3.0) activesupport (~> 3.0) - plucky (~> 0.4.0) - multi_json (1.0.4) - nokogiri (1.5.0) - orm_adapter (0.4.0) - pg (0.12.2) - plucky (0.4.4) + plucky (~> 0.5.2) + multi_json (1.8.4) + multi_test (0.0.3) + nokogiri (1.6.1) + mini_portile (~> 0.5.0) + orm_adapter (0.5.0) + pg (0.17.1) + plucky (0.5.2) mongo (~> 1.5) - polyglot (0.3.3) - pry (0.9.8) - coderay (~> 1.0.5) - method_source (~> 0.7) - slop (>= 2.4.3, < 3) - rack (1.3.10) + polyglot (0.3.4) + pry (0.9.12.6) + coderay (~> 1.0) + method_source (~> 0.8) + slop (~> 3.4) + rack (1.4.5) rack-cache (1.2) rack (>= 0.4) - rack-mount (0.8.3) - rack (>= 1.0.0) rack-ssl (1.3.3) rack rack-test (0.6.2) rack (>= 1.0) - rails (3.1.11) - actionmailer (= 3.1.11) - actionpack (= 3.1.11) - activerecord (= 3.1.11) - activeresource (= 3.1.11) - activesupport (= 3.1.11) + rails (3.2.16) + actionmailer (= 3.2.16) + actionpack (= 3.2.16) + activerecord (= 3.2.16) + activeresource (= 3.2.16) + activesupport (= 3.2.16) bundler (~> 1.0) - railties (= 3.1.11) - railties (3.1.11) - actionpack (= 3.1.11) - activesupport (= 3.1.11) + railties (= 3.2.16) + railties (3.2.16) + actionpack (= 3.2.16) + activesupport (= 3.2.16) rack-ssl (~> 1.3.2) rake (>= 0.8.7) rdoc (~> 3.4) - thor (~> 0.14.6) - raindrops (0.8.0) - rake (10.1.0) + thor (>= 0.14.6, < 2.0) + raindrops (0.13.0) + rake (10.1.1) rdoc (3.12.2) json (~> 1.4) - redcarpet (3.0.0) - responders (0.6.5) + redcarpet (3.1.1) + responders (1.0.0) + railties (>= 3.2, < 5) rest-client (1.6.7) mime-types (>= 1.16) - rspec-core (2.14.5) - rspec-expectations (2.14.3) + rspec-core (2.14.7) + rspec-expectations (2.14.5) diff-lcs (>= 1.1.3, < 2.0) - rspec-mocks (2.14.3) - rspec-rails (2.14.0) + rspec-mocks (2.14.5) + rspec-rails (2.14.1) actionpack (>= 3.0) + activemodel (>= 3.0) activesupport (>= 3.0) railties (>= 3.0) rspec-core (~> 2.14.0) rspec-expectations (~> 2.14.0) rspec-mocks (~> 2.14.0) - rubyzip (0.9.5) - sass (3.1.12) - sass-rails (3.1.5) - actionpack (~> 3.1.0) - railties (~> 3.1.0) - sass (~> 3.1.10) - tilt (~> 1.3.2) - selenium-webdriver (2.17.0) - childprocess (>= 0.2.5) - ffi (~> 1.0.9) - multi_json (~> 1.0.4) - rubyzip - simplecov (0.7.1) - multi_json (~> 1.0) - simplecov-html (~> 0.7.1) - simplecov-html (0.7.1) - slop (2.4.4) - sprockets (2.0.4) + sass (3.2.14) + sass-rails (3.2.6) + railties (~> 3.2.0) + sass (>= 3.1.10) + tilt (~> 1.3) + simplecov (0.8.2) + docile (~> 1.1.0) + multi_json + simplecov-html (~> 0.8.0) + simplecov-html (0.8.0) + slop (3.4.7) + sprockets (2.2.2) hike (~> 1.2) + multi_json (~> 1.0) rack (~> 1.0) tilt (~> 1.1, != 1.3.0) - sqlite3 (1.3.5) - term-ansicolor (1.0.7) - thor (0.14.6) - tilt (1.3.7) - treetop (1.4.12) + sqlite3 (1.3.8) + term-ansicolor (1.3.0) + tins (~> 1.0) + thor (0.18.1) + tilt (1.4.1) + tins (1.0.0) + treetop (1.4.15) polyglot polyglot (>= 0.3.1) - tzinfo (0.3.35) - uglifier (1.2.2) + tzinfo (0.3.38) + uglifier (2.4.0) execjs (>= 0.3.0) - multi_json (>= 1.0.2) - unicorn (4.1.1) - kgio (~> 2.4) + json (>= 1.8.0) + unicorn (4.8.2) + kgio (~> 2.6) rack - raindrops (~> 0.6) - warden (1.2.1) + raindrops (~> 0.7) + warden (1.2.3) rack (>= 1.0) - will_paginate (3.0.2) - xpath (0.1.4) + will_paginate (3.0.5) + xpath (2.0.0) nokogiri (~> 1.3) PLATFORMS @@ -247,7 +245,7 @@ DEPENDENCIES bson_ext cancan capybara - coffee-rails (~> 3.1.0) + coffee-rails coveralls cucumber-rails database_cleaner @@ -266,10 +264,10 @@ DEPENDENCIES mongo_mapper pg pry - rails (= 3.1.11) + rails (= 3.2.16) redcarpet (~> 3.0) rspec-rails - sass-rails (~> 3.1.0) + sass-rails semantic_menu! simple_form! simplecov diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 383cd89a..bad870f4 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -3,7 +3,7 @@ %html %head - title = yield :title - %title #{title.blank? ? "" : "#{title} | "}Hackety Hack! + %title=(title.blank? ? "" : title.gsub("\n", "")) + " | Hackety Hack!" / diff --git a/features/step_definitions/blog_steps.rb b/features/step_definitions/blog_steps.rb index 02d8b0e6..a200644e 100644 --- a/features/step_definitions/blog_steps.rb +++ b/features/step_definitions/blog_steps.rb @@ -29,8 +29,8 @@ @post = OpenStruct.new @post.title = "A title" - fill_in :title, :with => "A title" - fill_in :content, :with => "Some content" + fill_in :blog_post_title, :with => "A title" + fill_in :blog_post_content, :with => "Some content" end When /^I press "([^"]*)"$/ do |name| diff --git a/features/step_definitions/program_steps.rb b/features/step_definitions/program_steps.rb index 0fd28f2f..619e275c 100644 --- a/features/step_definitions/program_steps.rb +++ b/features/step_definitions/program_steps.rb @@ -1,4 +1,4 @@ -Given /^there is a featured program$/ do + Given /^there is a featured program$/ do @program = Program.create!(:author_username => "username", :slug => "slug", :title => "My Featured Program", @@ -56,7 +56,7 @@ def visit_user_programs_page When /^I click the first program link$/ do within "#all-programs ul" do - find("li:first-child a").click() + first("li:first-child a").click() end end diff --git a/features/step_definitions/user_steps.rb b/features/step_definitions/user_steps.rb index a1fea7b0..c3395f59 100644 --- a/features/step_definitions/user_steps.rb +++ b/features/step_definitions/user_steps.rb @@ -25,7 +25,7 @@ def create_other_user end Then /^it should have the right information$/ do - page.should have_selector('title', :content => "#{@user.username}'s page") + page.should have_title("#{@user.username}'s Profile\n | Hackety Hack!") page.should have_content("#{@user.username}'s Profile") end diff --git a/script/bootstrap b/script/bootstrap index b2daad6e..de77ea4d 100755 --- a/script/bootstrap +++ b/script/bootstrap @@ -1,4 +1,4 @@ -#!/bin/dash +#!/bin/bash go_go_gadget_bootstrap() { check_ruby diff --git a/spec/helpers/blog_helper_spec.rb b/spec/helpers/blog_helper_spec.rb deleted file mode 100644 index bef6d821..00000000 --- a/spec/helpers/blog_helper_spec.rb +++ /dev/null @@ -1,15 +0,0 @@ -require 'spec_helper' - -# Specs in this file have access to a helper object that includes -# the BlogHelper. For example: -# -# describe BlogHelper do -# describe "string concat" do -# it "concats two strings with spaces" do -# helper.concat_strings("this","that").should == "this that" -# end -# end -# end -describe BlogHelper do - pending "add some examples to (or delete) #{__FILE__}" -end diff --git a/spec/views/questions/index.html.haml_spec.rb b/spec/views/questions/index.html.haml_spec.rb index 8bcadc85..f371781c 100644 --- a/spec/views/questions/index.html.haml_spec.rb +++ b/spec/views/questions/index.html.haml_spec.rb @@ -13,6 +13,7 @@ it "renders an autodiscovery link in for the head content" do render :template => "questions/index.html.haml", :locals => {:collection => [question]} - view.content_for(:head).should have_selector("link", :href => questions_url(format: :atom)) + + view.content_for(:head).should include(questions_url(format: :atom)) end -end +end \ No newline at end of file From 61a9647ab091d70c4552d8f40ca89cd36883b92c Mon Sep 17 00:00:00 2001 From: Artur Gaifutdinov Date: Thu, 20 Feb 2014 10:37:25 -0500 Subject: [PATCH 148/161] Rails 3.2.17 --- Gemfile | 2 +- Gemfile.lock | 50 +++++++++++++++++++++++++------------------------- 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/Gemfile b/Gemfile index 1e301a1a..4bf72113 100644 --- a/Gemfile +++ b/Gemfile @@ -5,7 +5,7 @@ source 'http://rubygems.org' ruby '1.9.3' -gem 'rails', '3.2.16' +gem 'rails', '3.2.17' gem 'json' gem 'hackety_hack-lessons', '~> 1.1', :require => 'hackety_hack/lessons' diff --git a/Gemfile.lock b/Gemfile.lock index 55fce1e3..3d8a7b9f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -15,12 +15,12 @@ GIT GEM remote: http://rubygems.org/ specs: - actionmailer (3.2.16) - actionpack (= 3.2.16) + actionmailer (3.2.17) + actionpack (= 3.2.17) mail (~> 2.5.4) - actionpack (3.2.16) - activemodel (= 3.2.16) - activesupport (= 3.2.16) + actionpack (3.2.17) + activemodel (= 3.2.17) + activesupport (= 3.2.17) builder (~> 3.0.0) erubis (~> 2.7.0) journey (~> 1.0.4) @@ -28,18 +28,18 @@ GEM rack-cache (~> 1.2) rack-test (~> 0.6.1) sprockets (~> 2.2.1) - activemodel (3.2.16) - activesupport (= 3.2.16) + activemodel (3.2.17) + activesupport (= 3.2.17) builder (~> 3.0.0) - activerecord (3.2.16) - activemodel (= 3.2.16) - activesupport (= 3.2.16) + activerecord (3.2.17) + activemodel (= 3.2.17) + activesupport (= 3.2.17) arel (~> 3.0.2) tzinfo (~> 0.3.29) - activeresource (3.2.16) - activemodel (= 3.2.16) - activesupport (= 3.2.16) - activesupport (3.2.16) + activeresource (3.2.17) + activemodel (= 3.2.17) + activesupport (= 3.2.17) + activesupport (3.2.17) i18n (~> 0.6, >= 0.6.4) multi_json (~> 1.0) addressable (2.3.5) @@ -163,17 +163,17 @@ GEM rack rack-test (0.6.2) rack (>= 1.0) - rails (3.2.16) - actionmailer (= 3.2.16) - actionpack (= 3.2.16) - activerecord (= 3.2.16) - activeresource (= 3.2.16) - activesupport (= 3.2.16) + rails (3.2.17) + actionmailer (= 3.2.17) + actionpack (= 3.2.17) + activerecord (= 3.2.17) + activeresource (= 3.2.17) + activesupport (= 3.2.17) bundler (~> 1.0) - railties (= 3.2.16) - railties (3.2.16) - actionpack (= 3.2.16) - activesupport (= 3.2.16) + railties (= 3.2.17) + railties (3.2.17) + actionpack (= 3.2.17) + activesupport (= 3.2.17) rack-ssl (~> 1.3.2) rake (>= 0.8.7) rdoc (~> 3.4) @@ -264,7 +264,7 @@ DEPENDENCIES mongo_mapper pg pry - rails (= 3.2.16) + rails (= 3.2.17) redcarpet (~> 3.0) rspec-rails sass-rails From 27911d73883d2876ab21b144c75bbefe9b3e3327 Mon Sep 17 00:00:00 2001 From: Artur-Gaifutdinov Date: Tue, 25 Feb 2014 21:59:11 -0500 Subject: [PATCH 149/161] Fixed view of blog's admin panel --- app/views/blog/admin.html.haml | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/app/views/blog/admin.html.haml b/app/views/blog/admin.html.haml index e5f17e1a..03c9bea9 100644 --- a/app/views/blog/admin.html.haml +++ b/app/views/blog/admin.html.haml @@ -1,12 +1,13 @@ %h1 Blog Admin %h2 New Post -= form_for @post, :url => blog_index_path do |f| - = f.label :title - = f.text_field :title - = f.label :content - = f.text_area :content - = f.submit += simple_form_for @post, :url => blog_index_path do |f| + .inputs + = f.input :title + = f.input :content, :as => :text + + .actions + = f.button :submit, :value => "Create Blog post", :class => "primary btn" %h2 All Posts %ul From e54a48e732a606ee13d59179ba4abe996d14e2e8 Mon Sep 17 00:00:00 2001 From: Artur-Gaifutdinov Date: Wed, 26 Feb 2014 20:56:40 -0500 Subject: [PATCH 150/161] Increase tests coverage --- Gemfile | 1 + Gemfile.lock | 8 ++++++++ app/controllers/answers_controller.rb | 2 -- app/controllers/static_controller.rb | 11 +++++------ features/answers.feature | 7 +++++-- features/blog.feature | 5 ++++- features/lessons.feature | 13 +++++++++++++ features/moderator.feature | 3 ++- features/programs.feature | 3 +++ features/questions.feature | 3 +++ features/signup.feature | 3 +++ features/statics.feature | 19 +++++++++++++++++++ features/step_definitions/lesson_steps.rb | 17 +++++++++++++++++ features/step_definitions/static_steps.rb | 8 ++++++++ features/support/env.rb | 1 + features/users.feature | 5 +++-- 16 files changed, 95 insertions(+), 14 deletions(-) create mode 100644 features/lessons.feature create mode 100644 features/statics.feature create mode 100644 features/step_definitions/lesson_steps.rb create mode 100644 features/step_definitions/static_steps.rb diff --git a/Gemfile b/Gemfile index 4bf72113..0e9edb9f 100644 --- a/Gemfile +++ b/Gemfile @@ -42,6 +42,7 @@ group :development do end group :development, :test do + gem 'debugger' gem 'fabrication' gem 'rspec-rails' gem 'capybara' diff --git a/Gemfile.lock b/Gemfile.lock index 3d8a7b9f..43869d85 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -64,6 +64,7 @@ GEM coffee-script-source execjs coffee-script-source (1.7.0) + columnize (0.3.6) coveralls (0.7.0) multi_json (~> 1.3) rest-client @@ -82,6 +83,12 @@ GEM nokogiri (>= 1.5.0) rails (>= 3.0.0) database_cleaner (1.2.0) + debugger (1.6.5) + columnize (>= 0.3.1) + debugger-linecache (~> 1.2.0) + debugger-ruby_core_source (~> 1.3.1) + debugger-linecache (1.2.0) + debugger-ruby_core_source (1.3.2) devise (2.2.8) bcrypt-ruby (~> 3.0) orm_adapter (~> 0.1) @@ -249,6 +256,7 @@ DEPENDENCIES coveralls cucumber-rails database_cleaner + debugger devise (~> 2.2.2) fabrication faker diff --git a/app/controllers/answers_controller.rb b/app/controllers/answers_controller.rb index e9377081..0761042d 100644 --- a/app/controllers/answers_controller.rb +++ b/app/controllers/answers_controller.rb @@ -19,7 +19,5 @@ def update format.html { redirect_to question_url(resource.question) } end end - - end diff --git a/app/controllers/static_controller.rb b/app/controllers/static_controller.rb index e34ded3e..843fd4d1 100644 --- a/app/controllers/static_controller.rb +++ b/app/controllers/static_controller.rb @@ -23,7 +23,10 @@ def download @other_platforms = ["mac", "windows", "linux"] - [@platform] end - def api_root; render :layout => "api"; end + def api_root + render :layout => "api" + end + def newest_version render :json => {:version => "1.0.0"} end @@ -31,10 +34,6 @@ def newest_version protected def platform - if Rails.env.test? - "mac" - else - request.user_agent.match(/Mac|Linux|Windows/).try(:[], 0).try(:downcase) - end + request.user_agent.downcase end end diff --git a/features/answers.feature b/features/answers.feature index 600859ff..7a51357b 100644 --- a/features/answers.feature +++ b/features/answers.feature @@ -1,9 +1,12 @@ Feature: CRUD actions for answers As a user of the site, I can perform standard CRUD actions on answers + + Background: + Given "Mac" user agent Scenario: Create an answer - Given a question exists + And a question exists And I answer that question Then I should be notified that my answer was submitted And an email should be sent to the author @@ -11,7 +14,7 @@ Feature: CRUD actions for answers And my answer should show on my profile page Scenario: Edit an answer - Given a question exists + And a question exists And I answer that question When I edit that answer Then I should see the updated answer diff --git a/features/blog.feature b/features/blog.feature index 4c538602..9b342586 100644 --- a/features/blog.feature +++ b/features/blog.feature @@ -1,7 +1,10 @@ Feature: Hackety Blog As an admin, I can post to the hackety blog. - + + Background: + Given "Mac" user agent + Scenario: Read the blog Given a blog post exists When I visit the blog diff --git a/features/lessons.feature b/features/lessons.feature new file mode 100644 index 00000000..0f3b92ad --- /dev/null +++ b/features/lessons.feature @@ -0,0 +1,13 @@ +Feature: Hackety Lessons + + As a user of the site, I can visit lessons page + + Scenario: View the lessons + When I visit lessons path + Then I should see the list of lessons + + Scenario: View specific lesson + When I visit lessons path + When I click on lesson's title + Then I should see lesson content + diff --git a/features/moderator.feature b/features/moderator.feature index 2071f212..1560c2cf 100644 --- a/features/moderator.feature +++ b/features/moderator.feature @@ -3,7 +3,8 @@ Feature: Moderate questions As a moderator, I should be able to delete questions from the site. Background: - Given there is a question from someone else + Given "Mac" user agent + And there is a question from someone else Scenario: Delete a question Given I am a moderator diff --git a/features/programs.feature b/features/programs.feature index 5680b723..1f1d1380 100644 --- a/features/programs.feature +++ b/features/programs.feature @@ -1,6 +1,9 @@ Feature: Access Programs As a user of the site, I want to access users' programs + + Background: + Given "Mac" user agent Scenario: View a featured program Given there is a featured program diff --git a/features/questions.feature b/features/questions.feature index ac233e90..0a04f461 100644 --- a/features/questions.feature +++ b/features/questions.feature @@ -2,6 +2,9 @@ Feature: CRUD actions for question As a user of the site, I can perform standard CRUD actions on questions + Background: + Given "Mac" user agent + Scenario: Create a question When I create a new question Then I should be told the question was created diff --git a/features/signup.feature b/features/signup.feature index f1123432..5a386009 100644 --- a/features/signup.feature +++ b/features/signup.feature @@ -1,6 +1,9 @@ Feature: Sign up for an account As a new Hackety user, I want to create a new account and log in with it + + Background: + Given "Mac" user agent Scenario: Create an account via the signup form When I register a new account diff --git a/features/statics.feature b/features/statics.feature new file mode 100644 index 00000000..37294c25 --- /dev/null +++ b/features/statics.feature @@ -0,0 +1,19 @@ +Feature: Detect user's platform and provide download link + + As a fresh Hackety user, I want to download software for my current OS + + Scenario: MacOS User + Given "Mac" user agent + Then I should be able to download "mac" software + + Scenario: Windows User + Given "Windows" user agent + Then I should be able to download "windows" software + + Scenario: Linux User + Given "Linux" user agent + Then I should be able to download "linux" software + + Scenario: Android User + Given "android" user agent + Then I should be able to download "android" software diff --git a/features/step_definitions/lesson_steps.rb b/features/step_definitions/lesson_steps.rb new file mode 100644 index 00000000..d7355def --- /dev/null +++ b/features/step_definitions/lesson_steps.rb @@ -0,0 +1,17 @@ +When(/^I visit lessons path$/) do + visit lessons_path +end + +Then(/^I should see the list of lessons$/) do + page.should have_content("Lessons") + page.should have_content("A Tour of Hackety Hack") +end + +When(/^I click on lesson's title$/) do + click_link("A Tour of Hackety Hack") +end + +Then(/^I should see lesson content$/) do + expect(page).to have_title "A Tour of Hackety Hack" + page.should have_content("Welcome to the Hackety Hack tour!") +end diff --git a/features/step_definitions/static_steps.rb b/features/step_definitions/static_steps.rb new file mode 100644 index 00000000..b09a519a --- /dev/null +++ b/features/step_definitions/static_steps.rb @@ -0,0 +1,8 @@ +Given(/^"(.*?)" user agent$/) do |agent| + page.driver.header('User-Agent', agent) +end + +Then(/^I should be able to download "(.*?)" software$/) do |system| + visit download_path + page.should have_content("Version 1.0.1 for #{system}") +end \ No newline at end of file diff --git a/features/support/env.rb b/features/support/env.rb index ee6880e7..25e027c5 100644 --- a/features/support/env.rb +++ b/features/support/env.rb @@ -8,6 +8,7 @@ require_relative '../../spec/code_coverage' require 'cucumber/rails' +require 'ruby-debug' # Capybara defaults to XPath selectors rather than Webrat's default of CSS3. In # order to ease the transition to Capybara we set the default here. If you'd diff --git a/features/users.feature b/features/users.feature index 7dca8ff5..52ecaa78 100644 --- a/features/users.feature +++ b/features/users.feature @@ -2,8 +2,9 @@ Feature: Manage account As a user of this site, I can view and update my profile, see my followers - Background: The user is logged in - Given a logged in user + Background: + Given "Mac" user agent + And a logged in user Scenario: View my profile When I go to look at my profile page From 2cebc66b2bde36320b8e2eeec474a45ad4e6ba4d Mon Sep 17 00:00:00 2001 From: Artur-Gaifutdinov Date: Thu, 27 Feb 2014 10:58:56 -0500 Subject: [PATCH 151/161] User-Agent refactoring --- features/answers.feature | 3 --- features/blog.feature | 5 +---- features/moderator.feature | 3 +-- features/programs.feature | 3 --- features/questions.feature | 3 --- features/signup.feature | 3 --- features/support/env.rb | 1 + features/users.feature | 3 +-- 8 files changed, 4 insertions(+), 20 deletions(-) diff --git a/features/answers.feature b/features/answers.feature index 7a51357b..d647cebe 100644 --- a/features/answers.feature +++ b/features/answers.feature @@ -2,9 +2,6 @@ Feature: CRUD actions for answers As a user of the site, I can perform standard CRUD actions on answers - Background: - Given "Mac" user agent - Scenario: Create an answer And a question exists And I answer that question diff --git a/features/blog.feature b/features/blog.feature index 9b342586..4c538602 100644 --- a/features/blog.feature +++ b/features/blog.feature @@ -1,10 +1,7 @@ Feature: Hackety Blog As an admin, I can post to the hackety blog. - - Background: - Given "Mac" user agent - + Scenario: Read the blog Given a blog post exists When I visit the blog diff --git a/features/moderator.feature b/features/moderator.feature index 1560c2cf..2071f212 100644 --- a/features/moderator.feature +++ b/features/moderator.feature @@ -3,8 +3,7 @@ Feature: Moderate questions As a moderator, I should be able to delete questions from the site. Background: - Given "Mac" user agent - And there is a question from someone else + Given there is a question from someone else Scenario: Delete a question Given I am a moderator diff --git a/features/programs.feature b/features/programs.feature index 1f1d1380..f2ead8ec 100644 --- a/features/programs.feature +++ b/features/programs.feature @@ -2,9 +2,6 @@ Feature: Access Programs As a user of the site, I want to access users' programs - Background: - Given "Mac" user agent - Scenario: View a featured program Given there is a featured program Then I should be able to view a highlighted program diff --git a/features/questions.feature b/features/questions.feature index 0a04f461..ac233e90 100644 --- a/features/questions.feature +++ b/features/questions.feature @@ -2,9 +2,6 @@ Feature: CRUD actions for question As a user of the site, I can perform standard CRUD actions on questions - Background: - Given "Mac" user agent - Scenario: Create a question When I create a new question Then I should be told the question was created diff --git a/features/signup.feature b/features/signup.feature index 5a386009..442dd0bd 100644 --- a/features/signup.feature +++ b/features/signup.feature @@ -2,9 +2,6 @@ Feature: Sign up for an account As a new Hackety user, I want to create a new account and log in with it - Background: - Given "Mac" user agent - Scenario: Create an account via the signup form When I register a new account Then I should be logged in with my new account diff --git a/features/support/env.rb b/features/support/env.rb index 25e027c5..e3e7bc48 100644 --- a/features/support/env.rb +++ b/features/support/env.rb @@ -40,6 +40,7 @@ Before do DatabaseCleaner[:mongo_mapper].clean + page.driver.header('User-Agent', "Mac") end # You may also want to configure DatabaseCleaner to use different strategies for certain features and scenarios. diff --git a/features/users.feature b/features/users.feature index 52ecaa78..cbe60fdc 100644 --- a/features/users.feature +++ b/features/users.feature @@ -3,8 +3,7 @@ Feature: Manage account As a user of this site, I can view and update my profile, see my followers Background: - Given "Mac" user agent - And a logged in user + Given a logged in user Scenario: View my profile When I go to look at my profile page From 114bc6280167b60c6010ddc4a35c5ee00997a27f Mon Sep 17 00:00:00 2001 From: Artur-Gaifutdinov Date: Thu, 27 Feb 2014 12:40:20 -0500 Subject: [PATCH 152/161] Nil platform handler for StaticControllers --- app/controllers/static_controller.rb | 2 +- features/support/env.rb | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/app/controllers/static_controller.rb b/app/controllers/static_controller.rb index 843fd4d1..60acc47c 100644 --- a/app/controllers/static_controller.rb +++ b/app/controllers/static_controller.rb @@ -34,6 +34,6 @@ def newest_version protected def platform - request.user_agent.downcase + request.user_agent.nil? ? nil : request.user_agent.downcase end end diff --git a/features/support/env.rb b/features/support/env.rb index e3e7bc48..25e027c5 100644 --- a/features/support/env.rb +++ b/features/support/env.rb @@ -40,7 +40,6 @@ Before do DatabaseCleaner[:mongo_mapper].clean - page.driver.header('User-Agent', "Mac") end # You may also want to configure DatabaseCleaner to use different strategies for certain features and scenarios. From 0e3bb4ee2692cefc2df21e186b91682c06b9d262 Mon Sep 17 00:00:00 2001 From: Artur-Gaifutdinov Date: Fri, 28 Feb 2014 19:29:01 -0500 Subject: [PATCH 153/161] removed dead code, added more tests --- app/controllers/application_controller.rb | 7 ------- app/helpers/application_helper.rb | 4 ---- spec/models/deleted_user_spec.rb | 20 ++++++++++++++++++++ spec/unit/sluggifier_spec.rb | 2 -- 4 files changed, 20 insertions(+), 13 deletions(-) create mode 100644 spec/models/deleted_user_spec.rb diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 95596f7c..68f1059c 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,14 +1,7 @@ class ApplicationController < ActionController::Base protect_from_forgery - helper_method :title - def title t=nil - @title = t unless t.blank? - @title - end - rescue_from CanCan::AccessDenied do |exception| redirect_to login_url, :alert => exception.message end - end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 3419e0a3..eb35501b 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1,8 +1,4 @@ module ApplicationHelper - def program_path program - "/users/#{program.author_username}/programs/#{program.slug}" - end - def markdown(text) Redcarpet::Markdown.new(Redcarpet::Render::HTML.new(hard_wrap: true), autolink: true).render(text).html_safe end diff --git a/spec/models/deleted_user_spec.rb b/spec/models/deleted_user_spec.rb new file mode 100644 index 00000000..9afc850b --- /dev/null +++ b/spec/models/deleted_user_spec.rb @@ -0,0 +1,20 @@ +require 'spec_helper' + +describe DeletedUser do + + before do + @user = DeletedUser.new + end + + it 'has deleted username' do + @user.username.should == 'Deleted User' + end + + it 'has no email' do + @user.email.should == 'none' + end + + it 'returns deleted user param' do + @user.to_param.should == 'deleted_user' + end +end \ No newline at end of file diff --git a/spec/unit/sluggifier_spec.rb b/spec/unit/sluggifier_spec.rb index 19afa177..9cc71ce9 100644 --- a/spec/unit/sluggifier_spec.rb +++ b/spec/unit/sluggifier_spec.rb @@ -22,6 +22,4 @@ end end end - - end From 0cabceeb82b40aceca9e3adb1b6d4c47b40061ea Mon Sep 17 00:00:00 2001 From: Artur-Gaifutdinov Date: Sun, 2 Mar 2014 23:16:31 -0500 Subject: [PATCH 154/161] Question Presenter spec --- app/presenters/question_presenter.rb | 4 +- spec/controllers/static_controller_spec.rb | 9 +++++ spec/fabricators/answer_fabricator.rb | 1 - spec/fabricators/question_fabricator.rb | 1 + spec/models/rel_spec.rb | 14 +++++++ spec/presenters/question_presenter_spec.rb | 46 ++++++++++++++++++++++ 6 files changed, 72 insertions(+), 3 deletions(-) create mode 100644 spec/controllers/static_controller_spec.rb create mode 100644 spec/models/rel_spec.rb create mode 100644 spec/presenters/question_presenter_spec.rb diff --git a/app/presenters/question_presenter.rb b/app/presenters/question_presenter.rb index aaaba577..265a653e 100644 --- a/app/presenters/question_presenter.rb +++ b/app/presenters/question_presenter.rb @@ -22,7 +22,7 @@ def collection_path end def edit_resource_path - edit_question_path + edit_question_path(@question) end def apply_scope(chain) @@ -30,6 +30,6 @@ def apply_scope(chain) end def answers_path - question_answer_path(@question) + question_answers_path(@question) end end diff --git a/spec/controllers/static_controller_spec.rb b/spec/controllers/static_controller_spec.rb new file mode 100644 index 00000000..a304e045 --- /dev/null +++ b/spec/controllers/static_controller_spec.rb @@ -0,0 +1,9 @@ +require 'spec_helper' + +describe StaticController do + describe "GET root" do + it "responds with success" do + expect(:get => "/").to route_to(:controller => "static", :action => "root") + end + end +end \ No newline at end of file diff --git a/spec/fabricators/answer_fabricator.rb b/spec/fabricators/answer_fabricator.rb index a02e7ab2..25f90dd5 100644 --- a/spec/fabricators/answer_fabricator.rb +++ b/spec/fabricators/answer_fabricator.rb @@ -1,4 +1,3 @@ Fabricator(:answer) do description "MyString" - user "" end \ No newline at end of file diff --git a/spec/fabricators/question_fabricator.rb b/spec/fabricators/question_fabricator.rb index 2da52be4..74c4c5ea 100644 --- a/spec/fabricators/question_fabricator.rb +++ b/spec/fabricators/question_fabricator.rb @@ -1,4 +1,5 @@ Fabricator(:question) do + id "RandomID" title "Title" description "Description" user diff --git a/spec/models/rel_spec.rb b/spec/models/rel_spec.rb new file mode 100644 index 00000000..a614be8e --- /dev/null +++ b/spec/models/rel_spec.rb @@ -0,0 +1,14 @@ +require 'spec_helper' + +describe Rel do + + before do + @rel = Rel.create(:slug => 'text', :description => 'some text') + end + + context 'to_param' do + it 'returns slug' do + @rel.to_param.should == 'text' + end + end +end \ No newline at end of file diff --git a/spec/presenters/question_presenter_spec.rb b/spec/presenters/question_presenter_spec.rb new file mode 100644 index 00000000..13463fc7 --- /dev/null +++ b/spec/presenters/question_presenter_spec.rb @@ -0,0 +1,46 @@ +require 'spec_helper' + +describe QuestionPresenter do + + let(:question){Fabricate(:question)} + let(:another_question){Fabricate(:question, :id => 'AnotherID')} + let(:answer){Fabricate(:answer, :question_id => question.id)} + + before do + @qp = QuestionPresenter.new(question) + end + + context 'collection_path' do + it 'returns questions_path' do + @qp.collection_path.should == '/questions' + end + end + + context 'edit_resource_path' do + it 'returns edit_question_path' do + @qp.edit_resource_path.should == '/questions/RandomID/edit' + end + end + + context 'new_resource_path' do + it 'returns new_question_path' do + @qp.new_resource_path.should == '/questions/new' + end + end + + context 'resource_path' do + it 'returns self question path if nil' do + @qp.resource_path(nil).should == '/questions/RandomID' + end + + it 'returns question path if not nil' do + @qp.resource_path(another_question).should == '/questions/AnotherID' + end + end + + context 'answers_path' do + it 'returns questions answer path' do + @qp.answers_path.should == '/questions/RandomID/answers' + end + end +end \ No newline at end of file From a0d2ed1dfdb6e45543a6d9a5e810eac47fe3dc8f Mon Sep 17 00:00:00 2001 From: Artur-Gaifutdinov Date: Mon, 3 Mar 2014 21:06:26 -0500 Subject: [PATCH 155/161] Support presenter spec --- app/presenters/support_presenter.rb | 4 +- spec/presenters/support_presenter_spec.rb | 45 +++++++++++++++++++++++ 2 files changed, 47 insertions(+), 2 deletions(-) create mode 100644 spec/presenters/support_presenter_spec.rb diff --git a/app/presenters/support_presenter.rb b/app/presenters/support_presenter.rb index 2075cf09..acb871c5 100644 --- a/app/presenters/support_presenter.rb +++ b/app/presenters/support_presenter.rb @@ -18,14 +18,14 @@ def collection_path end def edit_resource_path - edit_support_question_path + edit_support_question_path(@support_question) end def resource_path(question) if question support_question_path(question) else - support_question_path(@question) + support_question_path(@support_question) end end diff --git a/spec/presenters/support_presenter_spec.rb b/spec/presenters/support_presenter_spec.rb new file mode 100644 index 00000000..6dd9ac83 --- /dev/null +++ b/spec/presenters/support_presenter_spec.rb @@ -0,0 +1,45 @@ +require 'spec_helper' + +describe SupportPresenter do + + let(:question){Fabricate(:question)} + let(:another_question){Fabricate(:question, :id => 'AnotherID')} + + before do + @sp = SupportPresenter.new(question) + end + + context 'page_title' do + it 'returns support questions title' do + @sp.page_title.should == 'Support Questions' + end + end + + context 'collection_path' do + it 'returns support questions_path' do + @sp.collection_path.should == '/support/questions' + end + end + + context 'edit_resource_path' do + it 'returns edit_support_question_path' do + @sp.edit_resource_path.should == '/support/questions/RandomID/edit' + end + end + + context 'new_resource_path' do + it 'returns new_support_question_path' do + @sp.new_resource_path.should == '/support/questions/new' + end + end + + context 'resource_path' do + it 'returns self question path if nil' do + @sp.resource_path(nil).should == '/support/questions/RandomID' + end + + it 'returns question path if not nil' do + @sp.resource_path(another_question).should == '/support/questions/AnotherID' + end + end +end \ No newline at end of file From 70d952f519a32edeb2b8bcca78911226bb711f27 Mon Sep 17 00:00:00 2001 From: cyberarm Date: Tue, 4 Mar 2014 14:41:12 -0600 Subject: [PATCH 156/161] Updated the error pages to better fit the sites theme. --- public/404.html | 84 +++++++++++++++++++++++-------------------------- public/422.html | 64 +++++++++++++++++++++++-------------- public/500.html | 84 +++++++++++++++++++++++-------------------------- 3 files changed, 121 insertions(+), 111 deletions(-) diff --git a/public/404.html b/public/404.html index c43e389f..a663cf70 100644 --- a/public/404.html +++ b/public/404.html @@ -1,48 +1,44 @@ - - The page you were looking for doesn't exist (404) - - - - -
- - Questions -
-
-

The page you were looking for doesn't exist.

-

You may have mistyped the address, the page may have moved or been deleted.

+ + The page you were looking for doesn't exist (404) + + + + + + + + + + +
+ +
+
+
+ +
+
+
+

The page you were looking for doesn't exist.

+

You may have mistyped the address, the page may have moved or been deleted.

+
+
+
- - + + diff --git a/public/422.html b/public/422.html index 83660ab1..197302a9 100644 --- a/public/422.html +++ b/public/422.html @@ -1,26 +1,44 @@ - - The change you wanted was rejected (422) - - - - - -
-

The change you wanted was rejected.

-

Maybe you tried to change something you didn't have access to.

-
- + + The change you wanted was rejected (422) + + + + + + + + + + +
+ +
+
+
+ +
+
+
+

The change you wanted was rejected.

+

Maybe you tried to change something you didn't have access to.

+
+
+
+
+ + diff --git a/public/500.html b/public/500.html index 4b8b5312..4ed09672 100644 --- a/public/500.html +++ b/public/500.html @@ -1,48 +1,44 @@ - - We're sorry, but something went wrong (500) - - - - -
- - Questions -
-
-

We're sorry, but something went wrong.

-

We've been notified about this issue and we'll take a look at it shortly.

+ + We're sorry, but something went wrong (500) + + + + + + + + + + +
+ +
+
+
+ +
+
+
+

We're sorry, but something went wrong.

+

We've been notified about this issue and we'll take a look at it shortly.

+
+
+
- - + + From 32ffa202f773de5a292e40986c1e29cffe2e0561 Mon Sep 17 00:00:00 2001 From: Artur-Gaifutdinov Date: Tue, 4 Mar 2014 20:24:45 -0500 Subject: [PATCH 157/161] Rels and static controllers spec --- app/controllers/api/rels_controller.rb | 2 +- spec/controllers/rel_controller_spec.rb | 21 +++++++++++++++++++++ spec/controllers/static_controller_spec.rb | 15 +++++++++++++++ 3 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 spec/controllers/rel_controller_spec.rb diff --git a/app/controllers/api/rels_controller.rb b/app/controllers/api/rels_controller.rb index 3cc30f1f..00894e2e 100644 --- a/app/controllers/api/rels_controller.rb +++ b/app/controllers/api/rels_controller.rb @@ -6,4 +6,4 @@ def index def show @rel = Rel.first(:slug => params[:id]) end -end +end \ No newline at end of file diff --git a/spec/controllers/rel_controller_spec.rb b/spec/controllers/rel_controller_spec.rb new file mode 100644 index 00000000..3f8f30a1 --- /dev/null +++ b/spec/controllers/rel_controller_spec.rb @@ -0,0 +1,21 @@ +require 'spec_helper' + +describe Api::RelsController do + + let(:slug){Fabricate(:rel)} + + + describe "GET index" do + it "responds with success" do + get :index + response.should be_success + end + end + + describe "GET show" do + it "responds with success" do + get :show + response.should be_success + end + end +end \ No newline at end of file diff --git a/spec/controllers/static_controller_spec.rb b/spec/controllers/static_controller_spec.rb index a304e045..ece397af 100644 --- a/spec/controllers/static_controller_spec.rb +++ b/spec/controllers/static_controller_spec.rb @@ -6,4 +6,19 @@ expect(:get => "/").to route_to(:controller => "static", :action => "root") end end + + describe "GET api_root" do + it "should render api layout" do + get :api_root + response.should render_template(:layout => "api") + end + end + + describe "GET newest_version" do + it "should render version of api" do + get :newest_version + response.header['Content-Type'].should include 'application/json' + response.body.should include "1.0.0".to_json + end + end end \ No newline at end of file From d39e127a15a8115cff146ce9c1b996449df56d6d Mon Sep 17 00:00:00 2001 From: Artur-Gaifutdinov Date: Thu, 6 Mar 2014 22:19:28 -0500 Subject: [PATCH 158/161] Helpers spec --- spec/controllers/mailer_controller_spec.rb | 7 +++++++ spec/controllers/questions_controller_spec.rb | 1 - spec/controllers/rel_controller_spec.rb | 2 -- spec/controllers/user_controller_spec.rb | 7 +++++++ spec/helpers/program_helper_spec.rb | 20 +++++++++++++++++++ 5 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 spec/helpers/program_helper_spec.rb diff --git a/spec/controllers/mailer_controller_spec.rb b/spec/controllers/mailer_controller_spec.rb index c65b252a..2c5f7554 100644 --- a/spec/controllers/mailer_controller_spec.rb +++ b/spec/controllers/mailer_controller_spec.rb @@ -88,6 +88,13 @@ ActionMailer::Base.deliveries.last.body.to_s.should match @message.body end end + + describe 'empty message' do + it "returns exception" do + post :create + expect(subject).to render_template(:new) + end + end end context 'when user is not a moderator' do diff --git a/spec/controllers/questions_controller_spec.rb b/spec/controllers/questions_controller_spec.rb index 54222ec1..c6e15a89 100644 --- a/spec/controllers/questions_controller_spec.rb +++ b/spec/controllers/questions_controller_spec.rb @@ -1,7 +1,6 @@ require 'spec_helper' describe QuestionsController do - describe "GET index" do context "with format atom" do it "responds with success" do diff --git a/spec/controllers/rel_controller_spec.rb b/spec/controllers/rel_controller_spec.rb index 3f8f30a1..ac13dba5 100644 --- a/spec/controllers/rel_controller_spec.rb +++ b/spec/controllers/rel_controller_spec.rb @@ -1,10 +1,8 @@ require 'spec_helper' describe Api::RelsController do - let(:slug){Fabricate(:rel)} - describe "GET index" do it "responds with success" do get :index diff --git a/spec/controllers/user_controller_spec.rb b/spec/controllers/user_controller_spec.rb index be688723..f756c742 100644 --- a/spec/controllers/user_controller_spec.rb +++ b/spec/controllers/user_controller_spec.rb @@ -50,4 +50,11 @@ expect(flash[:notice]).to eq("You're no longer following #{mozart.username}") end end + + describe 'Deleted user' do + it 'should create new deleted user' do + get :deleted_user + response.should be_success + end + end end diff --git a/spec/helpers/program_helper_spec.rb b/spec/helpers/program_helper_spec.rb new file mode 100644 index 00000000..8a4e4c6e --- /dev/null +++ b/spec/helpers/program_helper_spec.rb @@ -0,0 +1,20 @@ +require "spec_helper" + +describe ProgramsHelper do + let(:simple) { Fabricate(:program) } + let(:complicated) { Fabricate(:program, :author_username => nil) } + + describe "#program_link" do + it "returns author's program path if author username exists" do + helper.program_link(simple).should == "#{link_to(simple.title.titleize, + user_program_path(simple.author_username, simple))}".html_safe + end + + it "returns url by program's slug if author username doesn't exist" do + helper.program_link(complicated).should == "#{link_to(complicated.title.titleize, + url_for(:controller => '/programs', + :action => 'show', + :id => complicated.slug))}".html_safe + end + end +end \ No newline at end of file From cf442d3c955578fa53258785cf31a73a1d0720c4 Mon Sep 17 00:00:00 2001 From: Artur-Gaifutdinov Date: Sat, 8 Mar 2014 23:36:46 -0500 Subject: [PATCH 159/161] User model spec --- features/step_definitions/user_steps.rb | 13 ++++++++++++- features/users.feature | 8 ++++++-- spec/models/user_spec.rb | 16 +++++++++++++--- 3 files changed, 31 insertions(+), 6 deletions(-) diff --git a/features/step_definitions/user_steps.rb b/features/step_definitions/user_steps.rb index c3395f59..dafb78b1 100644 --- a/features/step_definitions/user_steps.rb +++ b/features/step_definitions/user_steps.rb @@ -1,5 +1,5 @@ def login_user - @user = User.create!(username: "test_user", + @user = User.create!(username: "test_user", email: "test_user@example.com", password: "foobar", password_confirmation: "foobar") @@ -20,6 +20,13 @@ def create_other_user login_user unless @user end +Given /^a steve exists$/ do + @steve = User.create!(username: "steve", + email: "steve_user@example.com", + password: "foobar", + password_confirmation: "foobar") +end + When /^I go to look at my profile page$/ do visit user_path(@user) end @@ -73,3 +80,7 @@ def create_other_user page.should have_content("Test user likes to edit his profile") end +Then(/^I should see 'Steve'$/) do + @user.following?(@steve).should == true + page.should have_link @steve.username +end diff --git a/features/users.feature b/features/users.feature index cbe60fdc..2d67ae5d 100644 --- a/features/users.feature +++ b/features/users.feature @@ -3,7 +3,8 @@ Feature: Manage account As a user of this site, I can view and update my profile, see my followers Background: - Given a logged in user + Given a steve exists + And a logged in user Scenario: View my profile When I go to look at my profile page @@ -23,4 +24,7 @@ Feature: Manage account When I am following someone And I click on the number of people I am following on my profile Then I should see someone I'm following - + + Scenario: I should always follow steve and vice versa + When I click on the number of people I am following on my profile + Then I should see 'Steve' diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 39a70431..c8d70a56 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -1,10 +1,10 @@ require 'spec_helper' describe User do - - let(:bob){Fabricate(:user)} + let(:bob){Fabricate(:user, :username => 'hacker')} let(:mozart){Fabricate(:user)} - + let(:hello_world){Fabricate(:program, :author_username => bob.username)} + it 'can be created validly' do bob.should be_valid mozart.should be_valid @@ -17,4 +17,14 @@ bob.reload bob.following?(mozart).should be_false end + + describe 'programs' do + it 'should return programs list' do + bob.programs.class.should == Plucky::Query + hello_world.author_username.should == 'hacker' + bob.username.should == 'hacker' + bob.programs.count.should == 1 + bob.programs.first.should == hello_world + end + end end \ No newline at end of file From b9d5458ae521413fb77281ec158e94e3101cc4cb Mon Sep 17 00:00:00 2001 From: Marcelo Boeira Date: Tue, 10 Feb 2015 20:11:31 -0200 Subject: [PATCH 160/161] Retina shield support by @badges --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 51b5f1cd..d9ae1f62 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # hackety-hack.com # -[![Build status](https://secure.travis-ci.org/hacketyhack/hackety-hack.com.png)](http://travis-ci.org/#!/hacketyhack/hackety-hack.com)[![Code Climate](https://codeclimate.com/github/hacketyhack/hackety-hack.com.png)](https://codeclimate.com/github/hacketyhack/hackety-hack.com)[![Coverage Status](https://coveralls.io/repos/hacketyhack/hackety-hack.com/badge.png?branch=master)](https://coveralls.io/r/hacketyhack/hackety-hack.com?branch=master) +[![Build status](https://img.shields.io/travis/hacketyhack/hackety-hack.com.svg)](http://travis-ci.org/#!/hacketyhack/hackety-hack.com)[![Code Climate](https://img.shields.io/codeclimate/github/hacketyhack/hackety-hack.com.svg)](https://codeclimate.com/github/hacketyhack/hackety-hack.com)[![Coverage Status](https://img.shields.io/coveralls/hacketyhack/hackety-hack.com/master.svg)](https://coveralls.io/r/hacketyhack/hackety-hack.com?branch=master) [hackety-hack.com][hh.com] is the web backend powering the collaborative features of [Hackety Hack][hh]. It is written in Rails 3 and continues to be under active development (see 'Helping Out'), the switch to Rails 3 happened quite recently so there's still lots to be done. From a97400e1f4e25d4af1a67e5b2365ee11dd17dbb2 Mon Sep 17 00:00:00 2001 From: Tobias Pfeiffer Date: Wed, 11 Feb 2015 09:25:50 +0100 Subject: [PATCH 161/161] Update the debugger gem to include new sources --- Gemfile.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 43869d85..98ac5970 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -64,7 +64,7 @@ GEM coffee-script-source execjs coffee-script-source (1.7.0) - columnize (0.3.6) + columnize (0.9.0) coveralls (0.7.0) multi_json (~> 1.3) rest-client @@ -83,12 +83,12 @@ GEM nokogiri (>= 1.5.0) rails (>= 3.0.0) database_cleaner (1.2.0) - debugger (1.6.5) + debugger (1.6.8) columnize (>= 0.3.1) debugger-linecache (~> 1.2.0) - debugger-ruby_core_source (~> 1.3.1) + debugger-ruby_core_source (~> 1.3.5) debugger-linecache (1.2.0) - debugger-ruby_core_source (1.3.2) + debugger-ruby_core_source (1.3.8) devise (2.2.8) bcrypt-ruby (~> 3.0) orm_adapter (~> 0.1)