Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/models/program.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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!
Expand Down
4 changes: 2 additions & 2 deletions app/views/programs/index.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
3 changes: 3 additions & 0 deletions app/views/programs/show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
15 changes: 14 additions & 1 deletion features/programs.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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
28 changes: 26 additions & 2 deletions features/step_definitions/program_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
3 changes: 2 additions & 1 deletion spec/unit/program_spec.rb
Original file line number Diff line number Diff line change
@@ -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
Expand Down