initial commit
This commit is contained in:
commit
1cf08781b4
2
.byebug_history
Normal file
2
.byebug_history
Normal file
@ -0,0 +1,2 @@
|
||||
exit
|
||||
current_controller
|
17
.gitignore
vendored
Normal file
17
.gitignore
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
# See https://help.github.com/articles/ignoring-files for more about ignoring files.
|
||||
#
|
||||
# If you find yourself ignoring temporary files generated by your text editor
|
||||
# or operating system, you probably want to add a global ignore instead:
|
||||
# git config --global core.excludesfile '~/.gitignore_global'
|
||||
|
||||
# Ignore bundler config.
|
||||
/.bundle
|
||||
|
||||
# Ignore the default SQLite database.
|
||||
/db/*.sqlite3
|
||||
/db/*.sqlite3-journal
|
||||
|
||||
# Ignore all logfiles and tempfiles.
|
||||
/log/*
|
||||
!/log/.keep
|
||||
/tmp
|
8
.idea/.generators
Normal file
8
.idea/.generators
Normal file
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Settings><!--This file was automatically generated by Ruby plugin.
|
||||
You are allowed to:
|
||||
1. Reorder generators
|
||||
2. Remove generators
|
||||
3. Add installed generators
|
||||
To add new installed generators automatically delete this file and reload the project.
|
||||
--><GeneratorsGroup><Generator name="active_record:migration" /><Generator name="active_record:model" /><Generator name="active_record:observer" /><Generator name="active_record:session_migration" /><Generator name="controller" /><Generator name="erb:controller" /><Generator name="erb:mailer" /><Generator name="erb:scaffold" /><Generator name="generator" /><Generator name="helper" /><Generator name="integration_test" /><Generator name="mailer" /><Generator name="metal" /><Generator name="migration" /><Generator name="model" /><Generator name="model_subclass" /><Generator name="observer" /><Generator name="performance_test" /><Generator name="plugin" /><Generator name="resource" /><Generator name="scaffold" /><Generator name="scaffold_controller" /><Generator name="session_migration" /><Generator name="stylesheets" /><Generator name="test_unit:controller" /><Generator name="test_unit:helper" /><Generator name="test_unit:integration" /><Generator name="test_unit:mailer" /><Generator name="test_unit:model" /><Generator name="test_unit:observer" /><Generator name="test_unit:performance" /><Generator name="test_unit:plugin" /><Generator name="test_unit:scaffold" /></GeneratorsGroup></Settings>
|
1
.idea/.name
Normal file
1
.idea/.name
Normal file
@ -0,0 +1 @@
|
||||
cookbook
|
7
.idea/.rakeTasks
Normal file
7
.idea/.rakeTasks
Normal file
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Settings><!--This file was automatically generated by Ruby plugin.
|
||||
You are allowed to:
|
||||
1. Remove rake task
|
||||
2. Add existing rake tasks
|
||||
To add existing rake tasks automatically delete this file and reload the project.
|
||||
--><RakeGroup description="" fullCmd="" taksId="rake" /></Settings>
|
180
.idea/cookbook.iml
Normal file
180
.idea/cookbook.iml
Normal file
@ -0,0 +1,180 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="RUBY_MODULE" version="4">
|
||||
<component name="FacetManager">
|
||||
<facet type="RailsFacetType" name="Ruby on Rails">
|
||||
<configuration>
|
||||
<RAILS_FACET_CONFIG_ID NAME="RAILS_FACET_SUPPORT_REMOVED" VALUE="false" />
|
||||
<RAILS_FACET_CONFIG_ID NAME="RAILS_TESTS_SOURCES_PATCHED" VALUE="true" />
|
||||
<RAILS_FACET_CONFIG_ID NAME="RAILS_FACET_APPLICATION_ROOT" VALUE="$MODULE_DIR$" />
|
||||
</configuration>
|
||||
</facet>
|
||||
</component>
|
||||
<component name="ModuleRunConfigurationManager">
|
||||
<configuration default="false" name="test: cookbook" type="RakeRunConfigurationType" factoryName="Rake">
|
||||
<module name="cookbook" />
|
||||
<RAKE_RUN_CONFIG_SETTINGS_ID NAME="RUBY_ARGS" VALUE="-e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift)" />
|
||||
<RAKE_RUN_CONFIG_SETTINGS_ID NAME="WORK DIR" VALUE="$MODULE_DIR$" />
|
||||
<RAKE_RUN_CONFIG_SETTINGS_ID NAME="SHOULD_USE_SDK" VALUE="false" />
|
||||
<RAKE_RUN_CONFIG_SETTINGS_ID NAME="ALTERN_SDK_NAME" VALUE="" />
|
||||
<RAKE_RUN_CONFIG_SETTINGS_ID NAME="myPassParentEnvs" VALUE="true" />
|
||||
<envs>
|
||||
<env name="RAILS_ENV" value="test" />
|
||||
</envs>
|
||||
<EXTENSION ID="BundlerRunConfigurationExtension" bundleExecEnabled="false" />
|
||||
<EXTENSION ID="JRubyRunConfigurationExtension" NailgunExecEnabled="false" />
|
||||
<EXTENSION ID="RubyCoverageRunConfigurationExtension" enabled="false" sample_coverage="true" track_test_folders="true" runner="rcov">
|
||||
<COVERAGE_PATTERN ENABLED="true">
|
||||
<PATTERN REGEXPS="/.rvm/" INCLUDED="false" />
|
||||
</COVERAGE_PATTERN>
|
||||
</EXTENSION>
|
||||
<EXTENSION ID="org.jetbrains.plugins.ruby.motion.run.MotionSimulatorRunExtension" />
|
||||
<RAKE_RUN_CONFIG_SETTINGS_ID NAME="RAKE_TASK_NAME" VALUE="test" />
|
||||
<RAKE_RUN_CONFIG_SETTINGS_ID NAME="RAKE_TASK_ARGS" VALUE="" />
|
||||
<RAKE_RUN_CONFIG_SETTINGS_ID NAME="RAKE_TASK_ATTACHED_TEST_FRAMEWORKS" VALUE=":test_unit " />
|
||||
<RAKE_RUN_CONFIG_SETTINGS_ID NAME="RAKE_TASK_OPTION_TRACE" VALUE="false" />
|
||||
<RAKE_RUN_CONFIG_SETTINGS_ID NAME="RAKE_TASK_OPTION_DRYRUN" VALUE="false" />
|
||||
<RAKE_RUN_CONFIG_SETTINGS_ID NAME="RAKE_TASK_OPTION_PREREQS" VALUE="false" />
|
||||
<method />
|
||||
</configuration>
|
||||
<configuration default="false" name="spec: cookbook" type="RakeRunConfigurationType" factoryName="Rake">
|
||||
<module name="cookbook" />
|
||||
<RAKE_RUN_CONFIG_SETTINGS_ID NAME="RUBY_ARGS" VALUE="-e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift)" />
|
||||
<RAKE_RUN_CONFIG_SETTINGS_ID NAME="WORK DIR" VALUE="$MODULE_DIR$" />
|
||||
<RAKE_RUN_CONFIG_SETTINGS_ID NAME="SHOULD_USE_SDK" VALUE="false" />
|
||||
<RAKE_RUN_CONFIG_SETTINGS_ID NAME="ALTERN_SDK_NAME" VALUE="" />
|
||||
<RAKE_RUN_CONFIG_SETTINGS_ID NAME="myPassParentEnvs" VALUE="true" />
|
||||
<envs />
|
||||
<EXTENSION ID="BundlerRunConfigurationExtension" bundleExecEnabled="false" />
|
||||
<EXTENSION ID="JRubyRunConfigurationExtension" NailgunExecEnabled="false" />
|
||||
<EXTENSION ID="RubyCoverageRunConfigurationExtension" enabled="false" sample_coverage="true" track_test_folders="true" runner="rcov">
|
||||
<COVERAGE_PATTERN ENABLED="true">
|
||||
<PATTERN REGEXPS="/.rvm/" INCLUDED="false" />
|
||||
</COVERAGE_PATTERN>
|
||||
</EXTENSION>
|
||||
<EXTENSION ID="org.jetbrains.plugins.ruby.motion.run.MotionSimulatorRunExtension" />
|
||||
<RAKE_RUN_CONFIG_SETTINGS_ID NAME="RAKE_TASK_NAME" VALUE="spec" />
|
||||
<RAKE_RUN_CONFIG_SETTINGS_ID NAME="RAKE_TASK_ARGS" VALUE="" />
|
||||
<RAKE_RUN_CONFIG_SETTINGS_ID NAME="RAKE_TASK_ATTACHED_TEST_FRAMEWORKS" VALUE=":rspec " />
|
||||
<RAKE_RUN_CONFIG_SETTINGS_ID NAME="RAKE_TASK_OPTION_TRACE" VALUE="false" />
|
||||
<RAKE_RUN_CONFIG_SETTINGS_ID NAME="RAKE_TASK_OPTION_DRYRUN" VALUE="false" />
|
||||
<RAKE_RUN_CONFIG_SETTINGS_ID NAME="RAKE_TASK_OPTION_PREREQS" VALUE="false" />
|
||||
<method />
|
||||
</configuration>
|
||||
<configuration default="false" name="Production: cookbook" type="RailsRunConfigurationType" factoryName="Rails">
|
||||
<predefined_log_file id="RUBY_RAILS_SERVER" enabled="true" />
|
||||
<module name="cookbook" />
|
||||
<RAILS_SERVER_CONFIG_SETTINGS_ID NAME="RUBY_ARGS" VALUE="-e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift)" />
|
||||
<RAILS_SERVER_CONFIG_SETTINGS_ID NAME="WORK DIR" VALUE="$MODULE_DIR$" />
|
||||
<RAILS_SERVER_CONFIG_SETTINGS_ID NAME="SHOULD_USE_SDK" VALUE="false" />
|
||||
<RAILS_SERVER_CONFIG_SETTINGS_ID NAME="ALTERN_SDK_NAME" VALUE="" />
|
||||
<RAILS_SERVER_CONFIG_SETTINGS_ID NAME="myPassParentEnvs" VALUE="true" />
|
||||
<envs />
|
||||
<EXTENSION ID="BundlerRunConfigurationExtension" bundleExecEnabled="false" />
|
||||
<EXTENSION ID="JRubyRunConfigurationExtension" NailgunExecEnabled="false" />
|
||||
<EXTENSION ID="RubyCoverageRunConfigurationExtension" enabled="false" sample_coverage="true" track_test_folders="true" runner="rcov">
|
||||
<COVERAGE_PATTERN ENABLED="true">
|
||||
<PATTERN REGEXPS="/.rvm/" INCLUDED="false" />
|
||||
</COVERAGE_PATTERN>
|
||||
</EXTENSION>
|
||||
<EXTENSION ID="org.jetbrains.plugins.ruby.motion.run.MotionSimulatorRunExtension" />
|
||||
<RAILS_SERVER_CONFIG_SETTINGS_ID NAME="SCRIPT_ARGS" VALUE="" />
|
||||
<RAILS_SERVER_CONFIG_SETTINGS_ID NAME="PORT" VALUE="3000" />
|
||||
<RAILS_SERVER_CONFIG_SETTINGS_ID NAME="IP" VALUE="0.0.0.0" />
|
||||
<RAILS_SERVER_CONFIG_SETTINGS_ID NAME="DUMMY_APP" VALUE="test/dummy" />
|
||||
<RAILS_SERVER_CONFIG_SETTINGS_ID NAME="RAILS_SERVER_TYPE" VALUE="Default" />
|
||||
<RAILS_SERVER_CONFIG_SETTINGS_ID NAME="ENVIRONMENT_TYPE" VALUE="production" />
|
||||
<RAILS_SERVER_CONFIG_SETTINGS_ID NAME="LAUNCH_JS" VALUE="false" />
|
||||
<method />
|
||||
</configuration>
|
||||
<configuration default="false" name="Development: cookbook" type="RailsRunConfigurationType" factoryName="Rails">
|
||||
<predefined_log_file id="RUBY_RAILS_SERVER" enabled="true" />
|
||||
<module name="cookbook" />
|
||||
<RAILS_SERVER_CONFIG_SETTINGS_ID NAME="RUBY_ARGS" VALUE="-e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift)" />
|
||||
<RAILS_SERVER_CONFIG_SETTINGS_ID NAME="WORK DIR" VALUE="$MODULE_DIR$" />
|
||||
<RAILS_SERVER_CONFIG_SETTINGS_ID NAME="SHOULD_USE_SDK" VALUE="false" />
|
||||
<RAILS_SERVER_CONFIG_SETTINGS_ID NAME="ALTERN_SDK_NAME" VALUE="" />
|
||||
<RAILS_SERVER_CONFIG_SETTINGS_ID NAME="myPassParentEnvs" VALUE="true" />
|
||||
<envs />
|
||||
<EXTENSION ID="BundlerRunConfigurationExtension" bundleExecEnabled="false" />
|
||||
<EXTENSION ID="JRubyRunConfigurationExtension" NailgunExecEnabled="false" />
|
||||
<EXTENSION ID="RubyCoverageRunConfigurationExtension" enabled="false" sample_coverage="true" track_test_folders="true" runner="rcov">
|
||||
<COVERAGE_PATTERN ENABLED="true">
|
||||
<PATTERN REGEXPS="/.rvm/" INCLUDED="false" />
|
||||
</COVERAGE_PATTERN>
|
||||
</EXTENSION>
|
||||
<EXTENSION ID="org.jetbrains.plugins.ruby.motion.run.MotionSimulatorRunExtension" />
|
||||
<RAILS_SERVER_CONFIG_SETTINGS_ID NAME="SCRIPT_ARGS" VALUE="" />
|
||||
<RAILS_SERVER_CONFIG_SETTINGS_ID NAME="PORT" VALUE="3000" />
|
||||
<RAILS_SERVER_CONFIG_SETTINGS_ID NAME="IP" VALUE="0.0.0.0" />
|
||||
<RAILS_SERVER_CONFIG_SETTINGS_ID NAME="DUMMY_APP" VALUE="test/dummy" />
|
||||
<RAILS_SERVER_CONFIG_SETTINGS_ID NAME="RAILS_SERVER_TYPE" VALUE="Default" />
|
||||
<RAILS_SERVER_CONFIG_SETTINGS_ID NAME="ENVIRONMENT_TYPE" VALUE="development" />
|
||||
<RAILS_SERVER_CONFIG_SETTINGS_ID NAME="LAUNCH_JS" VALUE="false" />
|
||||
<method />
|
||||
</configuration>
|
||||
</component>
|
||||
<component name="NewModuleRootManager">
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/spec" isTestSource="true" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/components" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/public/system" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/tmp" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="actionmailer (v4.2.5, RVM: ruby-2.1.1) [gem]" level="application" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="actionpack (v4.2.5, RVM: ruby-2.1.1) [gem]" level="application" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="actionview (v4.2.5, RVM: ruby-2.1.1) [gem]" level="application" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="activejob (v4.2.5, RVM: ruby-2.1.1) [gem]" level="application" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="activemodel (v4.2.5, RVM: ruby-2.1.1) [gem]" level="application" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="activerecord (v4.2.5, RVM: ruby-2.1.1) [gem]" level="application" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="activesupport (v4.2.5, RVM: ruby-2.1.1) [gem]" level="application" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="arel (v6.0.3, RVM: ruby-2.1.1) [gem]" level="application" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="bootstrap-sass (v3.3.6, RVM: ruby-2.1.1) [gem]" level="application" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="builder (v3.2.2, RVM: ruby-2.1.1) [gem]" level="application" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="bundler (v1.10.6, RVM: ruby-2.1.1) [gem]" level="application" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="concurrent-ruby (v1.0.0, RVM: ruby-2.1.1) [gem]" level="application" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="database_cleaner (v1.5.1, RVM: ruby-2.1.1) [gem]" level="application" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="diff-lcs (v1.2.5, RVM: ruby-2.1.1) [gem]" level="application" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="erubis (v2.7.0, RVM: ruby-2.1.1) [gem]" level="application" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="execjs (v2.6.0, RVM: ruby-2.1.1) [gem]" level="application" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="factory_girl (v4.5.0, RVM: ruby-2.1.1) [gem]" level="application" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="factory_girl_rails (v4.5.0, RVM: ruby-2.1.1) [gem]" level="application" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="globalid (v0.3.6, RVM: ruby-2.1.1) [gem]" level="application" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="i18n (v0.7.0, RVM: ruby-2.1.1) [gem]" level="application" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="jquery-rails (v4.0.5, RVM: ruby-2.1.1) [gem]" level="application" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="json (v1.8.3, RVM: ruby-2.1.1) [gem]" level="application" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="libv8 (v3.16.14.13, RVM: ruby-2.1.1) [gem]" level="application" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="loofah (v2.0.3, RVM: ruby-2.1.1) [gem]" level="application" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="mail (v2.6.3, RVM: ruby-2.1.1) [gem]" level="application" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="mime-types (v2.99, RVM: ruby-2.1.1) [gem]" level="application" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="mini_portile2 (v2.0.0, RVM: ruby-2.1.1) [gem]" level="application" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="minitest (v5.8.3, RVM: ruby-2.1.1) [gem]" level="application" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="multi_json (v1.11.2, RVM: ruby-2.1.1) [gem]" level="application" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="rack (v1.6.4, RVM: ruby-2.1.1) [gem]" level="application" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="rack-test (v0.6.3, RVM: ruby-2.1.1) [gem]" level="application" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="rails (v4.2.5, RVM: ruby-2.1.1) [gem]" level="application" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="rails-deprecated_sanitizer (v1.0.3, RVM: ruby-2.1.1) [gem]" level="application" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="rails-dom-testing (v1.0.7, RVM: ruby-2.1.1) [gem]" level="application" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="rails-html-sanitizer (v1.0.2, RVM: ruby-2.1.1) [gem]" level="application" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="railties (v4.2.5, RVM: ruby-2.1.1) [gem]" level="application" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="rake (v10.4.2, RVM: ruby-2.1.1) [gem]" level="application" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="ref (v2.0.0, RVM: ruby-2.1.1) [gem]" level="application" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="rspec-core (v3.4.1, RVM: ruby-2.1.1) [gem]" level="application" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="rspec-expectations (v3.4.0, RVM: ruby-2.1.1) [gem]" level="application" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="rspec-rails (v3.4.0, RVM: ruby-2.1.1) [gem]" level="application" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="rspec-support (v3.4.1, RVM: ruby-2.1.1) [gem]" level="application" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="sass-rails (v5.0.4, RVM: ruby-2.1.1) [gem]" level="application" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="sqlite3 (v1.3.11, RVM: ruby-2.1.1) [gem]" level="application" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="therubyracer (v0.12.2, RVM: ruby-2.1.1) [gem]" level="application" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="thor (v0.19.1, RVM: ruby-2.1.1) [gem]" level="application" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="thread_safe (v0.3.5, RVM: ruby-2.1.1) [gem]" level="application" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="tzinfo (v1.2.2, RVM: ruby-2.1.1) [gem]" level="application" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="uglifier (v2.7.2, RVM: ruby-2.1.1) [gem]" level="application" />
|
||||
</component>
|
||||
<component name="RModuleSettingsStorage">
|
||||
<LOAD_PATH number="0" />
|
||||
<I18N_FOLDERS number="1" string0="$MODULE_DIR$/config/locales" />
|
||||
</component>
|
||||
</module>
|
14
.idea/misc.xml
Normal file
14
.idea/misc.xml
Normal file
@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectLevelVcsManager" settingsEditedManually="false">
|
||||
<OptionsSetting value="true" id="Add" />
|
||||
<OptionsSetting value="true" id="Remove" />
|
||||
<OptionsSetting value="true" id="Checkout" />
|
||||
<OptionsSetting value="true" id="Update" />
|
||||
<OptionsSetting value="true" id="Status" />
|
||||
<OptionsSetting value="true" id="Edit" />
|
||||
<ConfirmationsSetting value="0" id="Add" />
|
||||
<ConfirmationsSetting value="0" id="Remove" />
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" project-jdk-name="RVM: ruby-2.1.1" project-jdk-type="RUBY_SDK" />
|
||||
</project>
|
8
.idea/modules.xml
Normal file
8
.idea/modules.xml
Normal file
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/cookbook.iml" filepath="$PROJECT_DIR$/.idea/cookbook.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
6
.idea/vcs.xml
Normal file
6
.idea/vcs.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="" vcs="" />
|
||||
</component>
|
||||
</project>
|
1025
.idea/workspace.xml
Normal file
1025
.idea/workspace.xml
Normal file
File diff suppressed because it is too large
Load Diff
42
Gemfile
Normal file
42
Gemfile
Normal file
@ -0,0 +1,42 @@
|
||||
source 'https://rubygems.org'
|
||||
|
||||
|
||||
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
|
||||
gem 'rails', '4.2.5'
|
||||
gem 'sqlite3'
|
||||
gem 'sass-rails', '~> 5.0'
|
||||
gem 'uglifier', '>= 1.3.0'
|
||||
|
||||
# See https://github.com/rails/execjs#readme for more supported runtimes
|
||||
gem 'therubyracer', platforms: :ruby
|
||||
|
||||
# Use jquery as the JavaScript library
|
||||
gem 'jquery-rails'
|
||||
gem 'bootstrap-sass', '~> 3.3.6'
|
||||
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
|
||||
gem 'turbolinks'
|
||||
gem 'jbuilder', '~> 2.0'
|
||||
|
||||
# Use ActiveModel has_secure_password
|
||||
# gem 'bcrypt', '~> 3.1.7'
|
||||
|
||||
# Use Unicorn as the app server
|
||||
# gem 'unicorn'
|
||||
|
||||
# Use Capistrano for deployment
|
||||
# gem 'capistrano-rails', group: :development
|
||||
|
||||
group :development, :test do
|
||||
|
||||
gem 'rspec-rails', '~> 3.4.0'
|
||||
gem 'factory_girl_rails', '~> 4.5.0'
|
||||
gem 'database_cleaner', '~> 1.5.1'
|
||||
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
|
||||
gem 'byebug'
|
||||
end
|
||||
|
||||
group :development do
|
||||
# Access an IRB console on exception pages or by using <%= console %> in views
|
||||
gem 'web-console', '~> 2.0'
|
||||
end
|
||||
|
190
Gemfile.lock
Normal file
190
Gemfile.lock
Normal file
@ -0,0 +1,190 @@
|
||||
GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
actionmailer (4.2.5)
|
||||
actionpack (= 4.2.5)
|
||||
actionview (= 4.2.5)
|
||||
activejob (= 4.2.5)
|
||||
mail (~> 2.5, >= 2.5.4)
|
||||
rails-dom-testing (~> 1.0, >= 1.0.5)
|
||||
actionpack (4.2.5)
|
||||
actionview (= 4.2.5)
|
||||
activesupport (= 4.2.5)
|
||||
rack (~> 1.6)
|
||||
rack-test (~> 0.6.2)
|
||||
rails-dom-testing (~> 1.0, >= 1.0.5)
|
||||
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
||||
actionview (4.2.5)
|
||||
activesupport (= 4.2.5)
|
||||
builder (~> 3.1)
|
||||
erubis (~> 2.7.0)
|
||||
rails-dom-testing (~> 1.0, >= 1.0.5)
|
||||
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
||||
activejob (4.2.5)
|
||||
activesupport (= 4.2.5)
|
||||
globalid (>= 0.3.0)
|
||||
activemodel (4.2.5)
|
||||
activesupport (= 4.2.5)
|
||||
builder (~> 3.1)
|
||||
activerecord (4.2.5)
|
||||
activemodel (= 4.2.5)
|
||||
activesupport (= 4.2.5)
|
||||
arel (~> 6.0)
|
||||
activesupport (4.2.5)
|
||||
i18n (~> 0.7)
|
||||
json (~> 1.7, >= 1.7.7)
|
||||
minitest (~> 5.1)
|
||||
thread_safe (~> 0.3, >= 0.3.4)
|
||||
tzinfo (~> 1.1)
|
||||
arel (6.0.3)
|
||||
autoprefixer-rails (6.2.3)
|
||||
execjs
|
||||
json
|
||||
binding_of_caller (0.7.2)
|
||||
debug_inspector (>= 0.0.1)
|
||||
bootstrap-sass (3.3.6)
|
||||
autoprefixer-rails (>= 5.2.1)
|
||||
sass (>= 3.3.4)
|
||||
builder (3.2.2)
|
||||
byebug (8.2.1)
|
||||
coffee-rails (4.1.1)
|
||||
coffee-script (>= 2.2.0)
|
||||
railties (>= 4.0.0, < 5.1.x)
|
||||
coffee-script (2.4.1)
|
||||
coffee-script-source
|
||||
execjs
|
||||
coffee-script-source (1.10.0)
|
||||
concurrent-ruby (1.0.0)
|
||||
database_cleaner (1.5.1)
|
||||
debug_inspector (0.0.2)
|
||||
diff-lcs (1.2.5)
|
||||
erubis (2.7.0)
|
||||
execjs (2.6.0)
|
||||
factory_girl (4.5.0)
|
||||
activesupport (>= 3.0.0)
|
||||
factory_girl_rails (4.5.0)
|
||||
factory_girl (~> 4.5.0)
|
||||
railties (>= 3.0.0)
|
||||
globalid (0.3.6)
|
||||
activesupport (>= 4.1.0)
|
||||
i18n (0.7.0)
|
||||
jbuilder (2.4.0)
|
||||
activesupport (>= 3.0.0, < 5.1)
|
||||
multi_json (~> 1.2)
|
||||
jquery-rails (4.0.5)
|
||||
rails-dom-testing (~> 1.0)
|
||||
railties (>= 4.2.0)
|
||||
thor (>= 0.14, < 2.0)
|
||||
json (1.8.3)
|
||||
libv8 (3.16.14.13)
|
||||
loofah (2.0.3)
|
||||
nokogiri (>= 1.5.9)
|
||||
mail (2.6.3)
|
||||
mime-types (>= 1.16, < 3)
|
||||
mime-types (2.99)
|
||||
mini_portile2 (2.0.0)
|
||||
minitest (5.8.3)
|
||||
multi_json (1.11.2)
|
||||
nokogiri (1.6.7.1)
|
||||
mini_portile2 (~> 2.0.0.rc2)
|
||||
rack (1.6.4)
|
||||
rack-test (0.6.3)
|
||||
rack (>= 1.0)
|
||||
rails (4.2.5)
|
||||
actionmailer (= 4.2.5)
|
||||
actionpack (= 4.2.5)
|
||||
actionview (= 4.2.5)
|
||||
activejob (= 4.2.5)
|
||||
activemodel (= 4.2.5)
|
||||
activerecord (= 4.2.5)
|
||||
activesupport (= 4.2.5)
|
||||
bundler (>= 1.3.0, < 2.0)
|
||||
railties (= 4.2.5)
|
||||
sprockets-rails
|
||||
rails-deprecated_sanitizer (1.0.3)
|
||||
activesupport (>= 4.2.0.alpha)
|
||||
rails-dom-testing (1.0.7)
|
||||
activesupport (>= 4.2.0.beta, < 5.0)
|
||||
nokogiri (~> 1.6.0)
|
||||
rails-deprecated_sanitizer (>= 1.0.1)
|
||||
rails-html-sanitizer (1.0.2)
|
||||
loofah (~> 2.0)
|
||||
railties (4.2.5)
|
||||
actionpack (= 4.2.5)
|
||||
activesupport (= 4.2.5)
|
||||
rake (>= 0.8.7)
|
||||
thor (>= 0.18.1, < 2.0)
|
||||
rake (10.4.2)
|
||||
ref (2.0.0)
|
||||
rspec-core (3.4.1)
|
||||
rspec-support (~> 3.4.0)
|
||||
rspec-expectations (3.4.0)
|
||||
diff-lcs (>= 1.2.0, < 2.0)
|
||||
rspec-support (~> 3.4.0)
|
||||
rspec-mocks (3.4.1)
|
||||
diff-lcs (>= 1.2.0, < 2.0)
|
||||
rspec-support (~> 3.4.0)
|
||||
rspec-rails (3.4.0)
|
||||
actionpack (>= 3.0, < 4.3)
|
||||
activesupport (>= 3.0, < 4.3)
|
||||
railties (>= 3.0, < 4.3)
|
||||
rspec-core (~> 3.4.0)
|
||||
rspec-expectations (~> 3.4.0)
|
||||
rspec-mocks (~> 3.4.0)
|
||||
rspec-support (~> 3.4.0)
|
||||
rspec-support (3.4.1)
|
||||
sass (3.4.21)
|
||||
sass-rails (5.0.4)
|
||||
railties (>= 4.0.0, < 5.0)
|
||||
sass (~> 3.1)
|
||||
sprockets (>= 2.8, < 4.0)
|
||||
sprockets-rails (>= 2.0, < 4.0)
|
||||
tilt (>= 1.1, < 3)
|
||||
sprockets (3.5.2)
|
||||
concurrent-ruby (~> 1.0)
|
||||
rack (> 1, < 3)
|
||||
sprockets-rails (3.0.0)
|
||||
actionpack (>= 4.0)
|
||||
activesupport (>= 4.0)
|
||||
sprockets (>= 3.0.0)
|
||||
sqlite3 (1.3.11)
|
||||
therubyracer (0.12.2)
|
||||
libv8 (~> 3.16.14.0)
|
||||
ref
|
||||
thor (0.19.1)
|
||||
thread_safe (0.3.5)
|
||||
tilt (2.0.2)
|
||||
turbolinks (2.5.3)
|
||||
coffee-rails
|
||||
tzinfo (1.2.2)
|
||||
thread_safe (~> 0.1)
|
||||
uglifier (2.7.2)
|
||||
execjs (>= 0.3.0)
|
||||
json (>= 1.8.0)
|
||||
web-console (2.2.1)
|
||||
activemodel (>= 4.0)
|
||||
binding_of_caller (>= 0.7.2)
|
||||
railties (>= 4.0)
|
||||
sprockets-rails (>= 2.0, < 4.0)
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
|
||||
DEPENDENCIES
|
||||
bootstrap-sass (~> 3.3.6)
|
||||
byebug
|
||||
database_cleaner (~> 1.5.1)
|
||||
factory_girl_rails (~> 4.5.0)
|
||||
jbuilder (~> 2.0)
|
||||
jquery-rails
|
||||
rails (= 4.2.5)
|
||||
rspec-rails (~> 3.4.0)
|
||||
sass-rails (~> 5.0)
|
||||
sqlite3
|
||||
therubyracer
|
||||
turbolinks
|
||||
uglifier (>= 1.3.0)
|
||||
web-console (~> 2.0)
|
||||
|
||||
BUNDLED WITH
|
||||
1.10.6
|
28
README.rdoc
Normal file
28
README.rdoc
Normal file
@ -0,0 +1,28 @@
|
||||
== README
|
||||
|
||||
This README would normally document whatever steps are necessary to get the
|
||||
application up and running.
|
||||
|
||||
Things you may want to cover:
|
||||
|
||||
* Ruby version
|
||||
|
||||
* System dependencies
|
||||
|
||||
* Configuration
|
||||
|
||||
* Database creation
|
||||
|
||||
* Database initialization
|
||||
|
||||
* How to run the test suite
|
||||
|
||||
* Services (job queues, cache servers, search engines, etc.)
|
||||
|
||||
* Deployment instructions
|
||||
|
||||
* ...
|
||||
|
||||
|
||||
Please feel free to use a different markup language if you do not plan to run
|
||||
<tt>rake doc:app</tt>.
|
6
Rakefile
Normal file
6
Rakefile
Normal file
@ -0,0 +1,6 @@
|
||||
# Add your own tasks in files placed in lib/tasks ending in .rake,
|
||||
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
|
||||
|
||||
require File.expand_path('../config/application', __FILE__)
|
||||
|
||||
Rails.application.load_tasks
|
0
app/assets/images/.keep
Normal file
0
app/assets/images/.keep
Normal file
17
app/assets/javascripts/application.js
Normal file
17
app/assets/javascripts/application.js
Normal file
@ -0,0 +1,17 @@
|
||||
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
||||
// listed below.
|
||||
//
|
||||
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
||||
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
|
||||
//
|
||||
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
||||
// compiled file.
|
||||
//
|
||||
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
|
||||
// about supported directives.
|
||||
//
|
||||
//= require jquery
|
||||
//= require jquery_ujs
|
||||
//= require turbolinks
|
||||
//= require bootstrap-sprockets
|
||||
//= require_tree .
|
34
app/assets/javascripts/flash_messages.js
Normal file
34
app/assets/javascripts/flash_messages.js
Normal file
@ -0,0 +1,34 @@
|
||||
|
||||
var flashMessageTypeMap = {
|
||||
error: "danger",
|
||||
notice: "success"
|
||||
};
|
||||
|
||||
function flashMessage(flashType, message) {
|
||||
|
||||
var timeoutIdContainer = {};
|
||||
|
||||
if (flashMessageTypeMap[flashType]) {
|
||||
flashType = flashMessageTypeMap[flashType];
|
||||
}
|
||||
|
||||
var closeButton = $("<button type='button' />")
|
||||
.addClass("close")
|
||||
.append($("<span />").html("×"))
|
||||
.bind("click.Flash", function() { $(this).parent().hide({effect: "fade", duration: 1000}); clearTimeout(timeoutIdContainer.id); });
|
||||
|
||||
var $flashDiv = $("<div></div>")
|
||||
.html(message)
|
||||
.append(closeButton)
|
||||
.addClass("popup")
|
||||
.addClass("alert")
|
||||
.addClass("alert-" + flashType)
|
||||
.hide()
|
||||
.appendTo("#flashContainer")
|
||||
.show({effect: "pulsate", times: 1, duration: 1500});
|
||||
|
||||
timeoutIdContainer.id = setTimeout(function() {
|
||||
$flashDiv.unbind(".Flash");
|
||||
$flashDiv.hide({effect: "fade", duration: 1000});
|
||||
}, 5000);
|
||||
}
|
29
app/assets/stylesheets/application.scss
Normal file
29
app/assets/stylesheets/application.scss
Normal file
@ -0,0 +1,29 @@
|
||||
/*
|
||||
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
||||
* listed below.
|
||||
*
|
||||
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
||||
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
|
||||
*
|
||||
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
|
||||
* compiled file so the styles you add here take precedence over styles defined in any styles
|
||||
* defined in the other CSS/SCSS files in this directory. It is generally better to create a new
|
||||
* file per style scope.
|
||||
*
|
||||
*= require_tree .
|
||||
*= require_self
|
||||
*/
|
||||
|
||||
|
||||
@import "bootstrap-sprockets";
|
||||
@import "sandstone/_variables";
|
||||
@import "bootstrap";
|
||||
@import "sandstone/_bootswatch";
|
||||
|
||||
.footer {
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
width: 100%;
|
||||
height: 30px;
|
||||
background-color: #f5f5f5;
|
||||
}
|
40
app/assets/stylesheets/flash_messages.scss
Normal file
40
app/assets/stylesheets/flash_messages.scss
Normal file
@ -0,0 +1,40 @@
|
||||
|
||||
#flashContainer {
|
||||
position: fixed;
|
||||
width: 100%;
|
||||
z-index: 9999;
|
||||
}
|
||||
|
||||
.alert.popup {
|
||||
position: fixed;
|
||||
top: 15px;
|
||||
left: 50%;
|
||||
width: 30em;
|
||||
margin-left: -15em;
|
||||
}
|
||||
|
||||
.alert {
|
||||
}
|
||||
|
||||
.flash {
|
||||
text-align: center;
|
||||
width: 30em;
|
||||
padding: 5px;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
}
|
||||
|
||||
.error {
|
||||
background-color: #fff6ff;
|
||||
border: 3px solid #fda8a8;
|
||||
}
|
||||
|
||||
.warning {
|
||||
background-color: #ffffdd;
|
||||
border: 3px solid #ffdd00;
|
||||
}
|
||||
|
||||
.notice {
|
||||
background-color: #D8F6CE;
|
||||
border: 3px solid #3ADF00;
|
||||
}
|
3
app/assets/stylesheets/ingredients.scss
Normal file
3
app/assets/stylesheets/ingredients.scss
Normal file
@ -0,0 +1,3 @@
|
||||
// Place all the styles related to the ingredients controller here.
|
||||
// They will automatically be included in application.css.
|
||||
// You can use Sass (SCSS) here: http://sass-lang.com/
|
3
app/assets/stylesheets/recipes.scss
Normal file
3
app/assets/stylesheets/recipes.scss
Normal file
@ -0,0 +1,3 @@
|
||||
// Place all the styles related to the recipes controller here.
|
||||
// They will automatically be included in application.css.
|
||||
// You can use Sass (SCSS) here: http://sass-lang.com/
|
5
app/controllers/application_controller.rb
Normal file
5
app/controllers/application_controller.rb
Normal file
@ -0,0 +1,5 @@
|
||||
class ApplicationController < ActionController::Base
|
||||
# Prevent CSRF attacks by raising an exception.
|
||||
# For APIs, you may want to use :null_session instead.
|
||||
protect_from_forgery with: :exception
|
||||
end
|
0
app/controllers/concerns/.keep
Normal file
0
app/controllers/concerns/.keep
Normal file
74
app/controllers/ingredients_controller.rb
Normal file
74
app/controllers/ingredients_controller.rb
Normal file
@ -0,0 +1,74 @@
|
||||
class IngredientsController < ApplicationController
|
||||
before_action :set_ingredient, only: [:show, :edit, :update, :destroy]
|
||||
|
||||
# GET /ingredients
|
||||
# GET /ingredients.json
|
||||
def index
|
||||
@ingredients = Ingredient.all
|
||||
end
|
||||
|
||||
# GET /ingredients/1
|
||||
# GET /ingredients/1.json
|
||||
def show
|
||||
end
|
||||
|
||||
# GET /ingredients/new
|
||||
def new
|
||||
@ingredient = Ingredient.new
|
||||
end
|
||||
|
||||
# GET /ingredients/1/edit
|
||||
def edit
|
||||
end
|
||||
|
||||
# POST /ingredients
|
||||
# POST /ingredients.json
|
||||
def create
|
||||
@ingredient = Ingredient.new(ingredient_params)
|
||||
|
||||
respond_to do |format|
|
||||
if @ingredient.save
|
||||
format.html { redirect_to @ingredient, notice: 'Ingredient was successfully created.' }
|
||||
format.json { render :show, status: :created, location: @ingredient }
|
||||
else
|
||||
format.html { render :new }
|
||||
format.json { render json: @ingredient.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# PATCH/PUT /ingredients/1
|
||||
# PATCH/PUT /ingredients/1.json
|
||||
def update
|
||||
respond_to do |format|
|
||||
if @ingredient.update(ingredient_params)
|
||||
format.html { redirect_to @ingredient, notice: 'Ingredient was successfully updated.' }
|
||||
format.json { render :show, status: :ok, location: @ingredient }
|
||||
else
|
||||
format.html { render :edit }
|
||||
format.json { render json: @ingredient.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# DELETE /ingredients/1
|
||||
# DELETE /ingredients/1.json
|
||||
def destroy
|
||||
@ingredient.destroy
|
||||
respond_to do |format|
|
||||
format.html { redirect_to ingredients_url, notice: 'Ingredient was successfully destroyed.' }
|
||||
format.json { head :no_content }
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
def set_ingredient
|
||||
@ingredient = Ingredient.find(params[:id])
|
||||
end
|
||||
|
||||
# Never trust parameters from the scary internet, only allow the white list through.
|
||||
def ingredient_params
|
||||
params.require(:ingredient).permit(:name, :density, :notes)
|
||||
end
|
||||
end
|
74
app/controllers/recipes_controller.rb
Normal file
74
app/controllers/recipes_controller.rb
Normal file
@ -0,0 +1,74 @@
|
||||
class RecipesController < ApplicationController
|
||||
before_action :set_recipe, only: [:show, :edit, :update, :destroy]
|
||||
|
||||
# GET /recipes
|
||||
# GET /recipes.json
|
||||
def index
|
||||
@recipes = Recipe.all
|
||||
end
|
||||
|
||||
# GET /recipes/1
|
||||
# GET /recipes/1.json
|
||||
def show
|
||||
end
|
||||
|
||||
# GET /recipes/new
|
||||
def new
|
||||
@recipe = Recipe.new
|
||||
end
|
||||
|
||||
# GET /recipes/1/edit
|
||||
def edit
|
||||
end
|
||||
|
||||
# POST /recipes
|
||||
# POST /recipes.json
|
||||
def create
|
||||
@recipe = Recipe.new(recipe_params)
|
||||
|
||||
respond_to do |format|
|
||||
if @recipe.save
|
||||
format.html { redirect_to @recipe, notice: 'Recipe was successfully created.' }
|
||||
format.json { render :show, status: :created, location: @recipe }
|
||||
else
|
||||
format.html { render :new }
|
||||
format.json { render json: @recipe.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# PATCH/PUT /recipes/1
|
||||
# PATCH/PUT /recipes/1.json
|
||||
def update
|
||||
respond_to do |format|
|
||||
if @recipe.update(recipe_params)
|
||||
format.html { redirect_to @recipe, notice: 'Recipe was successfully updated.' }
|
||||
format.json { render :show, status: :ok, location: @recipe }
|
||||
else
|
||||
format.html { render :edit }
|
||||
format.json { render json: @recipe.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# DELETE /recipes/1
|
||||
# DELETE /recipes/1.json
|
||||
def destroy
|
||||
@recipe.destroy
|
||||
respond_to do |format|
|
||||
format.html { redirect_to recipes_url, notice: 'Recipe was successfully destroyed.' }
|
||||
format.json { head :no_content }
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
def set_recipe
|
||||
@recipe = Recipe.find(params[:id])
|
||||
end
|
||||
|
||||
# Never trust parameters from the scary internet, only allow the white list through.
|
||||
def recipe_params
|
||||
params[:recipe]
|
||||
end
|
||||
end
|
24
app/helpers/application_helper.rb
Normal file
24
app/helpers/application_helper.rb
Normal file
@ -0,0 +1,24 @@
|
||||
module ApplicationHelper
|
||||
def nav_items
|
||||
[
|
||||
nav_item('Recipes', recipes_path, 'recipes'),
|
||||
nav_item('Ingredients', ingredients_path, 'ingredients')
|
||||
]
|
||||
end
|
||||
|
||||
def nav_item(name, url, controller)
|
||||
content_tag('li', link_to(name, url), class: active_for_controller(controller))
|
||||
end
|
||||
|
||||
def active_for_controller(controller)
|
||||
if current_controller == controller
|
||||
'active'
|
||||
else
|
||||
''
|
||||
end
|
||||
end
|
||||
|
||||
def current_controller
|
||||
params[:controller]
|
||||
end
|
||||
end
|
2
app/helpers/ingredients_helper.rb
Normal file
2
app/helpers/ingredients_helper.rb
Normal file
@ -0,0 +1,2 @@
|
||||
module IngredientsHelper
|
||||
end
|
2
app/helpers/recipes_helper.rb
Normal file
2
app/helpers/recipes_helper.rb
Normal file
@ -0,0 +1,2 @@
|
||||
module RecipesHelper
|
||||
end
|
0
app/mailers/.keep
Normal file
0
app/mailers/.keep
Normal file
0
app/models/.keep
Normal file
0
app/models/.keep
Normal file
0
app/models/concerns/.keep
Normal file
0
app/models/concerns/.keep
Normal file
2
app/models/ingredient.rb
Normal file
2
app/models/ingredient.rb
Normal file
@ -0,0 +1,2 @@
|
||||
class Ingredient < ActiveRecord::Base
|
||||
end
|
6
app/models/recipe.rb
Normal file
6
app/models/recipe.rb
Normal file
@ -0,0 +1,6 @@
|
||||
class Recipe < ActiveRecord::Base
|
||||
|
||||
has_many :recipe_ingredients
|
||||
has_many :recipe_steps
|
||||
|
||||
end
|
6
app/models/recipe_ingredient.rb
Normal file
6
app/models/recipe_ingredient.rb
Normal file
@ -0,0 +1,6 @@
|
||||
class RecipeIngredient < ActiveRecord::Base
|
||||
|
||||
belongs_to :ingredient
|
||||
belongs_to :recipe
|
||||
|
||||
end
|
2
app/models/recipe_step.rb
Normal file
2
app/models/recipe_step.rb
Normal file
@ -0,0 +1,2 @@
|
||||
class RecipeStep < ActiveRecord::Base
|
||||
end
|
26
app/views/ingredients/_form.html.erb
Normal file
26
app/views/ingredients/_form.html.erb
Normal file
@ -0,0 +1,26 @@
|
||||
|
||||
|
||||
<%= form_for(@ingredient) do |f| %>
|
||||
|
||||
<%= render partial: 'shared/error_list', locals: {model: @ingredient} %>
|
||||
|
||||
<div class="form-group">
|
||||
<%= f.label :name %>
|
||||
<%= f.text_field :name, class: 'form-control' %>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<%= f.label :density %>
|
||||
<%= f.text_field :density, class: 'form-control' %>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<%= f.label :notes %>
|
||||
<%= f.text_area :notes, class: 'form-control' %>
|
||||
</div>
|
||||
|
||||
<div class="actions">
|
||||
<%= f.submit class: 'btn btn-primary' %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
12
app/views/ingredients/edit.html.erb
Normal file
12
app/views/ingredients/edit.html.erb
Normal file
@ -0,0 +1,12 @@
|
||||
<div class="row">
|
||||
<div class="col-xs-12">
|
||||
|
||||
<h1>Editing Ingredient</h1>
|
||||
|
||||
<%= render 'form' %>
|
||||
|
||||
<%= link_to 'Show', @ingredient, class: 'btn btn-primary' %> |
|
||||
<%= link_to 'Back', ingredients_path, class: 'btn btn-primary' %>
|
||||
|
||||
</div>
|
||||
</div>
|
33
app/views/ingredients/index.html.erb
Normal file
33
app/views/ingredients/index.html.erb
Normal file
@ -0,0 +1,33 @@
|
||||
<div class="row">
|
||||
<div class="col-xs-12">
|
||||
<h1>Listing Ingredients</h1>
|
||||
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Density</th>
|
||||
<th colspan="3"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
<% @ingredients.each do |ingredient| %>
|
||||
<tr>
|
||||
<td><%= ingredient.name %></td>
|
||||
<td><%= ingredient.density %></td>
|
||||
<td><%= link_to 'Show', ingredient %></td>
|
||||
<td><%= link_to 'Edit', edit_ingredient_path(ingredient) %></td>
|
||||
<td><%= link_to 'Destroy', ingredient, method: :delete, data: { confirm: 'Are you sure?' } %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<br>
|
||||
|
||||
<%= link_to 'New Ingredient', new_ingredient_path, class: 'btn btn-primary' %>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
4
app/views/ingredients/index.json.jbuilder
Normal file
4
app/views/ingredients/index.json.jbuilder
Normal file
@ -0,0 +1,4 @@
|
||||
json.array!(@ingredients) do |ingredient|
|
||||
json.extract! ingredient, :id
|
||||
json.url ingredient_url(ingredient, format: :json)
|
||||
end
|
11
app/views/ingredients/new.html.erb
Normal file
11
app/views/ingredients/new.html.erb
Normal file
@ -0,0 +1,11 @@
|
||||
<div class="row">
|
||||
<div class="col-xs-12">
|
||||
|
||||
<h1>New Ingredient</h1>
|
||||
|
||||
<%= render 'form' %>
|
||||
|
||||
<%= link_to 'Back', ingredients_path, class: 'btn btn-primary' %>
|
||||
|
||||
</div>
|
||||
</div>
|
13
app/views/ingredients/show.html.erb
Normal file
13
app/views/ingredients/show.html.erb
Normal file
@ -0,0 +1,13 @@
|
||||
|
||||
<div class="row">
|
||||
<div class="col-xs-12">
|
||||
|
||||
<h3><%= @ingredient.name %></h3>
|
||||
|
||||
<p><%= @ingredient.notes %></p>
|
||||
|
||||
<%= link_to 'Edit', edit_ingredient_path(@ingredient), class: 'btn btn-default' %>
|
||||
<%= link_to 'Back', ingredients_path, class: 'btn btn-default' %>
|
||||
|
||||
</div>
|
||||
</div>
|
1
app/views/ingredients/show.json.jbuilder
Normal file
1
app/views/ingredients/show.json.jbuilder
Normal file
@ -0,0 +1 @@
|
||||
json.extract! @ingredient, :id, :created_at, :updated_at
|
22
app/views/layouts/_flash_messages.html.erb
Normal file
22
app/views/layouts/_flash_messages.html.erb
Normal file
@ -0,0 +1,22 @@
|
||||
<div id="flashContainer"></div>
|
||||
|
||||
<% unless flash.empty? %>
|
||||
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
<%=
|
||||
calls = []
|
||||
flash.each do |key, value|
|
||||
if value.respond_to? 'each'
|
||||
value.each { |sub_value| calls << "flashMessage('#{j(key.to_s)}', '#{j(sub_value.to_s)}');" }
|
||||
else
|
||||
calls << "flashMessage('#{j(key.to_s)}', '#{j(value.to_s)}');"
|
||||
end
|
||||
end
|
||||
|
||||
raw(calls.join('\n'))
|
||||
%>
|
||||
});
|
||||
</script>
|
||||
|
||||
<% end %>
|
51
app/views/layouts/application.html.erb
Normal file
51
app/views/layouts/application.html.erb
Normal file
@ -0,0 +1,51 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Cookbook</title>
|
||||
|
||||
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
|
||||
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
|
||||
<%= csrf_meta_tags %>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<nav class="navbar navbar-inverse">
|
||||
<div class="container">
|
||||
<div class="navbar-header">
|
||||
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
|
||||
<span class="sr-only">Toggle navigation</span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</button>
|
||||
<a class="navbar-brand" href="/">Cookbook</a>
|
||||
</div>
|
||||
<div id="navbar" class="collapse navbar-collapse">
|
||||
<ul class="nav navbar-nav">
|
||||
<% nav_items.each do |li| %>
|
||||
<%= li %>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div><!--/.nav-collapse -->
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<%= render partial: 'layouts/flash_messages' %>
|
||||
|
||||
<div class="container">
|
||||
|
||||
<%= yield %>
|
||||
|
||||
</div><!-- /.container -->
|
||||
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<p class="text-muted">(c) Dan Elbert 2016</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
</body>
|
||||
</html>
|
24
app/views/recipes/_form.html.erb
Normal file
24
app/views/recipes/_form.html.erb
Normal file
@ -0,0 +1,24 @@
|
||||
<%= form_for(@recipe) do |f| %>
|
||||
|
||||
<%= render partial: 'shared/error_list', locals: {model: @recipe} %>
|
||||
|
||||
<h3>Ingredients</h3>
|
||||
<% @recipe.recipe_ingredients.each do |ri| %>
|
||||
|
||||
<%= render partial: 'recipes/editor/ingredient', locals: { recipe_ingredient: ri } %>
|
||||
|
||||
<% end %>
|
||||
|
||||
<button id="add_recipe_button" type="button" class="btn btn-primary">Add Ingredient</button>
|
||||
|
||||
<h3>Steps</h3>
|
||||
<% @recipe.recipe_steps.each do |rs| %>
|
||||
|
||||
<%= render partial: 'recipes/editor/step', locals: { recipe_step: rs } %>
|
||||
|
||||
<% end %>
|
||||
|
||||
<div class="actions">
|
||||
<%= f.submit class: 'btn btn-primary' %>
|
||||
</div>
|
||||
<% end %>
|
12
app/views/recipes/edit.html.erb
Normal file
12
app/views/recipes/edit.html.erb
Normal file
@ -0,0 +1,12 @@
|
||||
<div class="row">
|
||||
<div class="col-xs-12">
|
||||
|
||||
<h1>Editing Recipe</h1>
|
||||
|
||||
<%= render 'form' %>
|
||||
|
||||
<%= link_to 'Show', @recipe, class: 'btn btn-primary' %> |
|
||||
<%= link_to 'Back', recipes_path, class: 'btn btn-primary' %>
|
||||
|
||||
</div>
|
||||
</div>
|
0
app/views/recipes/editor/_ingredient.html.erb
Normal file
0
app/views/recipes/editor/_ingredient.html.erb
Normal file
0
app/views/recipes/editor/_step.html.erb
Normal file
0
app/views/recipes/editor/_step.html.erb
Normal file
47
app/views/recipes/index.html.erb
Normal file
47
app/views/recipes/index.html.erb
Normal file
@ -0,0 +1,47 @@
|
||||
<div class="row">
|
||||
<div class="col-xs-12">
|
||||
|
||||
<h1>Listing Recipes</h1>
|
||||
|
||||
<% if @recipes.empty? %>
|
||||
<p>No Recipes</p>
|
||||
<% else %>
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Yields</th>
|
||||
<th>Total Time</th>
|
||||
<th>Active Time</th>
|
||||
<th>Created</th>
|
||||
<th>Modified</th>
|
||||
<th colspan="3"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
<% @recipes.each do |recipe| %>
|
||||
<tr>
|
||||
<td><%= recipe.name %></td>
|
||||
<td><%= recipe.yields %></td>
|
||||
<td><%= recipe.total_time %></td>
|
||||
<td><%= recipe.active_time %></td>
|
||||
<td><%= recipe.created_at %></td>
|
||||
<td><%= recipe.updated_at %></td>
|
||||
<td><%= link_to 'Show', recipe %></td>
|
||||
<td><%= link_to 'Edit', edit_recipe_path(recipe) %></td>
|
||||
<td><%= link_to 'Destroy', recipe, method: :delete, data: { confirm: 'Are you sure?' } %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<% end %>
|
||||
|
||||
<br>
|
||||
|
||||
<%= link_to 'New Recipe', new_recipe_path, class: 'btn btn-default' %>
|
||||
|
||||
</div>
|
||||
</div>
|
4
app/views/recipes/index.json.jbuilder
Normal file
4
app/views/recipes/index.json.jbuilder
Normal file
@ -0,0 +1,4 @@
|
||||
json.array!(@recipes) do |recipe|
|
||||
json.extract! recipe, :id
|
||||
json.url recipe_url(recipe, format: :json)
|
||||
end
|
11
app/views/recipes/new.html.erb
Normal file
11
app/views/recipes/new.html.erb
Normal file
@ -0,0 +1,11 @@
|
||||
<div class="row">
|
||||
<div class="col-xs-12">
|
||||
|
||||
<h1>New Recipe</h1>
|
||||
|
||||
<%= render 'form' %>
|
||||
|
||||
<%= link_to 'Back', recipes_path, class: 'btn btn-default' %>
|
||||
|
||||
</div>
|
||||
</div>
|
8
app/views/recipes/show.html.erb
Normal file
8
app/views/recipes/show.html.erb
Normal file
@ -0,0 +1,8 @@
|
||||
<div class="row">
|
||||
<div class="col-xs-12">
|
||||
|
||||
<%= link_to 'Edit', edit_recipe_path(@recipe) %> |
|
||||
<%= link_to 'Back', recipes_path %>
|
||||
|
||||
</div>
|
||||
</div>
|
1
app/views/recipes/show.json.jbuilder
Normal file
1
app/views/recipes/show.json.jbuilder
Normal file
@ -0,0 +1 @@
|
||||
json.extract! @recipe, :id, :created_at, :updated_at
|
11
app/views/shared/_error_list.html.erb
Normal file
11
app/views/shared/_error_list.html.erb
Normal file
@ -0,0 +1,11 @@
|
||||
<% if model.errors.any? %>
|
||||
<div id="error_explanation" class="alert alert-danger">
|
||||
<h4><%= pluralize(model.errors.count, 'error') %> prohibited this <%= model.class.model_name.human %> from being saved:</h4>
|
||||
|
||||
<ul>
|
||||
<% model.errors.full_messages.each do |msg| %>
|
||||
<li><%= msg %></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
<% end %>
|
3
bin/bundle
Executable file
3
bin/bundle
Executable file
@ -0,0 +1,3 @@
|
||||
#!/usr/bin/env ruby
|
||||
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
|
||||
load Gem.bin_path('bundler', 'bundle')
|
4
bin/rails
Executable file
4
bin/rails
Executable file
@ -0,0 +1,4 @@
|
||||
#!/usr/bin/env ruby
|
||||
APP_PATH = File.expand_path('../../config/application', __FILE__)
|
||||
require_relative '../config/boot'
|
||||
require 'rails/commands'
|
4
bin/rake
Executable file
4
bin/rake
Executable file
@ -0,0 +1,4 @@
|
||||
#!/usr/bin/env ruby
|
||||
require_relative '../config/boot'
|
||||
require 'rake'
|
||||
Rake.application.run
|
29
bin/setup
Executable file
29
bin/setup
Executable file
@ -0,0 +1,29 @@
|
||||
#!/usr/bin/env ruby
|
||||
require 'pathname'
|
||||
|
||||
# path to your application root.
|
||||
APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
|
||||
|
||||
Dir.chdir APP_ROOT do
|
||||
# This script is a starting point to setup your application.
|
||||
# Add necessary setup steps to this file:
|
||||
|
||||
puts "== Installing dependencies =="
|
||||
system "gem install bundler --conservative"
|
||||
system "bundle check || bundle install"
|
||||
|
||||
# puts "\n== Copying sample files =="
|
||||
# unless File.exist?("config/database.yml")
|
||||
# system "cp config/database.yml.sample config/database.yml"
|
||||
# end
|
||||
|
||||
puts "\n== Preparing database =="
|
||||
system "bin/rake db:setup"
|
||||
|
||||
puts "\n== Removing old logs and tempfiles =="
|
||||
system "rm -f log/*"
|
||||
system "rm -rf tmp/cache"
|
||||
|
||||
puts "\n== Restarting application server =="
|
||||
system "touch tmp/restart.txt"
|
||||
end
|
4
config.ru
Normal file
4
config.ru
Normal file
@ -0,0 +1,4 @@
|
||||
# This file is used by Rack-based servers to start the application.
|
||||
|
||||
require ::File.expand_path('../config/environment', __FILE__)
|
||||
run Rails.application
|
26
config/application.rb
Normal file
26
config/application.rb
Normal file
@ -0,0 +1,26 @@
|
||||
require File.expand_path('../boot', __FILE__)
|
||||
|
||||
require 'rails/all'
|
||||
|
||||
# Require the gems listed in Gemfile, including any gems
|
||||
# you've limited to :test, :development, or :production.
|
||||
Bundler.require(*Rails.groups)
|
||||
|
||||
module Cookbook
|
||||
class Application < Rails::Application
|
||||
# Settings in config/environments/* take precedence over those specified here.
|
||||
# Application configuration should go into files in config/initializers
|
||||
# -- all .rb files in that directory are automatically loaded.
|
||||
|
||||
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
|
||||
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
|
||||
# config.time_zone = 'Central Time (US & Canada)'
|
||||
|
||||
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
||||
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
|
||||
# config.i18n.default_locale = :de
|
||||
|
||||
# Do not swallow errors in after_commit/after_rollback callbacks.
|
||||
config.active_record.raise_in_transactional_callbacks = true
|
||||
end
|
||||
end
|
3
config/boot.rb
Normal file
3
config/boot.rb
Normal file
@ -0,0 +1,3 @@
|
||||
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
|
||||
|
||||
require 'bundler/setup' # Set up gems listed in the Gemfile.
|
25
config/database.yml
Normal file
25
config/database.yml
Normal file
@ -0,0 +1,25 @@
|
||||
# SQLite version 3.x
|
||||
# gem install sqlite3
|
||||
#
|
||||
# Ensure the SQLite 3 gem is defined in your Gemfile
|
||||
# gem 'sqlite3'
|
||||
#
|
||||
default: &default
|
||||
adapter: sqlite3
|
||||
pool: 5
|
||||
timeout: 5000
|
||||
|
||||
development:
|
||||
<<: *default
|
||||
database: db/development.sqlite3
|
||||
|
||||
# Warning: The database defined as "test" will be erased and
|
||||
# re-generated from your development database when you run "rake".
|
||||
# Do not set this db to the same as development or production.
|
||||
test:
|
||||
<<: *default
|
||||
database: db/test.sqlite3
|
||||
|
||||
production:
|
||||
<<: *default
|
||||
database: db/production.sqlite3
|
5
config/environment.rb
Normal file
5
config/environment.rb
Normal file
@ -0,0 +1,5 @@
|
||||
# Load the Rails application.
|
||||
require File.expand_path('../application', __FILE__)
|
||||
|
||||
# Initialize the Rails application.
|
||||
Rails.application.initialize!
|
41
config/environments/development.rb
Normal file
41
config/environments/development.rb
Normal file
@ -0,0 +1,41 @@
|
||||
Rails.application.configure do
|
||||
# Settings specified here will take precedence over those in config/application.rb.
|
||||
|
||||
# In the development environment your application's code is reloaded on
|
||||
# every request. This slows down response time but is perfect for development
|
||||
# since you don't have to restart the web server when you make code changes.
|
||||
config.cache_classes = false
|
||||
|
||||
# Do not eager load code on boot.
|
||||
config.eager_load = false
|
||||
|
||||
# Show full error reports and disable caching.
|
||||
config.consider_all_requests_local = true
|
||||
config.action_controller.perform_caching = false
|
||||
|
||||
# Don't care if the mailer can't send.
|
||||
config.action_mailer.raise_delivery_errors = false
|
||||
|
||||
# Print deprecation notices to the Rails logger.
|
||||
config.active_support.deprecation = :log
|
||||
|
||||
# Raise an error on page load if there are pending migrations.
|
||||
config.active_record.migration_error = :page_load
|
||||
|
||||
# Debug mode disables concatenation and preprocessing of assets.
|
||||
# This option may cause significant delays in view rendering with a large
|
||||
# number of complex assets.
|
||||
config.assets.debug = true
|
||||
|
||||
# Asset digests allow you to set far-future HTTP expiration dates on all assets,
|
||||
# yet still be able to expire them through the digest params.
|
||||
config.assets.digest = true
|
||||
|
||||
# Adds additional error checking when serving assets at runtime.
|
||||
# Checks for improperly declared sprockets dependencies.
|
||||
# Raises helpful error messages.
|
||||
config.assets.raise_runtime_errors = true
|
||||
|
||||
# Raises error for missing translations
|
||||
# config.action_view.raise_on_missing_translations = true
|
||||
end
|
79
config/environments/production.rb
Normal file
79
config/environments/production.rb
Normal file
@ -0,0 +1,79 @@
|
||||
Rails.application.configure do
|
||||
# Settings specified here will take precedence over those in config/application.rb.
|
||||
|
||||
# Code is not reloaded between requests.
|
||||
config.cache_classes = true
|
||||
|
||||
# Eager load code on boot. This eager loads most of Rails and
|
||||
# your application in memory, allowing both threaded web servers
|
||||
# and those relying on copy on write to perform better.
|
||||
# Rake tasks automatically ignore this option for performance.
|
||||
config.eager_load = true
|
||||
|
||||
# Full error reports are disabled and caching is turned on.
|
||||
config.consider_all_requests_local = false
|
||||
config.action_controller.perform_caching = true
|
||||
|
||||
# Enable Rack::Cache to put a simple HTTP cache in front of your application
|
||||
# Add `rack-cache` to your Gemfile before enabling this.
|
||||
# For large-scale production use, consider using a caching reverse proxy like
|
||||
# NGINX, varnish or squid.
|
||||
# config.action_dispatch.rack_cache = true
|
||||
|
||||
# Disable serving static files from the `/public` folder by default since
|
||||
# Apache or NGINX already handles this.
|
||||
config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present?
|
||||
|
||||
# Compress JavaScripts and CSS.
|
||||
config.assets.js_compressor = :uglifier
|
||||
# config.assets.css_compressor = :sass
|
||||
|
||||
# Do not fallback to assets pipeline if a precompiled asset is missed.
|
||||
config.assets.compile = false
|
||||
|
||||
# Asset digests allow you to set far-future HTTP expiration dates on all assets,
|
||||
# yet still be able to expire them through the digest params.
|
||||
config.assets.digest = true
|
||||
|
||||
# `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
|
||||
|
||||
# Specifies the header that your server uses for sending files.
|
||||
# config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
|
||||
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
|
||||
|
||||
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
|
||||
# config.force_ssl = true
|
||||
|
||||
# Use the lowest log level to ensure availability of diagnostic information
|
||||
# when problems arise.
|
||||
config.log_level = :debug
|
||||
|
||||
# Prepend all log lines with the following tags.
|
||||
# config.log_tags = [ :subdomain, :uuid ]
|
||||
|
||||
# Use a different logger for distributed setups.
|
||||
# config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
|
||||
|
||||
# Use a different cache store in production.
|
||||
# config.cache_store = :mem_cache_store
|
||||
|
||||
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
|
||||
# config.action_controller.asset_host = 'http://assets.example.com'
|
||||
|
||||
# Ignore bad email addresses and do not raise email delivery errors.
|
||||
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
|
||||
# config.action_mailer.raise_delivery_errors = false
|
||||
|
||||
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
|
||||
# the I18n.default_locale when a translation cannot be found).
|
||||
config.i18n.fallbacks = true
|
||||
|
||||
# Send deprecation notices to registered listeners.
|
||||
config.active_support.deprecation = :notify
|
||||
|
||||
# Use default logging formatter so that PID and timestamp are not suppressed.
|
||||
config.log_formatter = ::Logger::Formatter.new
|
||||
|
||||
# Do not dump schema after migrations.
|
||||
config.active_record.dump_schema_after_migration = false
|
||||
end
|
42
config/environments/test.rb
Normal file
42
config/environments/test.rb
Normal file
@ -0,0 +1,42 @@
|
||||
Rails.application.configure do
|
||||
# Settings specified here will take precedence over those in config/application.rb.
|
||||
|
||||
# The test environment is used exclusively to run your application's
|
||||
# test suite. You never need to work with it otherwise. Remember that
|
||||
# your test database is "scratch space" for the test suite and is wiped
|
||||
# and recreated between test runs. Don't rely on the data there!
|
||||
config.cache_classes = true
|
||||
|
||||
# Do not eager load code on boot. This avoids loading your whole application
|
||||
# just for the purpose of running a single test. If you are using a tool that
|
||||
# preloads Rails for running tests, you may have to set it to true.
|
||||
config.eager_load = false
|
||||
|
||||
# Configure static file server for tests with Cache-Control for performance.
|
||||
config.serve_static_files = true
|
||||
config.static_cache_control = 'public, max-age=3600'
|
||||
|
||||
# Show full error reports and disable caching.
|
||||
config.consider_all_requests_local = true
|
||||
config.action_controller.perform_caching = false
|
||||
|
||||
# Raise exceptions instead of rendering exception templates.
|
||||
config.action_dispatch.show_exceptions = false
|
||||
|
||||
# Disable request forgery protection in test environment.
|
||||
config.action_controller.allow_forgery_protection = false
|
||||
|
||||
# Tell Action Mailer not to deliver emails to the real world.
|
||||
# The :test delivery method accumulates sent emails in the
|
||||
# ActionMailer::Base.deliveries array.
|
||||
config.action_mailer.delivery_method = :test
|
||||
|
||||
# Randomize the order test cases are executed.
|
||||
config.active_support.test_order = :random
|
||||
|
||||
# Print deprecation notices to the stderr.
|
||||
config.active_support.deprecation = :stderr
|
||||
|
||||
# Raises error for missing translations
|
||||
# config.action_view.raise_on_missing_translations = true
|
||||
end
|
11
config/initializers/assets.rb
Normal file
11
config/initializers/assets.rb
Normal file
@ -0,0 +1,11 @@
|
||||
# Be sure to restart your server when you modify this file.
|
||||
|
||||
# Version of your assets, change this if you want to expire all your assets.
|
||||
Rails.application.config.assets.version = '1.0'
|
||||
|
||||
# Add additional assets to the asset load path
|
||||
# Rails.application.config.assets.paths << Emoji.images_path
|
||||
|
||||
# Precompile additional assets.
|
||||
# application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
|
||||
# Rails.application.config.assets.precompile += %w( search.js )
|
7
config/initializers/backtrace_silencers.rb
Normal file
7
config/initializers/backtrace_silencers.rb
Normal file
@ -0,0 +1,7 @@
|
||||
# Be sure to restart your server when you modify this file.
|
||||
|
||||
# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
|
||||
# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
|
||||
|
||||
# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
|
||||
# Rails.backtrace_cleaner.remove_silencers!
|
3
config/initializers/cookies_serializer.rb
Normal file
3
config/initializers/cookies_serializer.rb
Normal file
@ -0,0 +1,3 @@
|
||||
# Be sure to restart your server when you modify this file.
|
||||
|
||||
Rails.application.config.action_dispatch.cookies_serializer = :json
|
4
config/initializers/filter_parameter_logging.rb
Normal file
4
config/initializers/filter_parameter_logging.rb
Normal file
@ -0,0 +1,4 @@
|
||||
# Be sure to restart your server when you modify this file.
|
||||
|
||||
# Configure sensitive parameters which will be filtered from the log file.
|
||||
Rails.application.config.filter_parameters += [:password]
|
16
config/initializers/inflections.rb
Normal file
16
config/initializers/inflections.rb
Normal file
@ -0,0 +1,16 @@
|
||||
# Be sure to restart your server when you modify this file.
|
||||
|
||||
# Add new inflection rules using the following format. Inflections
|
||||
# are locale specific, and you may define rules for as many different
|
||||
# locales as you wish. All of these examples are active by default:
|
||||
# ActiveSupport::Inflector.inflections(:en) do |inflect|
|
||||
# inflect.plural /^(ox)$/i, '\1en'
|
||||
# inflect.singular /^(ox)en/i, '\1'
|
||||
# inflect.irregular 'person', 'people'
|
||||
# inflect.uncountable %w( fish sheep )
|
||||
# end
|
||||
|
||||
# These inflection rules are supported but not enabled by default:
|
||||
# ActiveSupport::Inflector.inflections(:en) do |inflect|
|
||||
# inflect.acronym 'RESTful'
|
||||
# end
|
4
config/initializers/mime_types.rb
Normal file
4
config/initializers/mime_types.rb
Normal file
@ -0,0 +1,4 @@
|
||||
# Be sure to restart your server when you modify this file.
|
||||
|
||||
# Add new mime types for use in respond_to blocks:
|
||||
# Mime::Type.register "text/richtext", :rtf
|
3
config/initializers/session_store.rb
Normal file
3
config/initializers/session_store.rb
Normal file
@ -0,0 +1,3 @@
|
||||
# Be sure to restart your server when you modify this file.
|
||||
|
||||
Rails.application.config.session_store :cookie_store, key: '_cookbook_session'
|
14
config/initializers/wrap_parameters.rb
Normal file
14
config/initializers/wrap_parameters.rb
Normal file
@ -0,0 +1,14 @@
|
||||
# Be sure to restart your server when you modify this file.
|
||||
|
||||
# This file contains settings for ActionController::ParamsWrapper which
|
||||
# is enabled by default.
|
||||
|
||||
# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
|
||||
ActiveSupport.on_load(:action_controller) do
|
||||
wrap_parameters format: [:json] if respond_to?(:wrap_parameters)
|
||||
end
|
||||
|
||||
# To enable root element in JSON for ActiveRecord objects.
|
||||
# ActiveSupport.on_load(:active_record) do
|
||||
# self.include_root_in_json = true
|
||||
# end
|
23
config/locales/en.yml
Normal file
23
config/locales/en.yml
Normal file
@ -0,0 +1,23 @@
|
||||
# Files in the config/locales directory are used for internationalization
|
||||
# and are automatically loaded by Rails. If you want to use locales other
|
||||
# than English, add the necessary files in this directory.
|
||||
#
|
||||
# To use the locales, use `I18n.t`:
|
||||
#
|
||||
# I18n.t 'hello'
|
||||
#
|
||||
# In views, this is aliased to just `t`:
|
||||
#
|
||||
# <%= t('hello') %>
|
||||
#
|
||||
# To use a different locale, set it with `I18n.locale`:
|
||||
#
|
||||
# I18n.locale = :es
|
||||
#
|
||||
# This would use the information in config/locales/es.yml.
|
||||
#
|
||||
# To learn more, please read the Rails Internationalization guide
|
||||
# available at http://guides.rubyonrails.org/i18n.html.
|
||||
|
||||
en:
|
||||
hello: "Hello world"
|
9
config/routes.rb
Normal file
9
config/routes.rb
Normal file
@ -0,0 +1,9 @@
|
||||
Rails.application.routes.draw do
|
||||
|
||||
resources :recipes
|
||||
resources :ingredients
|
||||
|
||||
root 'recipes#index'
|
||||
|
||||
|
||||
end
|
22
config/secrets.yml
Normal file
22
config/secrets.yml
Normal file
@ -0,0 +1,22 @@
|
||||
# Be sure to restart your server when you modify this file.
|
||||
|
||||
# Your secret key is used for verifying the integrity of signed cookies.
|
||||
# If you change this key, all old signed cookies will become invalid!
|
||||
|
||||
# Make sure the secret is at least 30 characters and all random,
|
||||
# no regular words or you'll be exposed to dictionary attacks.
|
||||
# You can use `rake secret` to generate a secure secret key.
|
||||
|
||||
# Make sure the secrets in this file are kept private
|
||||
# if you're sharing your code publicly.
|
||||
|
||||
development:
|
||||
secret_key_base: c5522f51520c361b0848e80a52f6b5ce2259285fd1de3db94869460aa636c49a62217995dec4047eb0f037a16246cbf2b6b62f3a88f8f5cc2f0f6837b372d3b3
|
||||
|
||||
test:
|
||||
secret_key_base: 1cf4b0a7e92c645ce88bc6909fa66ad706a7b4d8dcfc6c80a472b309cb1c745dead17d3c633ae971da164b7b82555a8f33033229f598b72a35b74ae199cc93e0
|
||||
|
||||
# Do not keep production secrets in the repository,
|
||||
# instead read values from the environment.
|
||||
production:
|
||||
secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
|
12
db/migrate/20160112214203_create_ingredients.rb
Normal file
12
db/migrate/20160112214203_create_ingredients.rb
Normal file
@ -0,0 +1,12 @@
|
||||
class CreateIngredients < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :ingredients do |t|
|
||||
|
||||
t.string :name
|
||||
t.string :density
|
||||
t.text :notes
|
||||
|
||||
t.timestamps null: false
|
||||
end
|
||||
end
|
||||
end
|
14
db/migrate/20160112214213_create_recipes.rb
Normal file
14
db/migrate/20160112214213_create_recipes.rb
Normal file
@ -0,0 +1,14 @@
|
||||
class CreateRecipes < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :recipes do |t|
|
||||
|
||||
t.string :name
|
||||
t.text :source
|
||||
t.integer :yields
|
||||
t.integer :total_time
|
||||
t.integer :active_time
|
||||
|
||||
t.timestamps null: false
|
||||
end
|
||||
end
|
||||
end
|
17
db/migrate/20160112225805_create_recipe_ingredients.rb
Normal file
17
db/migrate/20160112225805_create_recipe_ingredients.rb
Normal file
@ -0,0 +1,17 @@
|
||||
class CreateRecipeIngredients < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :recipe_ingredients do |t|
|
||||
|
||||
t.integer :ingredient_id
|
||||
t.integer :recipe_id, index: true
|
||||
|
||||
t.string :custom_name
|
||||
t.string :custom_density
|
||||
|
||||
t.string :quantity
|
||||
t.string :units
|
||||
|
||||
t.timestamps null: false
|
||||
end
|
||||
end
|
||||
end
|
12
db/migrate/20160113002615_create_recipe_steps.rb
Normal file
12
db/migrate/20160113002615_create_recipe_steps.rb
Normal file
@ -0,0 +1,12 @@
|
||||
class CreateRecipeSteps < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :recipe_steps do |t|
|
||||
|
||||
t.integer :recipe_id, index: true
|
||||
t.integer :number
|
||||
t.text :step
|
||||
|
||||
t.timestamps null: false
|
||||
end
|
||||
end
|
||||
end
|
57
db/schema.rb
Normal file
57
db/schema.rb
Normal file
@ -0,0 +1,57 @@
|
||||
# encoding: UTF-8
|
||||
# This file is auto-generated from the current state of the database. Instead
|
||||
# of editing this file, please use the migrations feature of Active Record to
|
||||
# incrementally modify your database, and then regenerate this schema definition.
|
||||
#
|
||||
# Note that this schema.rb definition is the authoritative source for your
|
||||
# database schema. If you need to create the application database on another
|
||||
# system, you should be using db:schema:load, not running all the migrations
|
||||
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
|
||||
# you'll amass, the slower it'll run and the greater likelihood for issues).
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20160113002615) do
|
||||
|
||||
create_table "ingredients", force: :cascade do |t|
|
||||
t.string "name"
|
||||
t.string "density"
|
||||
t.text "notes"
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
end
|
||||
|
||||
create_table "recipe_ingredients", force: :cascade do |t|
|
||||
t.integer "ingredient_id"
|
||||
t.integer "recipe_id"
|
||||
t.string "custom_name"
|
||||
t.string "custom_density"
|
||||
t.string "quantity"
|
||||
t.string "units"
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
end
|
||||
|
||||
add_index "recipe_ingredients", ["recipe_id"], name: "index_recipe_ingredients_on_recipe_id"
|
||||
|
||||
create_table "recipe_steps", force: :cascade do |t|
|
||||
t.integer "recipe_id"
|
||||
t.integer "number"
|
||||
t.text "step"
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
end
|
||||
|
||||
add_index "recipe_steps", ["recipe_id"], name: "index_recipe_steps_on_recipe_id"
|
||||
|
||||
create_table "recipes", force: :cascade do |t|
|
||||
t.string "name"
|
||||
t.text "source"
|
||||
t.integer "yields"
|
||||
t.integer "total_time"
|
||||
t.integer "active_time"
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
end
|
||||
|
||||
end
|
7
db/seeds.rb
Normal file
7
db/seeds.rb
Normal file
@ -0,0 +1,7 @@
|
||||
# This file should contain all the record creation needed to seed the database with its default values.
|
||||
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
|
||||
#
|
||||
# Examples:
|
||||
#
|
||||
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
|
||||
# Mayor.create(name: 'Emanuel', city: cities.first)
|
0
lib/assets/.keep
Normal file
0
lib/assets/.keep
Normal file
0
lib/tasks/.keep
Normal file
0
lib/tasks/.keep
Normal file
67
public/404.html
Normal file
67
public/404.html
Normal file
@ -0,0 +1,67 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>The page you were looking for doesn't exist (404)</title>
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
<style>
|
||||
body {
|
||||
background-color: #EFEFEF;
|
||||
color: #2E2F30;
|
||||
text-align: center;
|
||||
font-family: arial, sans-serif;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
div.dialog {
|
||||
width: 95%;
|
||||
max-width: 33em;
|
||||
margin: 4em auto 0;
|
||||
}
|
||||
|
||||
div.dialog > div {
|
||||
border: 1px solid #CCC;
|
||||
border-right-color: #999;
|
||||
border-left-color: #999;
|
||||
border-bottom-color: #BBB;
|
||||
border-top: #B00100 solid 4px;
|
||||
border-top-left-radius: 9px;
|
||||
border-top-right-radius: 9px;
|
||||
background-color: white;
|
||||
padding: 7px 12% 0;
|
||||
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: 100%;
|
||||
color: #730E15;
|
||||
line-height: 1.5em;
|
||||
}
|
||||
|
||||
div.dialog > p {
|
||||
margin: 0 0 1em;
|
||||
padding: 1em;
|
||||
background-color: #F7F7F7;
|
||||
border: 1px solid #CCC;
|
||||
border-right-color: #999;
|
||||
border-left-color: #999;
|
||||
border-bottom-color: #999;
|
||||
border-bottom-left-radius: 4px;
|
||||
border-bottom-right-radius: 4px;
|
||||
border-top-color: #DADADA;
|
||||
color: #666;
|
||||
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<!-- This file lives in public/404.html -->
|
||||
<div class="dialog">
|
||||
<div>
|
||||
<h1>The page you were looking for doesn't exist.</h1>
|
||||
<p>You may have mistyped the address or the page may have moved.</p>
|
||||
</div>
|
||||
<p>If you are the application owner check the logs for more information.</p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
67
public/422.html
Normal file
67
public/422.html
Normal file
@ -0,0 +1,67 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>The change you wanted was rejected (422)</title>
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
<style>
|
||||
body {
|
||||
background-color: #EFEFEF;
|
||||
color: #2E2F30;
|
||||
text-align: center;
|
||||
font-family: arial, sans-serif;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
div.dialog {
|
||||
width: 95%;
|
||||
max-width: 33em;
|
||||
margin: 4em auto 0;
|
||||
}
|
||||
|
||||
div.dialog > div {
|
||||
border: 1px solid #CCC;
|
||||
border-right-color: #999;
|
||||
border-left-color: #999;
|
||||
border-bottom-color: #BBB;
|
||||
border-top: #B00100 solid 4px;
|
||||
border-top-left-radius: 9px;
|
||||
border-top-right-radius: 9px;
|
||||
background-color: white;
|
||||
padding: 7px 12% 0;
|
||||
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: 100%;
|
||||
color: #730E15;
|
||||
line-height: 1.5em;
|
||||
}
|
||||
|
||||
div.dialog > p {
|
||||
margin: 0 0 1em;
|
||||
padding: 1em;
|
||||
background-color: #F7F7F7;
|
||||
border: 1px solid #CCC;
|
||||
border-right-color: #999;
|
||||
border-left-color: #999;
|
||||
border-bottom-color: #999;
|
||||
border-bottom-left-radius: 4px;
|
||||
border-bottom-right-radius: 4px;
|
||||
border-top-color: #DADADA;
|
||||
color: #666;
|
||||
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<!-- This file lives in public/422.html -->
|
||||
<div class="dialog">
|
||||
<div>
|
||||
<h1>The change you wanted was rejected.</h1>
|
||||
<p>Maybe you tried to change something you didn't have access to.</p>
|
||||
</div>
|
||||
<p>If you are the application owner check the logs for more information.</p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
66
public/500.html
Normal file
66
public/500.html
Normal file
@ -0,0 +1,66 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>We're sorry, but something went wrong (500)</title>
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
<style>
|
||||
body {
|
||||
background-color: #EFEFEF;
|
||||
color: #2E2F30;
|
||||
text-align: center;
|
||||
font-family: arial, sans-serif;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
div.dialog {
|
||||
width: 95%;
|
||||
max-width: 33em;
|
||||
margin: 4em auto 0;
|
||||
}
|
||||
|
||||
div.dialog > div {
|
||||
border: 1px solid #CCC;
|
||||
border-right-color: #999;
|
||||
border-left-color: #999;
|
||||
border-bottom-color: #BBB;
|
||||
border-top: #B00100 solid 4px;
|
||||
border-top-left-radius: 9px;
|
||||
border-top-right-radius: 9px;
|
||||
background-color: white;
|
||||
padding: 7px 12% 0;
|
||||
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: 100%;
|
||||
color: #730E15;
|
||||
line-height: 1.5em;
|
||||
}
|
||||
|
||||
div.dialog > p {
|
||||
margin: 0 0 1em;
|
||||
padding: 1em;
|
||||
background-color: #F7F7F7;
|
||||
border: 1px solid #CCC;
|
||||
border-right-color: #999;
|
||||
border-left-color: #999;
|
||||
border-bottom-color: #999;
|
||||
border-bottom-left-radius: 4px;
|
||||
border-bottom-right-radius: 4px;
|
||||
border-top-color: #DADADA;
|
||||
color: #666;
|
||||
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<!-- This file lives in public/500.html -->
|
||||
<div class="dialog">
|
||||
<div>
|
||||
<h1>We're sorry, but something went wrong.</h1>
|
||||
</div>
|
||||
<p>If you are the application owner check the logs for more information.</p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
0
public/favicon.ico
Normal file
0
public/favicon.ico
Normal file
5
public/robots.txt
Normal file
5
public/robots.txt
Normal file
@ -0,0 +1,5 @@
|
||||
# See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file
|
||||
#
|
||||
# To ban all spiders from the entire site uncomment the next two lines:
|
||||
# User-agent: *
|
||||
# Disallow: /
|
0
spec/controllers/.keep
Normal file
0
spec/controllers/.keep
Normal file
159
spec/controllers/ingredients_controller_spec.rb
Normal file
159
spec/controllers/ingredients_controller_spec.rb
Normal file
@ -0,0 +1,159 @@
|
||||
require 'rails_helper'
|
||||
|
||||
# This spec was generated by rspec-rails when you ran the scaffold generator.
|
||||
# It demonstrates how one might use RSpec to specify the controller code that
|
||||
# was generated by Rails when you ran the scaffold generator.
|
||||
#
|
||||
# It assumes that the implementation code is generated by the rails scaffold
|
||||
# generator. If you are using any extension libraries to generate different
|
||||
# controller code, this generated spec may or may not pass.
|
||||
#
|
||||
# It only uses APIs available in rails and/or rspec-rails. There are a number
|
||||
# of tools you can use to make these specs even more expressive, but we're
|
||||
# sticking to rails and rspec-rails APIs to keep things simple and stable.
|
||||
#
|
||||
# Compared to earlier versions of this generator, there is very limited use of
|
||||
# stubs and message expectations in this spec. Stubs are only used when there
|
||||
# is no simpler way to get a handle on the object needed for the example.
|
||||
# Message expectations are only used when there is no simpler way to specify
|
||||
# that an instance is receiving a specific message.
|
||||
|
||||
RSpec.describe IngredientsController, type: :controller do
|
||||
|
||||
# This should return the minimal set of attributes required to create a valid
|
||||
# Ingredient. As you add validations to Ingredient, be sure to
|
||||
# adjust the attributes here as well.
|
||||
let(:valid_attributes) {
|
||||
skip("Add a hash of attributes valid for your model")
|
||||
}
|
||||
|
||||
let(:invalid_attributes) {
|
||||
skip("Add a hash of attributes invalid for your model")
|
||||
}
|
||||
|
||||
# This should return the minimal set of values that should be in the session
|
||||
# in order to pass any filters (e.g. authentication) defined in
|
||||
# IngredientsController. Be sure to keep this updated too.
|
||||
let(:valid_session) { {} }
|
||||
|
||||
describe "GET #index" do
|
||||
it "assigns all ingredients as @ingredients" do
|
||||
ingredient = Ingredient.create! valid_attributes
|
||||
get :index, {}, valid_session
|
||||
expect(assigns(:ingredients)).to eq([ingredient])
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET #show" do
|
||||
it "assigns the requested ingredient as @ingredient" do
|
||||
ingredient = Ingredient.create! valid_attributes
|
||||
get :show, {:id => ingredient.to_param}, valid_session
|
||||
expect(assigns(:ingredient)).to eq(ingredient)
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET #new" do
|
||||
it "assigns a new ingredient as @ingredient" do
|
||||
get :new, {}, valid_session
|
||||
expect(assigns(:ingredient)).to be_a_new(Ingredient)
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET #edit" do
|
||||
it "assigns the requested ingredient as @ingredient" do
|
||||
ingredient = Ingredient.create! valid_attributes
|
||||
get :edit, {:id => ingredient.to_param}, valid_session
|
||||
expect(assigns(:ingredient)).to eq(ingredient)
|
||||
end
|
||||
end
|
||||
|
||||
describe "POST #create" do
|
||||
context "with valid params" do
|
||||
it "creates a new Ingredient" do
|
||||
expect {
|
||||
post :create, {:ingredient => valid_attributes}, valid_session
|
||||
}.to change(Ingredient, :count).by(1)
|
||||
end
|
||||
|
||||
it "assigns a newly created ingredient as @ingredient" do
|
||||
post :create, {:ingredient => valid_attributes}, valid_session
|
||||
expect(assigns(:ingredient)).to be_a(Ingredient)
|
||||
expect(assigns(:ingredient)).to be_persisted
|
||||
end
|
||||
|
||||
it "redirects to the created ingredient" do
|
||||
post :create, {:ingredient => valid_attributes}, valid_session
|
||||
expect(response).to redirect_to(Ingredient.last)
|
||||
end
|
||||
end
|
||||
|
||||
context "with invalid params" do
|
||||
it "assigns a newly created but unsaved ingredient as @ingredient" do
|
||||
post :create, {:ingredient => invalid_attributes}, valid_session
|
||||
expect(assigns(:ingredient)).to be_a_new(Ingredient)
|
||||
end
|
||||
|
||||
it "re-renders the 'new' template" do
|
||||
post :create, {:ingredient => invalid_attributes}, valid_session
|
||||
expect(response).to render_template("new")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "PUT #update" do
|
||||
context "with valid params" do
|
||||
let(:new_attributes) {
|
||||
skip("Add a hash of attributes valid for your model")
|
||||
}
|
||||
|
||||
it "updates the requested ingredient" do
|
||||
ingredient = Ingredient.create! valid_attributes
|
||||
put :update, {:id => ingredient.to_param, :ingredient => new_attributes}, valid_session
|
||||
ingredient.reload
|
||||
skip("Add assertions for updated state")
|
||||
end
|
||||
|
||||
it "assigns the requested ingredient as @ingredient" do
|
||||
ingredient = Ingredient.create! valid_attributes
|
||||
put :update, {:id => ingredient.to_param, :ingredient => valid_attributes}, valid_session
|
||||
expect(assigns(:ingredient)).to eq(ingredient)
|
||||
end
|
||||
|
||||
it "redirects to the ingredient" do
|
||||
ingredient = Ingredient.create! valid_attributes
|
||||
put :update, {:id => ingredient.to_param, :ingredient => valid_attributes}, valid_session
|
||||
expect(response).to redirect_to(ingredient)
|
||||
end
|
||||
end
|
||||
|
||||
context "with invalid params" do
|
||||
it "assigns the ingredient as @ingredient" do
|
||||
ingredient = Ingredient.create! valid_attributes
|
||||
put :update, {:id => ingredient.to_param, :ingredient => invalid_attributes}, valid_session
|
||||
expect(assigns(:ingredient)).to eq(ingredient)
|
||||
end
|
||||
|
||||
it "re-renders the 'edit' template" do
|
||||
ingredient = Ingredient.create! valid_attributes
|
||||
put :update, {:id => ingredient.to_param, :ingredient => invalid_attributes}, valid_session
|
||||
expect(response).to render_template("edit")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "DELETE #destroy" do
|
||||
it "destroys the requested ingredient" do
|
||||
ingredient = Ingredient.create! valid_attributes
|
||||
expect {
|
||||
delete :destroy, {:id => ingredient.to_param}, valid_session
|
||||
}.to change(Ingredient, :count).by(-1)
|
||||
end
|
||||
|
||||
it "redirects to the ingredients list" do
|
||||
ingredient = Ingredient.create! valid_attributes
|
||||
delete :destroy, {:id => ingredient.to_param}, valid_session
|
||||
expect(response).to redirect_to(ingredients_url)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
159
spec/controllers/recipes_controller_spec.rb
Normal file
159
spec/controllers/recipes_controller_spec.rb
Normal file
@ -0,0 +1,159 @@
|
||||
require 'rails_helper'
|
||||
|
||||
# This spec was generated by rspec-rails when you ran the scaffold generator.
|
||||
# It demonstrates how one might use RSpec to specify the controller code that
|
||||
# was generated by Rails when you ran the scaffold generator.
|
||||
#
|
||||
# It assumes that the implementation code is generated by the rails scaffold
|
||||
# generator. If you are using any extension libraries to generate different
|
||||
# controller code, this generated spec may or may not pass.
|
||||
#
|
||||
# It only uses APIs available in rails and/or rspec-rails. There are a number
|
||||
# of tools you can use to make these specs even more expressive, but we're
|
||||
# sticking to rails and rspec-rails APIs to keep things simple and stable.
|
||||
#
|
||||
# Compared to earlier versions of this generator, there is very limited use of
|
||||
# stubs and message expectations in this spec. Stubs are only used when there
|
||||
# is no simpler way to get a handle on the object needed for the example.
|
||||
# Message expectations are only used when there is no simpler way to specify
|
||||
# that an instance is receiving a specific message.
|
||||
|
||||
RSpec.describe RecipesController, type: :controller do
|
||||
|
||||
# This should return the minimal set of attributes required to create a valid
|
||||
# Recipe. As you add validations to Recipe, be sure to
|
||||
# adjust the attributes here as well.
|
||||
let(:valid_attributes) {
|
||||
skip("Add a hash of attributes valid for your model")
|
||||
}
|
||||
|
||||
let(:invalid_attributes) {
|
||||
skip("Add a hash of attributes invalid for your model")
|
||||
}
|
||||
|
||||
# This should return the minimal set of values that should be in the session
|
||||
# in order to pass any filters (e.g. authentication) defined in
|
||||
# RecipesController. Be sure to keep this updated too.
|
||||
let(:valid_session) { {} }
|
||||
|
||||
describe "GET #index" do
|
||||
it "assigns all recipes as @recipes" do
|
||||
recipe = Recipe.create! valid_attributes
|
||||
get :index, {}, valid_session
|
||||
expect(assigns(:recipes)).to eq([recipe])
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET #show" do
|
||||
it "assigns the requested recipe as @recipe" do
|
||||
recipe = Recipe.create! valid_attributes
|
||||
get :show, {:id => recipe.to_param}, valid_session
|
||||
expect(assigns(:recipe)).to eq(recipe)
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET #new" do
|
||||
it "assigns a new recipe as @recipe" do
|
||||
get :new, {}, valid_session
|
||||
expect(assigns(:recipe)).to be_a_new(Recipe)
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET #edit" do
|
||||
it "assigns the requested recipe as @recipe" do
|
||||
recipe = Recipe.create! valid_attributes
|
||||
get :edit, {:id => recipe.to_param}, valid_session
|
||||
expect(assigns(:recipe)).to eq(recipe)
|
||||
end
|
||||
end
|
||||
|
||||
describe "POST #create" do
|
||||
context "with valid params" do
|
||||
it "creates a new Recipe" do
|
||||
expect {
|
||||
post :create, {:recipe => valid_attributes}, valid_session
|
||||
}.to change(Recipe, :count).by(1)
|
||||
end
|
||||
|
||||
it "assigns a newly created recipe as @recipe" do
|
||||
post :create, {:recipe => valid_attributes}, valid_session
|
||||
expect(assigns(:recipe)).to be_a(Recipe)
|
||||
expect(assigns(:recipe)).to be_persisted
|
||||
end
|
||||
|
||||
it "redirects to the created recipe" do
|
||||
post :create, {:recipe => valid_attributes}, valid_session
|
||||
expect(response).to redirect_to(Recipe.last)
|
||||
end
|
||||
end
|
||||
|
||||
context "with invalid params" do
|
||||
it "assigns a newly created but unsaved recipe as @recipe" do
|
||||
post :create, {:recipe => invalid_attributes}, valid_session
|
||||
expect(assigns(:recipe)).to be_a_new(Recipe)
|
||||
end
|
||||
|
||||
it "re-renders the 'new' template" do
|
||||
post :create, {:recipe => invalid_attributes}, valid_session
|
||||
expect(response).to render_template("new")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "PUT #update" do
|
||||
context "with valid params" do
|
||||
let(:new_attributes) {
|
||||
skip("Add a hash of attributes valid for your model")
|
||||
}
|
||||
|
||||
it "updates the requested recipe" do
|
||||
recipe = Recipe.create! valid_attributes
|
||||
put :update, {:id => recipe.to_param, :recipe => new_attributes}, valid_session
|
||||
recipe.reload
|
||||
skip("Add assertions for updated state")
|
||||
end
|
||||
|
||||
it "assigns the requested recipe as @recipe" do
|
||||
recipe = Recipe.create! valid_attributes
|
||||
put :update, {:id => recipe.to_param, :recipe => valid_attributes}, valid_session
|
||||
expect(assigns(:recipe)).to eq(recipe)
|
||||
end
|
||||
|
||||
it "redirects to the recipe" do
|
||||
recipe = Recipe.create! valid_attributes
|
||||
put :update, {:id => recipe.to_param, :recipe => valid_attributes}, valid_session
|
||||
expect(response).to redirect_to(recipe)
|
||||
end
|
||||
end
|
||||
|
||||
context "with invalid params" do
|
||||
it "assigns the recipe as @recipe" do
|
||||
recipe = Recipe.create! valid_attributes
|
||||
put :update, {:id => recipe.to_param, :recipe => invalid_attributes}, valid_session
|
||||
expect(assigns(:recipe)).to eq(recipe)
|
||||
end
|
||||
|
||||
it "re-renders the 'edit' template" do
|
||||
recipe = Recipe.create! valid_attributes
|
||||
put :update, {:id => recipe.to_param, :recipe => invalid_attributes}, valid_session
|
||||
expect(response).to render_template("edit")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "DELETE #destroy" do
|
||||
it "destroys the requested recipe" do
|
||||
recipe = Recipe.create! valid_attributes
|
||||
expect {
|
||||
delete :destroy, {:id => recipe.to_param}, valid_session
|
||||
}.to change(Recipe, :count).by(-1)
|
||||
end
|
||||
|
||||
it "redirects to the recipes list" do
|
||||
recipe = Recipe.create! valid_attributes
|
||||
delete :destroy, {:id => recipe.to_param}, valid_session
|
||||
expect(response).to redirect_to(recipes_url)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
6
spec/factories/ingredients.rb
Normal file
6
spec/factories/ingredients.rb
Normal file
@ -0,0 +1,6 @@
|
||||
FactoryGirl.define do
|
||||
factory :ingredient do
|
||||
|
||||
end
|
||||
|
||||
end
|
6
spec/factories/recipe_ingredients.rb
Normal file
6
spec/factories/recipe_ingredients.rb
Normal file
@ -0,0 +1,6 @@
|
||||
FactoryGirl.define do
|
||||
factory :recipe_ingredient do
|
||||
|
||||
end
|
||||
|
||||
end
|
7
spec/factories/recipe_steps.rb
Normal file
7
spec/factories/recipe_steps.rb
Normal file
@ -0,0 +1,7 @@
|
||||
FactoryGirl.define do
|
||||
factory :recipe_step do
|
||||
number 1
|
||||
step "MyText"
|
||||
end
|
||||
|
||||
end
|
6
spec/factories/recipes.rb
Normal file
6
spec/factories/recipes.rb
Normal file
@ -0,0 +1,6 @@
|
||||
FactoryGirl.define do
|
||||
factory :recipe do
|
||||
|
||||
end
|
||||
|
||||
end
|
0
spec/fixtures/.keep
vendored
Normal file
0
spec/fixtures/.keep
vendored
Normal file
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user