Created DataBundles controller, model and draft views.
Created relation between User and DataBundle
Writed model spec for check databundle factory
diff --git a/app/controllers/data_bundles_controller.rb b/app/controllers/data_bundles_controller.rb
new file mode 100644
index 0000000..df17a5a
--- /dev/null
+++ b/app/controllers/data_bundles_controller.rb
@@ -0,0 +1,72 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+class DataBundlesController < ApplicationController
+ before_action :set_data_bundle, only: [:show, :edit, :update, :destroy]
+
+ # GET /data_bundles
+ def index
+ @data_bundles = DataBundle.all
+ end
+
+ # GET /data_bundles/1
+ def show
+ end
+
+ # GET /data_bundles/1/edit
+ def edit
+ end
+
+ # POST /data_bundles
+ def create
+ @data_bundle = current_user.databundles.new(data_bundle_params)
+
+ if @data_bundle.save
+ redirect_to @data_bundle, notice: 'Data bundle was successfully created.'
+ else
+ render :edit
+ end
+ end
+
+ # PATCH/PUT /data_bundles/1
+ def update
+ if @data_bundle.update(data_bundle_params)
+ redirect_to @data_bundle, notice: 'Data bundle was successfully updated.'
+ else
+ render :edit
+ end
+ end
+
+ # DELETE /data_bundles/1
+ def destroy
+ @data_bundle.destroy
+ redirect_to data_bundles_url, notice: 'Data bundle was successfully destroyed.'
+ end
+
+ private
+ # Use callbacks to share common setup or constraints between actions.
+ def set_data_bundle
+ @data_bundle = DataBundle.find(params[:id])
+ end
+
+ # Never trust parameters from the scary internet, only allow the white list through.
+ def data_bundle_params
+ params.require(:data_bundle).permit(:file, :name)
+ end
+end
diff --git a/app/models/data_bundle.rb b/app/models/data_bundle.rb
new file mode 100644
index 0000000..37abbe6
--- /dev/null
+++ b/app/models/data_bundle.rb
@@ -0,0 +1,26 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+class DataBundle < ActiveRecord::Base
+ mount_uploader :file, ::DataBundleUploader
+
+ belongs_to :user
+
+ validates :user_id, presence: true
+end
diff --git a/app/models/user.rb b/app/models/user.rb
index d440c1e..52a6af9 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -24,6 +24,8 @@
:recoverable, :rememberable, :trackable, :validatable,
:omniauthable, omniauth_providers: [:facebook, :google_oauth2]
+ has_many :databundles, class_name: 'DataBundle'
+
validates :email, presence: true, uniqueness: true
def self.from_omniauth(auth)
diff --git a/app/views/data_bundles/_form.html.slim b/app/views/data_bundles/_form.html.slim
new file mode 100644
index 0000000..d442668
--- /dev/null
+++ b/app/views/data_bundles/_form.html.slim
@@ -0,0 +1,6 @@
+- if user_signed_in?
+ = form_for @data_bundle, multipart: true do |f|
+ .field
+ = f.file_field :file
+ .actions
+ = f.submit
diff --git a/app/views/data_bundles/edit.html.slim b/app/views/data_bundles/edit.html.slim
new file mode 100644
index 0000000..6c13f0a
--- /dev/null
+++ b/app/views/data_bundles/edit.html.slim
@@ -0,0 +1,8 @@
+h1 Editing data_bundle
+
+== render 'form'
+
+= link_to 'Show', @data_bundle
+'|
+= link_to 'Back', data_bundles_path
+
diff --git a/app/views/data_bundles/index.html.slim b/app/views/data_bundles/index.html.slim
new file mode 100644
index 0000000..b1bf20b
--- /dev/null
+++ b/app/views/data_bundles/index.html.slim
@@ -0,0 +1,23 @@
+h1 Listing data_bundles
+
+table
+ thead
+ tr
+ th File
+ th User
+ th
+ th
+ th
+
+ tbody
+ - @data_bundles.each do |data_bundle|
+ tr
+ td = data_bundle.file
+ td = data_bundle.user_id
+ td = link_to 'Show', data_bundle
+ td = link_to 'Edit', edit_data_bundle_path(data_bundle)
+ td = link_to 'Destroy', data_bundle, data: {:confirm => 'Are you sure?'}, :method => :delete
+
+br
+
+= render partial: 'form'
diff --git a/app/views/data_bundles/show.html.slim b/app/views/data_bundles/show.html.slim
new file mode 100644
index 0000000..e395854
--- /dev/null
+++ b/app/views/data_bundles/show.html.slim
@@ -0,0 +1,12 @@
+p#notice = notice
+
+p
+ strong File:
+ = @data_bundle.file
+p
+ strong User:
+ = @data_bundle.user_id
+
+= link_to 'Edit', edit_data_bundle_path(@data_bundle)
+'|
+= link_to 'Back', data_bundles_path
diff --git a/config/routes.rb b/config/routes.rb
index 19a25de..f5c29d7 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -18,6 +18,7 @@
#
Rails.application.routes.draw do
+ resources :data_bundles, except: [:new]
get 'welcome/index'
root 'welcome#index'
diff --git a/db/migrate/20150701132604_create_data_bundles.rb b/db/migrate/20150701132604_create_data_bundles.rb
new file mode 100644
index 0000000..13e0853
--- /dev/null
+++ b/db/migrate/20150701132604_create_data_bundles.rb
@@ -0,0 +1,11 @@
+class CreateDataBundles < ActiveRecord::Migration
+ def change
+ create_table :data_bundles do |t|
+ t.string :file
+ t.string :name
+ t.integer :user_id
+
+ t.timestamps null: false
+ end
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 78219e9..7514588 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -11,11 +11,19 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema.define(version: 20150610102232) do
+ActiveRecord::Schema.define(version: 20150701132604) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
+ create_table "data_bundles", force: :cascade do |t|
+ t.string "file"
+ t.string "name"
+ t.integer "user_id"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ end
+
create_table "users", force: :cascade do |t|
t.string "firstname"
t.string "lastname"
diff --git a/spec/factories/data_bundles.rb b/spec/factories/data_bundles.rb
new file mode 100644
index 0000000..8202260
--- /dev/null
+++ b/spec/factories/data_bundles.rb
@@ -0,0 +1,25 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+FactoryGirl.define do
+ factory :data_bundle do
+ association :user
+ name Faker::Lorem.sentence
+ end
+end
diff --git a/spec/feature/data_bundles_spec.rb b/spec/feature/data_bundles_spec.rb
new file mode 100644
index 0000000..e1f6bb5
--- /dev/null
+++ b/spec/feature/data_bundles_spec.rb
@@ -0,0 +1,23 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+require 'spec_helper'
+
+RSpec.describe 'DataBundles', type: :feature do
+end
diff --git a/spec/models/data_bundle_spec.rb b/spec/models/data_bundle_spec.rb
new file mode 100644
index 0000000..985bdc8
--- /dev/null
+++ b/spec/models/data_bundle_spec.rb
@@ -0,0 +1,26 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+require 'spec_helper'
+
+RSpec.describe DataBundle, type: :model do
+ it 'default factory - valid' do
+ expect(build(:data_bundle)).to be_valid
+ end
+end