diff --git a/Gemfile b/Gemfile
index 4868c0d..b300784 100644
--- a/Gemfile
+++ b/Gemfile
@@ -1,47 +1,51 @@
source 'https://rubygems.org'
-# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
+#rails gem
gem 'rails', '4.1.0.rc2'
-gem 'mongoid', github: 'mongoid/mongoid'
-# Use SCSS for stylesheets
-gem 'sass-rails', '~> 4.0.0'
-gem 'nokogiri'
-
-
-# Use Uglifier as compressor for JavaScript assets
+#assets and templates
+gem 'sass-rails', '~> 4.0.2'
gem 'uglifier', '>= 1.3.0'
-
-# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', '~> 4.0.0'
-gem 'announcement', path: '/Users/saurabhbhatia/announcement-test'
-
-# See https://github.com/sstephenson/execjs#readme for more supported runtimes
-# gem 'therubyracer', platforms: :ruby
-
-# Use jquery as the JavaScript library
gem 'jquery-rails'
-
-# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
-# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
-gem 'jbuilder', '~> 1.2'
-gem "active_model_serializers"
+#password
+gem 'bcrypt-ruby', '~> 3.1.5'
-group :doc do
- # bundle exec rake doc:rails generates the API under doc/api.
- gem 'sdoc', require: false
+#json
+gem 'jbuilder', '~> 2.0'
+gem 'sdoc', '~> 0.4.0', group: :doc
+gem 'spring', group: :development
+gem 'active_model_serializers'
+
+#parser
+gem 'nokogiri'
+
+#database
+gem 'mongoid', github: "mongoid/mongoid"
+
+#built in modules
+eval(File.read(File.dirname(__FILE__) + '/built_in_extensions.rb'))
+#modules installed from the store
+eval(File.read(File.dirname(__FILE__) + '/downloaded_extensions.rb'))
+
+#development related gems
+group :development do
+ gem 'better_errors'
+ gem 'binding_of_caller', :platforms=>[:mri_19, :mri_20, :rbx]
+ gem 'guard-bundler'
+ gem 'guard-rails'
+ gem 'rails_layout'
+ gem 'rb-fchange', :require=>false
+ gem 'rb-fsevent', :require=>false
+ gem 'rb-inotify', :require=>false
end
-# Use ActiveModel has_secure_password
-# gem 'bcrypt-ruby', '~> 3.1.2'
+#testing gems
+group :test do
+ gem "minitest"
+ gem 'minitest-spec-rails'
+end
-# Use unicorn as the app server
-# gem 'unicorn'
-
-# Use Capistrano for deployment
-# gem 'capistrano', group: :development
-
-# Use debugger
gem 'debugger', '>= 1.6.6', group: [:development, :test]
\ No newline at end of file
diff --git a/app/assets/javascripts/users.js.coffee b/app/assets/javascripts/users.js.coffee
new file mode 100644
index 0000000..24f83d1
--- /dev/null
+++ b/app/assets/javascripts/users.js.coffee
@@ -0,0 +1,3 @@
+# Place all the behaviors and hooks related to the matching controller here.
+# All this logic will automatically be available in application.js.
+# You can use CoffeeScript in this file: http://coffeescript.org/
diff --git a/app/assets/stylesheets/users.css.scss b/app/assets/stylesheets/users.css.scss
new file mode 100644
index 0000000..1efc835
--- /dev/null
+++ b/app/assets/stylesheets/users.css.scss
@@ -0,0 +1,3 @@
+// Place all the styles related to the users controller here.
+// They will automatically be included in application.css.
+// You can use Sass (SCSS) here: http://sass-lang.com/
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
new file mode 100644
index 0000000..7f3b7da
--- /dev/null
+++ b/app/controllers/users_controller.rb
@@ -0,0 +1,21 @@
+class UsersController < ApplicationController
+ def new
+ @user = User.new
+ end
+
+ def create
+ @user = User.new(user_params)
+ if @user.save
+ redirect_to root_url, :notice => "Signed Up Successfully!"
+ else
+ render "new"
+ end
+ end
+
+ private
+
+ # Never trust parameters from the scary internet, only allow the white list through.
+ def user_params
+ params.require(:user).permit(:email, :password, :password_confirmation, :user_name)
+ end
+end
diff --git a/app/models/user.rb b/app/models/user.rb
new file mode 100644
index 0000000..7ccce77
--- /dev/null
+++ b/app/models/user.rb
@@ -0,0 +1,17 @@
+class User
+ include Mongoid::Document
+ include Mongoid::Timestamps
+ include ActiveModel::SecurePassword
+
+ field :user_name, type: String
+ field :email, type: String
+ field :password_digest, type:
+
+ has_secure_password
+
+ VALID_EMAIL_FORMAT = /\A[^@\s]+@([^@.\s]+\.)+[^@.\s]+\z/
+
+ validates :user_name, presence: true, uniqueness: true
+ validates :password, presence: true, :on => :create, length: {:in => 8..20}
+ validates :email, presence: true, uniqueness: true, format: { with: VALID_EMAIL_FORMAT }
+end
diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb
index 91cb386..f20e420 100644
--- a/app/views/layouts/application.html.erb
+++ b/app/views/layouts/application.html.erb
@@ -1,7 +1,7 @@
- OrbitStore
+ RulingOrbit
<%= stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => true %>
<%= javascript_include_tag "jquery11" %>
<%= csrf_meta_tags %>
diff --git a/app/views/users/create.html.erb b/app/views/users/create.html.erb
new file mode 100644
index 0000000..48ea02e
--- /dev/null
+++ b/app/views/users/create.html.erb
@@ -0,0 +1,2 @@
+Users#create
+Find me in app/views/users/create.html.erb
diff --git a/app/views/users/new.html.erb b/app/views/users/new.html.erb
new file mode 100644
index 0000000..3b5b874
--- /dev/null
+++ b/app/views/users/new.html.erb
@@ -0,0 +1,33 @@
+Sign Up
+
+<%= form_for @user do |f| %>
+ <% if @user.errors.any? %>
+
+
Form is invalid
+
+ <% for message in @user.errors.full_messages %>
+ - <%= message %>
+ <% end %>
+
+
+ <% end %>
+
+
+ <%= f.label :user_name %>
+ <%= f.text_field :user_name %>
+
+
+
+ <%= f.label :email %>
+ <%= f.text_field :email %>
+
+
+ <%= f.label :password %>
+ <%= f.password_field :password %>
+
+
+ <%= f.label :password_confirmation %>
+ <%= f.password_field :password_confirmation %>
+
+ <%= f.submit %>
+<% end %>
\ No newline at end of file
diff --git a/built_in_extensions.rb b/built_in_extensions.rb
new file mode 100644
index 0000000..0861943
--- /dev/null
+++ b/built_in_extensions.rb
@@ -0,0 +1 @@
+gem 'announcement', git: 'git@gitlab.tp.rulingcom.com:saurabh/announcement-test.git'
diff --git a/config/initializers/keyword_constraint.rb b/config/initializers/keyword_constraint.rb
index 6906dd2..adb8472 100644
--- a/config/initializers/keyword_constraint.rb
+++ b/config/initializers/keyword_constraint.rb
@@ -1,6 +1,6 @@
class KeywordConstraint
def matches?(request)
- keywords = %w{admin member desktop}
+ keywords = %w{admin member desktop user}
keywords.all? { |k| !request.url.include?(k) }
end
end
\ No newline at end of file
diff --git a/config/routes.rb b/config/routes.rb
index eb17a9e..7afa392 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -1,5 +1,7 @@
OrbitStore::Application.routes.draw do
+ resources :users
+
get "/pages/edit_view" => "pages#edit_view"
get "/pages/preview" => "pages#preview"
diff --git a/downloaded_extensions.rb b/downloaded_extensions.rb
new file mode 100644
index 0000000..e69de29
diff --git a/lib/orbit_app/helper/side_bar_renderer.rb b/lib/orbit_app/helper/side_bar_renderer.rb
index 2cfd2ed..7412dcd 100644
--- a/lib/orbit_app/helper/side_bar_renderer.rb
+++ b/lib/orbit_app/helper/side_bar_renderer.rb
@@ -39,6 +39,4 @@ module SideBarRenderer
@active_for_controllers.include? controller
end
-
-
end
\ No newline at end of file
diff --git a/test/controllers/users_controller_test.rb b/test/controllers/users_controller_test.rb
index 4e01165..650800e 100644
--- a/test/controllers/users_controller_test.rb
+++ b/test/controllers/users_controller_test.rb
@@ -1,49 +1,14 @@
require 'test_helper'
class UsersControllerTest < ActionController::TestCase
- setup do
- @user = users(:one)
- end
-
- test "should get index" do
- get :index
- assert_response :success
- assert_not_nil assigns(:users)
- end
-
test "should get new" do
get :new
assert_response :success
end
- test "should create user" do
- assert_difference('User.count') do
- post :create, user: { first_name: @user.first_name, last_name: @user.last_name }
- end
-
- assert_redirected_to user_path(assigns(:user))
- end
-
- test "should show user" do
- get :show, id: @user
+ test "should get create" do
+ get :create
assert_response :success
end
- test "should get edit" do
- get :edit, id: @user
- assert_response :success
- end
-
- test "should update user" do
- patch :update, id: @user, user: { first_name: @user.first_name, last_name: @user.last_name }
- assert_redirected_to user_path(assigns(:user))
- end
-
- test "should destroy user" do
- assert_difference('User.count', -1) do
- delete :destroy, id: @user
- end
-
- assert_redirected_to users_path
- end
end
diff --git a/test/fixtures/users.yml b/test/fixtures/users.yml
index afdaa6a..6ed1a86 100644
--- a/test/fixtures/users.yml
+++ b/test/fixtures/users.yml
@@ -1,9 +1,11 @@
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
one:
- first_name: MyString
- last_name: MyString
+ user_name: MyString
+ email: MyString
+ password_digest: MyString
two:
- first_name: MyString
- last_name: MyString
+ user_name: MyString
+ email: MyString
+ password_digest: MyString
diff --git a/test/models/user_test.rb b/test/models/user_test.rb
index 82f61e0..d293390 100644
--- a/test/models/user_test.rb
+++ b/test/models/user_test.rb
@@ -1,7 +1,45 @@
+#this is a class to test the signup
require 'test_helper'
+require 'minitest/autorun'
class UserTest < ActiveSupport::TestCase
- # test "the truth" do
- # assert true
- # end
+ def valid_params
+ { user_name: "johndoe", email: "john@example.com", password: "password123", password_confirmation: "password123" }
+ end
+
+ let(:user) { User.new valid_params }
+
+ it "should fail when password and password confirmation do not match" do
+ def user.password_confirmation
+ "password456"
+ end
+ user.wont_be :valid?
+ end
+
+ it "should not pass when email not supplied" do
+ def user.email
+ nil
+ end
+ user.wont_be :valid?
+ user.errors[:email].must_be :present?
+ end
+
+ it "should not pass when user_name not supplied" do
+ def user.user_name
+ nil
+ end
+ user.wont_be :valid?
+ user.errors[:user_name].must_be :present?
+ end
+
+ it "should pass when password and password confirmation are same" do
+ assert user.must_be :valid?, "Can't create with valid params: #{user.errors.messages}"
+ end
+
+ it "should check the email format" do
+ def user.email
+ "fsdnjgsjk@lo;;sdfd"
+ end
+ user.wont_be :valid?
+ end
end