Reference no: EM131143706
Advanced Web Development - AJAX Lab
Aim: The aim of this lab is to understand how to implement AJAX in Rails applications
Instructions:
1. Use the VM supplied in class for this. Please refrain from using your own installs for labs.
2. Please answer all questions - you can be very brief.
3. You may have to refer to the book/slides to understand some things.
1. Develop a RoR application that shows the current time (at the server side) to the user. The index page should have the message "The current time is: <time>". It should also have a button that says "Update". The user should be able to click the button to update the time. However, only the time portion should get updated - not the entire page.
Advanced Web Development - "Unit and Functional Testing Lab"
1. Clone the project from https://github.com/siddharthkaza/depot_p_for_lab.gitunder the lab and import into the IDE.
a. Run the application to make sure it's running in the browser.
Hint: It's always a good idea to run 'bundle update and then 'rake db:migrate' and 'rake db:seed' first - when using an application from another location. This updates any gems needed and brings the DB to its newest version.
1. Validations
Validations are methods that are placed in the model to validate data before records are entered in the database.
In the depot application, we will put in validations in the product model to prevent bad data from being entered in the database (for instance, 'a product should always have a title').
a. Run the depot application, enter a new product in the database (go to /products in the URL to get to the products listing).
b. What validations do you think the product model needs? List them here.
c. Enter the following statements in the product model (product.rb) one-by-one
validates :title, :description, :image_url, presence: true
validates :price, numericality: {greater_than_or_equal_to: 0.01}
validates :title, uniqueness: true
validates :image_url, allow_blank: true, format: {
with: %r{\.(gif|jpg|png)\Z}i,
message: 'must be a URL for GIF, JPG or PNG image.'
}
validates :title, length: {minimum: 10}
d. Create another product that fails the validations (for e.g., leave the title empty). You notice that errors show up at the top of the page after you have. How does that work? What data structures are being used in the view to show the errors?
e. Are there any more validations that you want see in the products model? Think about how you would add them. Bring them up when we discuss the lab in the class.
2. Testing
b. Study the model tests for the 'products' model in the application (they are located under the 'tests' folder). Run those model tests and see the results. The command to run all the model tests (also known as 'unit' tests) in your application is 'rake test:units'
Do you think the application needs more unit/model tests for products? Explain here.
c. Study the controller tests in the application. Run the functional tests (rake test:functionals) and see the results.
i. You will notice that some functional tests fail. Why do they fail? Study the assert_difference method for one of them. When one of the test fails you get a message:
Product.count didn't change by -1
<2> expected but was
<4>.
What do the numbers <2> and <4> mean?
ii. Fix the code so that all failing tests pass.
3. Download the address book application https://github.com/siddharthkaza/addressbook_rails42
Write two unit tests and two functional tests for the application. See the examples in depot_p. You might have to write the validations in the model to write unit tests.
4. How much time did you spend on this lab?
Attachment:- Assignment.rar
Estimate how many miles this star travels in one year
: It takes 3x107 years for a particular star to make one orbit around its galaxy. Assume that this star's orbit in its galaxy is circular with a diameter of 104 light years. A light year is the distance that light travels in one year. There are about 5..
|
Pay the mortgage off by repaying the outstanding balance
: 4-21. When you purchased your house, you took out a 30-year annual-payment mortgage with an interest rate of 6% per year. The annual payment on the mortgage is $12,000. You have just made a payment and have now decided to pay the mortgage off by repa..
|
Evaluate the technology trends available to help
: Your detailed promotional strategy to support theintroduction(Advertising, sales promotion, sales force, direct marketing, P/Retc) Include your promotional budget, Evaluate the technology trends available to help youmarket the product.
|
What is a reflective cross-site scripting attack
: What is a reflective cross-site scripting attack? Which Web application attack is more likely to extract privacy data elements out of a database?
|
Develop a ror application that shows the current time
: Develop a RoR application that shows the current time (at the server side) to the user. The index page should have the message "The current time is: ".
|
The following was published with the financial statements
: Write a brief memo to your instructor discussing American Exploration Company's note regarding property, plant, and equipment. Your memo should address what is meant by the "successful efforts method" and "units-of-activity method."
|
Three largest consumer segments within particular market
: After reading the chapters and lecture notes regarding marketing segmentation and target markets, select one of the following product categories (cars, trucks, SUV’s, shoe stores, men’s or women’s clothing stores, computers, beer, headphones, or fitn..
|
What is the main difference between a virus and a trojan
: What is the main difference between a virus and a Trojan? A virus or malware can impact which of the three tenets of information systems security (confidentiality, integrity, or availability)? In what way?
|
Determine which proposal will be the final outcome
: Finally, the last person has the right to pass it or reject it. If the last person's payoff is the smallest among the three, then the proposal will be rejected and no one will get anything. The decision making process can be done by only one time. Pl..
|