Commit d96c861
Changed files (27)
app
assets
javascripts
models
templates
controllers
models
views
applications
services
config
spec
app/assets/javascripts/controllers/applications.js.coffee
@@ -1,2 +0,0 @@
-App.ApplicationsController = Ember.ArrayController.extend(
-)
app/assets/javascripts/controllers/applications_new.js.coffee
@@ -1,10 +0,0 @@
-App.ApplicationsNewController = Ember.Controller.extend
- actions:
- createApplication: ->
- fields = @get('fields')
- if App.Application.valid(fields)
- application = @store.createRecord('application', @get('fields'))
- application.save().then =>
- @transitionTo('application', application)
- else
- @set('showError', true)
app/assets/javascripts/controllers/apps.js.coffee
@@ -0,0 +1,2 @@
+App.AppsController = Ember.ArrayController.extend(
+)
app/assets/javascripts/controllers/services_new.js.coffee
@@ -0,0 +1,10 @@
+App.ServicesNewController = Ember.Controller.extend
+ actions:
+ createService: ->
+ fields = @get('fields')
+ if App.Service.valid(fields)
+ service = @store.createRecord('service', @get('fields'))
+ service.save().then =>
+ @transitionTo('service', service)
+ else
+ @set('showError', true)
app/assets/javascripts/models/application.js.coffee → app/assets/javascripts/models/service.js.coffee
@@ -1,6 +1,6 @@
-App.Application = DS.Model.extend
+App.Service = DS.Model.extend
name: DS.attr('string')
-App.Application.reopenClass
+App.Service.reopenClass
valid: (fields) ->
fields.name
app/assets/javascripts/routes/applications_route.js.coffee
@@ -1,4 +0,0 @@
-App.ApplicationsRoute = Ember.Route.extend(
- model: ->
- @store.findAll('application')
-)
app/assets/javascripts/routes/applications_new_route.js.coffee → app/assets/javascripts/routes/services_new_route.js.coffee
@@ -1,4 +1,4 @@
-App.ApplicationsNewRoute = Ember.Route.extend
+App.ServicesNewRoute = Ember.Route.extend
setupController: (controller) ->
controller.set('fields', {})
controller.set('showError', false)
app/assets/javascripts/routes/services_route.js.coffee
@@ -0,0 +1,4 @@
+App.ServicesRoute = Ember.Route.extend(
+ model: ->
+ @store.findAll('service')
+)
app/assets/javascripts/templates/applications/new.hbs → app/assets/javascripts/templates/services/new.hbs
@@ -1,6 +1,6 @@
-<h1>New Application</h1>
+<h1>New Service</h1>
{{#if showError}}
-<p>Application must have a name.</p>
+<p>Service must have a name.</p>
{{/if}}
<form>
<fieldset>
@@ -11,4 +11,4 @@
</fieldset>
</form>
-<input type="submit" value="Create" {{action 'createApplication'}} />
+<input type="submit" value="Create" {{action 'createService'}} />
app/assets/javascripts/templates/application.hbs
@@ -4,7 +4,7 @@
<ul class="nav nav-sidebar">
<li>{{#link-to 'index'}}Overview{{/link-to}}</li>
<li>{{#link-to 'videos'}}Videos{{/link-to}}</li>
- <li>{{#link-to 'applications'}}Applications{{/link-to}}</li>
+ <li>{{#link-to 'services'}}Services{{/link-to}}</li>
</ul>
</div>
<div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
app/assets/javascripts/templates/applications.hbs
@@ -1,9 +0,0 @@
-<h1>Applications</h1>
-
-{{#link-to 'applications.new'}}new application{{/link-to}}
-
-{{#each application in controller}}
- {{application.name}}
-{{/each}}
-
-{{outlet}}
app/assets/javascripts/templates/services.hbs
@@ -0,0 +1,9 @@
+<h1>Services</h1>
+
+{{#link-to 'services.new'}}new service{{/link-to}}
+
+{{#each service in controller}}
+ {{service.name}}
+{{/each}}
+
+{{outlet}}
app/assets/javascripts/router.js.coffee
@@ -8,5 +8,6 @@ App.Router.map ()->
@route 'new'
@resource 'video', { path: ':video_id' }, ->
@route 'edit'
- @resource 'applications', ->
+ @resource 'services', ->
@route 'new'
+ @resource 'service', { path: ':service_id' }
app/controllers/applications_controller.rb
@@ -1,16 +0,0 @@
-class ApplicationsController < ApplicationController
- def index
- @applications = Application.all
- end
-
- def create
- Application.create!(application_params)
- render nothing: true
- end
-
- private
-
- def application_params
- params.require(:application).permit(:name)
- end
-end
app/controllers/services_controller.rb
@@ -0,0 +1,16 @@
+class ServicesController < ApplicationController
+ def index
+ @services = Service.all
+ end
+
+ def create
+ Service.create!(application_params)
+ render nothing: true
+ end
+
+ private
+
+ def application_params
+ params.require(:service).permit(:name)
+ end
+end
app/models/application.rb
@@ -1,2 +0,0 @@
-class Application < ActiveRecord::Base
-end
app/models/service.rb
@@ -0,0 +1,2 @@
+class Service < ActiveRecord::Base
+end
app/views/applications/index.json.jbuilder
@@ -1,4 +0,0 @@
-json.applications @applications do |application|
- json.id application.id
- json.name application.name
-end
app/views/services/index.json.jbuilder
@@ -0,0 +1,4 @@
+json.services @services do |service|
+ json.id service.id
+ json.name service.name
+end
config/routes.rb
@@ -1,7 +1,7 @@
Erkell::Application.routes.draw do
resources :sessions, only: [:new, :create, :destroy]
resources :videos, only: [:index, :create, :update, :destroy]
- resources :applications, only: [:index, :create]
+ resources :services, only: [:index, :create]
get 'dashboard', to: 'dashboard#index'
root 'dashboard#index'
# The priority is based upon order of creation: first created -> highest priority.
db/migrate/20141110173131_rename_applications_to_services.rb
@@ -0,0 +1,5 @@
+class RenameApplicationsToServices < ActiveRecord::Migration
+ def change
+ rename_table :applications, :services
+ end
+end
db/schema.rb
@@ -11,12 +11,12 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema.define(version: 20141110163805) do
+ActiveRecord::Schema.define(version: 20141110173131) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
- create_table "applications", force: true do |t|
+ create_table "services", force: true do |t|
t.string "name"
t.datetime "created_at"
t.datetime "updated_at"
spec/controllers/applications_controller_spec.rb
@@ -1,28 +0,0 @@
-require 'rails_helper'
-
-describe ApplicationsController do
- let(:user) { user_session.user }
- let(:user_session) { create(:session) }
-
- before :each do
- session[:user_session_id] = user_session.id
- end
-
- describe "#index" do
- let!(:application) { create(:application) }
-
- it 'returns a list of all registered applications' do
- xhr :get, :index
- expect(assigns(:applications)).to include(application)
- end
- end
-
- describe "#create" do
- it 'creates a new application' do
- xhr :post, :create, application: { name: 'blah' }
-
- expect(Application.count).to eql(1)
- expect(Application.last.name).to eql('blah')
- end
- end
-end
spec/controllers/services_controller_spec.rb
@@ -0,0 +1,28 @@
+require 'rails_helper'
+
+describe ServicesController do
+ let(:user) { user_session.user }
+ let(:user_session) { create(:session) }
+
+ before :each do
+ session[:user_session_id] = user_session.id
+ end
+
+ describe "#index" do
+ let!(:service) { create(:service) }
+
+ it 'returns a list of all registered services' do
+ xhr :get, :index
+ expect(assigns(:services)).to include(service)
+ end
+ end
+
+ describe "#create" do
+ it 'creates a new service' do
+ xhr :post, :create, service: { name: 'blah' }
+
+ expect(Service.count).to eql(1)
+ expect(Service.last.name).to eql('blah')
+ end
+ end
+end
spec/models/application_spec.rb → spec/models/service_spec.rb
@@ -1,4 +1,4 @@
require 'rails_helper'
-describe Application do
+describe Service do
end
spec/factories.rb
@@ -16,7 +16,7 @@ FactoryGirl.define do
user
end
- factory :application do
+ factory :service do
name Faker::Company.name
end
end
spec/spec_helper.rb
@@ -67,7 +67,7 @@ RSpec.configure do |config|
# Print the 10 slowest examples and example groups at the
# end of the spec run, to help surface which specs are running
# particularly slow.
- config.profile_examples = 10
+ #config.profile_examples = 10
# Run specs in random order to surface order dependencies. If you find an
# order dependency and want to debug it, you can fix the order by providing