Program descriptions #120

Merged
merged 2 commits into from Jan 18, 2012
@@ -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!
@@ -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,7 +22,7 @@
%h3 All Programs
.description Every program uploaded by our users!
- %ul
+ %ul.programs_list
- @programs.each do |program|
%li
.title= program_link program
@@ -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
@@ -13,4 +13,17 @@ 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
+ 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
+ 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
@@ -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
@@ -30,6 +31,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 +52,20 @@ def visit_user_programs_page
Then /^I should be able to view their programs$/ do
visit_user_programs_page
-end
+end
+
+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
@@ -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