Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
dbc148b
updated travis ci badges & iter0 doc
junyu-w Oct 8, 2016
79445f8
updated code climate badge & iter0 doc
junyu-w Oct 8, 2016
089e1eb
added pivotal tracker project url
junyu-w Oct 8, 2016
703b0be
iter 1: cucumber
Shuotong Oct 14, 2016
cc649b2
Merge remote-tracking branch 'upstream/develop' into develop
junyu-w Oct 15, 2016
ac82d6f
added status of both main repo and forked repo to readme
junyu-w Oct 15, 2016
982f2a3
Merge branch 'cucumber' into develop
junyu-w Oct 15, 2016
a3ada8b
added heroku staging url
junyu-w Oct 15, 2016
b3e3256
revise cukes
Shuotong Oct 21, 2016
d406b7c
update _form to use gem's credentials method
Shuotong Oct 21, 2016
4a32792
remove irrelevant features
Shuotong Oct 21, 2016
d348357
change credentials strings to symbols
Shuotong Oct 25, 2016
5700756
change unless to if not
Shuotong Oct 25, 2016
fcb1f53
change if not back to unless
Shuotong Oct 25, 2016
13b2654
move logic from view to controller
Shuotong Oct 26, 2016
739fd3a
change intern to to_sym
Shuotong Oct 26, 2016
b8ca10c
merges to develop
tansaku Nov 2, 2016
d8a4ffc
updated gems
junyu-w Nov 2, 2016
306eef6
change hash to ruby style and remove redundant lines
Shuotong Nov 20, 2016
a0c599c
move logic from view to controller: check repondency to credentials m…
Shuotong Nov 20, 2016
8d99a3c
Merge branch 'config' of github.com:DrakeW/projectscope into config
Shuotong Nov 20, 2016
fc6b85b
change styling according to codeclimate report
Shuotong Nov 20, 2016
a6c1797
add klass method in config model and change logic accordingly
Shuotong Dec 2, 2016
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
44 changes: 21 additions & 23 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -15,35 +15,35 @@ GIT

GIT
remote: https://github.com/AgileVentures/project_metric_code_climate
revision: 428cf1ca92e2e822bfdd4569fec5b1a8b518a52e
revision: 99c1927642270777620a683a2b8bd92ce2190af9
specs:
project_metric_code_climate (0.0.5)
httparty

GIT
remote: https://github.com/AgileVentures/project_metric_github
revision: 629101fa195ece6843e13281a11604abdf4b597e
revision: 98ca683a242d0ab4489ce0a644cf3d5ca0f4ac44
specs:
project_metric_github (0.0.9)
octokit

GIT
remote: https://github.com/AgileVentures/project_metric_pivotal_tracker
revision: d2b603bb1f6c8639e74a68d4a739d255e383d808
revision: 0923771b2ef15a4f44698aaa4cb27f8cdf7235cb
specs:
project_metric_pivotal_tracker (0.0.1)
tracker_api (~> 0.2.0)

GIT
remote: https://github.com/AgileVentures/project_metric_slack
revision: f0e2a83a761087542c089f2b1226942d7c083bb8
revision: 35d9827d5fd6ec9d7a7e4b5dbdc0ca2e22f1578d
specs:
project_metric_slack (0.0.0)
slack-ruby-client (>= 0.7.6)

GIT
remote: https://github.com/AgileVentures/project_metric_slack_trends
revision: 5721ff93fc8f50cfda02c5fcaee9efba50b483df
revision: 646b106b610bc29508ffbeb5b97047eb629f04ec
specs:
project_metric_slack_trends (0.0.1)
rasem (~> 0.6.1)
Expand Down Expand Up @@ -111,8 +111,8 @@ GEM
autoprefixer-rails (>= 5.2.1)
sass (>= 3.3.4)
builder (3.2.2)
byebug (9.0.5)
capybara (2.8.1)
byebug (9.0.6)
capybara (2.10.1)
addressable
mime-types (>= 1.16)
nokogiri (>= 1.3.3)
Expand Down Expand Up @@ -145,9 +145,9 @@ GEM
multi_test (>= 0.1.2)
cucumber-core (1.5.0)
gherkin (~> 4.0)
cucumber-rails (1.4.4)
cucumber-rails (1.4.5)
capybara (>= 1.1.2, < 3)
cucumber (>= 1.3.8, < 3)
cucumber (>= 1.3.8, < 4)
mime-types (>= 1.16, < 4)
nokogiri (~> 1.5)
railties (>= 3, < 5.1)
Expand Down Expand Up @@ -175,7 +175,7 @@ GEM
encryptor (3.0.0)
equalizer (0.0.11)
erubis (2.7.0)
excon (0.52.0)
excon (0.54.0)
execjs (2.7.0)
factory_girl (4.7.0)
activesupport (>= 3.0.0)
Expand All @@ -195,7 +195,7 @@ GEM
haml (4.0.7)
tilt
hashdiff (0.3.0)
hashie (3.4.4)
hashie (3.4.6)
httparty (0.14.0)
multi_xml (>= 0.5.2)
i18n (0.7.0)
Expand All @@ -219,21 +219,20 @@ GEM
mime-types-data (~> 3.2015)
mime-types-data (3.2016.0521)
mini_portile2 (2.1.0)
minitest (5.9.0)
minitest (5.9.1)
multi_json (1.12.1)
multi_test (0.1.2)
multi_xml (0.5.5)
multipart-post (2.0.0)
nokogiri (1.6.8)
nokogiri (1.6.8.1)
mini_portile2 (~> 2.1.0)
pkg-config (~> 1.1.7)
oauth2 (1.2.0)
faraday (>= 0.8, < 0.10)
jwt (~> 1.0)
multi_json (~> 1.3)
multi_xml (~> 0.5)
rack (>= 1.2, < 3)
octokit (4.3.0)
octokit (4.4.1)
sawyer (~> 0.7.0, >= 0.5.3)
omniauth (1.3.1)
hashie (>= 1.2, < 4)
Expand All @@ -242,10 +241,9 @@ GEM
oauth2 (~> 1.0)
omniauth (~> 1.2)
orm_adapter (0.5.0)
pg (0.18.4)
pg (0.19.0)
phantomjs (2.1.1.0)
pkg-config (1.1.7)
poltergeist (1.10.0)
poltergeist (1.11.0)
capybara (~> 2.1)
cliver (~> 0.3.1)
websocket-driver (>= 0.2.0)
Expand Down Expand Up @@ -283,7 +281,7 @@ GEM
activesupport (= 4.2.6)
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rake (11.2.2)
rake (11.3.0)
rasem (0.6.1)
rdoc (4.2.2)
json (~> 1.4)
Expand All @@ -292,7 +290,7 @@ GEM
uber (~> 0.0.15)
responders (2.3.0)
railties (>= 4.2.0, < 5.1)
rspec-core (3.5.3)
rspec-core (3.5.4)
rspec-support (~> 3.5.0)
rspec-expectations (3.5.0)
diff-lcs (>= 1.2.0, < 2.0)
Expand Down Expand Up @@ -320,7 +318,7 @@ GEM
sawyer (0.7.0)
addressable (>= 2.3.5, < 2.5)
faraday (~> 0.8, < 0.10)
sdoc (0.4.1)
sdoc (0.4.2)
json (~> 1.7, >= 1.7.7)
rdoc (~> 4.0)
simplecov (0.12.0)
Expand All @@ -343,7 +341,7 @@ GEM
actionpack (>= 4.0)
activesupport (>= 4.0)
sprockets (>= 3.0.0)
sqlite3 (1.3.11)
sqlite3 (1.3.12)
thor (0.19.1)
thread_safe (0.3.5)
tilt (2.0.5)
Expand All @@ -363,7 +361,7 @@ GEM
tzinfo (1.2.2)
thread_safe (~> 0.1)
uber (0.0.15)
uglifier (3.0.2)
uglifier (3.0.3)
execjs (>= 0.3.0, < 3)
vcr (3.0.3)
virtus (1.0.5)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
Main Repo Status:


<a href="https://codeclimate.com/github/AgileVentures/projectscope"><img src="https://codeclimate.com/github/AgileVentures/projectscope/badges/gpa.svg" /></a>
<a href="https://travis-ci.org/AgileVentures/projectscope"><img src="https://travis-ci.org/AgileVentures/projectscope.svg?branch=develop"></a>

CS169 Group Forked Repo Status:

<a href="https://codeclimate.com/github/DrakeW/projectscope"><img src="https://codeclimate.com/github/DrakeW/projectscope/badges/gpa.svg" /></a>
<a href="https://travis-ci.org/DrakeW/projectscope"><img src="https://travis-ci.org/DrakeW/projectscope.svg?branch=develop"></a>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this file shouldn't be changed?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure - which file are you referring to? sorry ... you mean the README? a codeclimate file?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean the README, this line is our repo's code climate coverage badge

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, being changes from build to coverage - we should display both right?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did I change this? sorry - I thought I was updating to be correct - feel free to set to what you think it should be - for this whole branch though the main thing we need is the refactoring of the view to use the new controller code right?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the late comment, been busy with other stuff recently..

and @Shuotong can you update this readme to not remove the coverage badge and update this branch according to @tansaku 's comments days ago? Thanks

<a href="https://codeclimate.com/github/DrakeW/projectscope/coverage"><img src="https://codeclimate.com/github/DrakeW/projectscope/badges/coverage.svg" /></a>

# MVP dashboard for ProjectScope

Expand Down
18 changes: 18 additions & 0 deletions app/controllers/projects_controller.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
class ProjectsController < ApplicationController
before_action :set_project, only: [:show, :edit, :update, :destroy]

before_action :init_existed_configs, only: [:show, :edit, :new]
before_action :authenticate_user!

# GET /projects
# GET /projects.json

def index
@projects = Project.all
@metric_names = ProjectMetrics.metric_names
Expand All @@ -23,6 +26,14 @@ def new

# GET /projects/1/edit
def edit
@project.configs.each do |config|

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually I can remove all this code as well and everything still works ...

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The loop here checks whether certain credentials has already been given value. In _form.html, it first displays all the existed credentials and adds fields for credentials that haven't been configured. The cucumber test would pass, and everything still works if we remove this part. But on the edit page, for example, if we already have an url for codeclimate, it still provides an empty field to config url. I hope that makes sense. I should probably modify the cucumber for edit page to test this scenario.

name = config.metric_name
if config.klass.respond_to?(:credentials)
config.options.each_pair do |key,_val|
@existed_configs[name] << key.to_sym
end
end
end
end

# POST /projects
Expand Down Expand Up @@ -72,6 +83,13 @@ def set_project
@project = Project.includes(:configs).find(params[:id])
end

def init_existed_configs
@existed_configs = {}
ProjectMetrics.metric_names.each do |name|
@existed_configs[name] = []
end
end

# Never trust parameters from the scary internet, only allow the white list through.
def project_params
# Grab new option keys/vals from params, and incorporate them into
Expand Down
3 changes: 3 additions & 0 deletions app/models/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,8 @@ class Config < ActiveRecord::Base

attr_accessible :options, :metric_name

def klass
ProjectMetrics.class_for self.metric_name

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 space indenting please - let's be consistent :-)

end
end

27 changes: 18 additions & 9 deletions app/views/projects/_form.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
= f.text_field :name, :disabled => @readonly

= f.fields_for :configs do |cf|
- name,index = cf.object.metric_name, cf.index
- name,klass,index = cf.object.metric_name, cf.object.klass, cf.index
%fieldset{:id => name}
%legend= name.titleize
= hidden_field_tag "project[configs_attributes][#{index}][metric_name]", name
Expand All @@ -24,15 +24,24 @@
= text_field_tag field_name, val, :disabled => @readonly
%br
- unless @readonly
= link_to 'Add new', '', :class => 'add'
.field.new
= text_field_tag "project[configs_attributes][#{index}][new][]", '', :id => nil, :class => 'newf'
\ :
= text_field_tag "project[configs_attributes][#{index}][new][]", '', :id => nil, :class => 'newf'
%br
- if klass.respond_to? :credentials
- klass.credentials.each do |cred|
-unless @existed_configs[name].include?(cred)
.field.new
= label_tag "project[configs_attributes][#{index}][new][]", "#{cred}", :id => nil, :class => 'newf'
\ :
= hidden_field_tag "project[configs_attributes][#{index}][new][]", "#{cred}", :id => nil, :class => 'newf'
= text_field_tag "project[configs_attributes][#{index}][new][]", '', :id => "#{name}_#{cred}", :class => 'newf'
- else
= link_to 'Add new', '', :class => 'add'
.field.new
= text_field_tag "project[configs_attributes][#{index}][new][]", '', :id => nil, :class => 'newf'
\ :
= text_field_tag "project[configs_attributes][#{index}][new][]", '', :id => nil, :class => 'newf'
%br

:javascript
$('.add').click(function() { $(this).closest('fieldset').append($('.new')[0].outerHTML); return(false); } )
:javascript
$('.add').click(function() { $(this).closest('fieldset').append($('.new')[0].outerHTML); return(false); } )

- unless @readonly
.actions
Expand Down
37 changes: 31 additions & 6 deletions features/add_project_with_config.feature
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,39 @@ Feature: add project and its config/credentials info
When I follow "New Project"
And I fill in "Name" with "Test Project"
And I enter new "Code Climate" config values:
| key | value |
| token | 12345 |
| login | fox |
| key | value |
| url | a.com |
| channel | 12345 |
| token | 555 |
And I enter new "Github" config values:
| key | value |
| url | b.com |
And I enter new "Slack" config values:
| key | value |
| channel | 1 |
| token | 5 |
And I enter new "Pivotal Tracker" config values:
| key | value |
| project | la |
| token | 444 |
And I enter new "Slack Trends" config values:
| key | value |
| channel | 1 |
| token | 5 |
And I press "Create Project"
Then there should be a project "Test Project" with config values:
| metric_name | key | value |
| code_climate | token | 12345 |
| code_climate | login | fox |
| metric_name | key | value |
| code_climate | url | a.com |
| code_climate | channel | 12345 |
| code_climate | token | 555 |
| github | url | b.com |
| slack | channel | 1 |
| slack | token | 5 |
| slack_trends | channel | 1 |
| slack_trends | token | 5 |
| pivotal_tracker | project | la |
| pivotal_tracker | token | 444 |




12 changes: 2 additions & 10 deletions features/step_definitions/project_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,9 @@

When /^I enter new "(.*)" config values/ do |metric, table|
fieldset_id = metric.downcase.gsub(' ', '_') # "Code Climate" => "code_climate"
(table.hashes.length - 1).times do
within "##{fieldset_id}" do
click_link 'Add new'
end
end
idx = 0
all_inputs = page.all("fieldset##{fieldset_id} .newf")
table.hashes.each do |h|
all_inputs[idx].set h['key']
all_inputs[idx+1].set h['value']
idx += 2
credential = h['key']
fill_in("#{fieldset_id}_#{credential}", :with => h['value'])
end
end

Expand Down