-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from rubyforgood/view-targets
View targets
- Loading branch information
Showing
8 changed files
with
52 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# frozen_string_literal: true | ||
|
||
class TargetsController < ApplicationController | ||
def index | ||
@project = Project.find(params[:project_id]) | ||
@targets = @project.targets | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<%= link_to 'View all targets', project_targets_url(@project) %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<h1><%= @project.name %></h1> | ||
|
||
<ul> | ||
<%= @targets.each do |target| %> | ||
<li><h2><%= target.name %></h2></li> | ||
<% end %> | ||
</ul> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
Rails.application.routes.draw do | ||
root 'projects#index' | ||
resources :projects | ||
resources :projects do | ||
resources :targets | ||
end | ||
|
||
devise_for :users | ||
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
require 'rails_helper' | ||
|
||
feature 'Target management' do | ||
scenario 'User can view all targets for a Project' do | ||
project_name = 'TEST PROJECT' | ||
target_one_name = 'TEST TARGET ONE' | ||
target_two_name = 'TEST TARGET TWO' | ||
|
||
project = Project.create(name: project_name) | ||
Target.create(name: target_one_name, project: project) | ||
Target.create(name: target_two_name, project: project) | ||
Target.create(name: 'NOT MY TARGET', project: Project.create) | ||
|
||
visit "/projects/#{project.id}" | ||
click_link 'View all targets' | ||
|
||
expect(page).to have_text(project_name) | ||
expect(page).to have_text(target_one_name) | ||
expect(page).to have_text(target_two_name) | ||
expect(page).not_to have_text('NOT MY TARGET') | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,8 @@ | ||
require 'rails_helper' | ||
|
||
RSpec.feature 'Projects', type: :feature do | ||
|
||
feature 'Projects' do | ||
scenario 'user visits projects index' do | ||
visit root_path | ||
expect(page).to have_content "Projects" | ||
end | ||
end | ||
end |